summaryrefslogtreecommitdiff
path: root/Build/source/texk/xdv2pdf/xdv2pdf_globals.h
blob: 4a0e7a6a1760fdf93e5a1ae1cd0d2d95392b7807 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/****************************************************************************\
 Part of the XeTeX typesetting system
 copyright (c) 1994-2005 by SIL International
 written by Jonathan Kew

Permission is hereby granted, free of charge, to any person obtaining  
a copy of this software and associated documentation files (the  
"Software"), to deal in the Software without restriction, including  
without limitation the rights to use, copy, modify, merge, publish,  
distribute, sublicense, and/or sell copies of the Software, and to  
permit persons to whom the Software is furnished to do so, subject to  
the following conditions:

The above copyright notice and this permission notice shall be  
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,  
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF  
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND  
NONINFRINGEMENT. IN NO EVENT SHALL SIL INTERNATIONAL BE LIABLE FOR  
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF  
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of SIL International  
shall not be used in advertising or otherwise to promote the sale,  
use or other dealings in this Software without prior written  
authorization from SIL International.
\****************************************************************************/


#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;
GLOBAL	double_t	gPaperWd;
GLOBAL	double_t	gPaperHt;


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 */