summaryrefslogtreecommitdiff
path: root/Build/source/texk/xdv2pdf/xdv2pdf_globals.h
blob: 63baa0b7e30e3c4ffa969f7588e6bf7e7d9ac8e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/****************************************************************************\
 Part of the XeTeX typesetting system
 copyright (c) 1994-2005 by SIL International
 written by Jonathan Kew

 This software is distributed under the terms of the Common Public License,
 version 1.0.
 For details, see <http://www.opensource.org/licenses/cpl1.0.php> or the file
 cpl1.0.txt included with the software.
\****************************************************************************/


#ifndef XDV2PDF_GLOBALS
#define XDV2PDF_GLOBALS

#include <list>
#include <map>
#include <vector>

#ifdef DEFINE_GLOBALS
#define GLOBAL
#else
#define GLOBAL	extern
#endif

#define	kUndefinedFont	0x80000000UL

GLOBAL	CGContextRef	gCtx;

GLOBAL	CGColorSpaceRef	gRGBColorSpace;
GLOBAL	CGColorSpaceRef	gCMYKColorSpace;
GLOBAL	CGColorSpaceRef	gGrayColorSpace;

GLOBAL	bool 		gPageStarted;
GLOBAL	CGRect		gMediaBox;

struct dviVars {
	SInt32	h;
	SInt32	v;
	SInt32	w;
	SInt32	x;
	SInt32	y;
	SInt32	z;
};
GLOBAL dviVars			dvi;
GLOBAL UInt32			f, cur_cgFont;

GLOBAL double_t kScr2Dvi	// not quite const, actually - mag changes them
#ifdef DEFINE_GLOBALS
	= (72.27 * 65536.0) / 72.0
#endif
	;
GLOBAL double_t kDvi2Scr
#ifdef DEFINE_GLOBALS
	= 1.0 / kScr2Dvi
#endif
	;

GLOBAL CGColorRef	kBlackColor;

GLOBAL std::list<CGColorRef>	gTextColorStack;
GLOBAL std::list<CGColorRef>	gRuleColorStack;

GLOBAL CGColorRef	gTextColor;
GLOBAL CGColorRef	gRuleColor;
GLOBAL CGColorRef	gBackground;

GLOBAL CGColorRef	gCurrentColor;

struct texFont {
				texFont()
                    : cgFont(0)
                    , size(Long2Fix(10))
					, charMap(NULL)
					, hasMetrics(false)
						{
						}
	CGFontRef			cgFont;
    Fixed				size;
	std::vector<Fixed>	widths;
	std::vector<Fixed>	heights;
	std::vector<Fixed>	depths;
	std::vector<UInt16>*charMap;
	bool				hasMetrics;
	bool				hasMap;
};

GLOBAL	std::map<UInt32,texFont>	gTeXFonts;

GLOBAL	long	gPageIndex;
GLOBAL	int		gCounts[10];

struct box {
	float	llx;
	float	lly;
	float	urx;
	float	ury;
};
GLOBAL	box		gAnnotBox;

GLOBAL	int		gTagLevel;
GLOBAL	int		gDviLevel;
GLOBAL	bool	gTrackingBoxes;

GLOBAL	double_t	gMagScale;

GLOBAL	double_t	gPageHt;
GLOBAL	double_t	gPageWd;

struct paperSizeRec {
	const char*	name;
	double_t	width;
	double_t	height;	// dimensions in BP ("big" or PostScript/CG points)
};

#ifndef DEFINE_GLOBALS
GLOBAL	paperSizeRec	gPaperSizes[];
#endif

GLOBAL CFURLRef	gSaveURL;
GLOBAL char		gPdfMarkPath[_POSIX_PATH_MAX+1];
GLOBAL FILE*	gPdfMarkFile;


void	flushAnnotBox();
void	initAnnotBox();
bool	getPaperSize(const char* arg, double_t& paperWd, double_t& paperHt);
void	doPDFspecial(const char* special);
void	doSpecial(const char* special);


void	ensurePageStarted();
void	paintBackground();
void	setColor(CGColorRef color, bool force);
void	doPdfMapLine(const char* line, char mode);
void	doPdfMapFile(const char* fileName);

extern "C" {
	int	xdv2pdf(int argc, char** argv);
};

#endif /* XDV2PDF_GLOBALS */