]> git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/GlobalParams.h
Merge changes from CUPS 1.4svn-r7199.
[thirdparty/cups.git] / pdftops / GlobalParams.h
1 //========================================================================
2 //
3 // GlobalParams.h
4 //
5 // Copyright 2001-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #ifndef GLOBALPARAMS_H
10 #define GLOBALPARAMS_H
11
12 #include <config.h>
13
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17
18 #include <stdio.h>
19 #include "gtypes.h"
20 #include "CharTypes.h"
21
22 #if MULTITHREADED
23 #include "GMutex.h"
24 #endif
25
26 class GString;
27 class GList;
28 class GHash;
29 class NameToCharCode;
30 class CharCodeToUnicode;
31 class CharCodeToUnicodeCache;
32 class UnicodeMap;
33 class UnicodeMapCache;
34 class CMap;
35 class CMapCache;
36 struct XpdfSecurityHandler;
37 class GlobalParams;
38
39 //------------------------------------------------------------------------
40
41 // The global parameters object.
42 extern GlobalParams *globalParams;
43
44 //------------------------------------------------------------------------
45
46 enum DisplayFontParamKind {
47 displayFontT1,
48 displayFontTT
49 };
50
51 struct DisplayFontParamT1 {
52 GString *fileName;
53 };
54
55 struct DisplayFontParamTT {
56 GString *fileName;
57 };
58
59 class DisplayFontParam {
60 public:
61
62 GString *name; // font name for 8-bit fonts and named
63 // CID fonts; collection name for
64 // generic CID fonts
65 DisplayFontParamKind kind;
66 union {
67 DisplayFontParamT1 t1;
68 DisplayFontParamTT tt;
69 };
70
71 DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
72 ~DisplayFontParam();
73 };
74
75 //------------------------------------------------------------------------
76
77 class PSFontParam {
78 public:
79
80 GString *pdfFontName; // PDF font name for 8-bit fonts and
81 // named 16-bit fonts; char collection
82 // name for generic 16-bit fonts
83 int wMode; // writing mode (0=horiz, 1=vert) for
84 // 16-bit fonts
85 GString *psFontName; // PostScript font name
86 GString *encoding; // encoding, for 16-bit fonts only
87
88 PSFontParam(GString *pdfFontNameA, int wModeA,
89 GString *psFontNameA, GString *encodingA);
90 ~PSFontParam();
91 };
92
93 //------------------------------------------------------------------------
94
95 enum PSLevel {
96 psLevel1,
97 psLevel1Sep,
98 psLevel2,
99 psLevel2Sep,
100 psLevel3,
101 psLevel3Sep
102 };
103
104 //------------------------------------------------------------------------
105
106 enum EndOfLineKind {
107 eolUnix, // LF
108 eolDOS, // CR+LF
109 eolMac // CR
110 };
111
112 //------------------------------------------------------------------------
113
114 class GlobalParams {
115 public:
116
117 // Initialize the global parameters by attempting to read a config
118 // file.
119 GlobalParams(char *cfgFileName);
120
121 ~GlobalParams();
122
123 void setBaseDir(char *dir);
124 void setupBaseFonts(char *dir);
125
126 //----- accessors
127
128 CharCode getMacRomanCharCode(char *charName);
129
130 GString *getBaseDir();
131 Unicode mapNameToUnicode(char *charName);
132 UnicodeMap *getResidentUnicodeMap(GString *encodingName);
133 FILE *getUnicodeMapFile(GString *encodingName);
134 FILE *findCMapFile(GString *collection, GString *cMapName);
135 FILE *findToUnicodeFile(GString *name);
136 DisplayFontParam *getDisplayFont(GString *fontName);
137 DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
138 GString *getPSFile();
139 int getPSPaperWidth();
140 int getPSPaperHeight();
141 void getPSImageableArea(int *llx, int *lly, int *urx, int *ury);
142 GBool getPSDuplex();
143 GBool getPSCrop();
144 GBool getPSExpandSmaller();
145 GBool getPSShrinkLarger();
146 GBool getPSCenter();
147 PSLevel getPSLevel();
148 PSFontParam *getPSFont(GString *fontName);
149 PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
150 GBool getPSEmbedType1();
151 GBool getPSEmbedTrueType();
152 GBool getPSEmbedCIDPostScript();
153 GBool getPSEmbedCIDTrueType();
154 GBool getPSOPI();
155 GBool getPSASCIIHex();
156 GString *getTextEncodingName();
157 EndOfLineKind getTextEOL();
158 GBool getTextPageBreaks();
159 GBool getTextKeepTinyChars();
160 GString *findFontFile(GString *fontName, char **exts);
161 GString *getInitialZoom();
162 GBool getContinuousView();
163 GBool getEnableT1lib();
164 GBool getEnableFreeType();
165 GBool getAntialias();
166 GString *getURLCommand() { return urlCommand; }
167 GString *getMovieCommand() { return movieCommand; }
168 GBool getMapNumericCharNames();
169 GBool getPrintCommands();
170 GBool getErrQuiet();
171
172 CharCodeToUnicode *getCIDToUnicode(GString *collection);
173 CharCodeToUnicode *getUnicodeToUnicode(GString *fontName);
174 UnicodeMap *getUnicodeMap(GString *encodingName);
175 CMap *getCMap(GString *collection, GString *cMapName);
176 UnicodeMap *getTextEncoding();
177
178 //----- functions to set parameters
179
180 void addDisplayFont(DisplayFontParam *param);
181 void setPSFile(char *file);
182 GBool setPSPaperSize(char *size);
183 void setPSPaperWidth(int width);
184 void setPSPaperHeight(int height);
185 void setPSImageableArea(int llx, int lly, int urx, int ury);
186 void setPSDuplex(GBool duplex);
187 void setPSCrop(GBool crop);
188 void setPSExpandSmaller(GBool expand);
189 void setPSShrinkLarger(GBool shrink);
190 void setPSCenter(GBool center);
191 void setPSLevel(PSLevel level);
192 void setPSEmbedType1(GBool embed);
193 void setPSEmbedTrueType(GBool embed);
194 void setPSEmbedCIDPostScript(GBool embed);
195 void setPSEmbedCIDTrueType(GBool embed);
196 void setPSOPI(GBool opi);
197 void setPSASCIIHex(GBool hex);
198 void setTextEncoding(char *encodingName);
199 GBool setTextEOL(char *s);
200 void setTextPageBreaks(GBool pageBreaks);
201 void setTextKeepTinyChars(GBool keep);
202 void setInitialZoom(char *s);
203 void setContinuousView(GBool cont);
204 GBool setEnableT1lib(char *s);
205 GBool setEnableFreeType(char *s);
206 GBool setAntialias(char *s);
207 void setMapNumericCharNames(GBool map);
208 void setPrintCommands(GBool printCommandsA);
209 void setErrQuiet(GBool errQuietA);
210
211 //----- security handlers
212
213 void addSecurityHandler(XpdfSecurityHandler *handler);
214 XpdfSecurityHandler *getSecurityHandler(char *name);
215
216 private:
217
218 void parseFile(GString *fileName, FILE *f);
219 void parseNameToUnicode(GList *tokens, GString *fileName, int line);
220 void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
221 void parseUnicodeToUnicode(GList *tokens, GString *fileName, int line);
222 void parseUnicodeMap(GList *tokens, GString *fileName, int line);
223 void parseCMapDir(GList *tokens, GString *fileName, int line);
224 void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
225 void parseDisplayFont(GList *tokens, GHash *fontHash,
226 DisplayFontParamKind kind,
227 GString *fileName, int line);
228 void parsePSFile(GList *tokens, GString *fileName, int line);
229 void parsePSPaperSize(GList *tokens, GString *fileName, int line);
230 void parsePSImageableArea(GList *tokens, GString *fileName, int line);
231 void parsePSLevel(GList *tokens, GString *fileName, int line);
232 void parsePSFont(GList *tokens, GString *fileName, int line);
233 void parsePSFont16(char *cmdName, GList *fontList,
234 GList *tokens, GString *fileName, int line);
235 void parseTextEncoding(GList *tokens, GString *fileName, int line);
236 void parseTextEOL(GList *tokens, GString *fileName, int line);
237 void parseFontDir(GList *tokens, GString *fileName, int line);
238 void parseInitialZoom(GList *tokens, GString *fileName, int line);
239 void parseCommand(char *cmdName, GString **val,
240 GList *tokens, GString *fileName, int line);
241 void parseYesNo(char *cmdName, GBool *flag,
242 GList *tokens, GString *fileName, int line);
243 GBool parseYesNo2(char *token, GBool *flag);
244 UnicodeMap *getUnicodeMap2(GString *encodingName);
245 #ifdef ENABLE_PLUGINS
246 GBool loadPlugin(char *type, char *name);
247 #endif
248
249 //----- static tables
250
251 NameToCharCode * // mapping from char name to
252 macRomanReverseMap; // MacRomanEncoding index
253
254 //----- user-modifiable settings
255
256 GString *baseDir; // base directory - for plugins, etc.
257 NameToCharCode * // mapping from char name to Unicode
258 nameToUnicode;
259 GHash *cidToUnicodes; // files for mappings from char collections
260 // to Unicode, indexed by collection name
261 // [GString]
262 GHash *unicodeToUnicodes; // files for Unicode-to-Unicode mappings,
263 // indexed by font name pattern [GString]
264 GHash *residentUnicodeMaps; // mappings from Unicode to char codes,
265 // indexed by encoding name [UnicodeMap]
266 GHash *unicodeMaps; // files for mappings from Unicode to char
267 // codes, indexed by encoding name [GString]
268 GHash *cMapDirs; // list of CMap dirs, indexed by collection
269 // name [GList[GString]]
270 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
271 GHash *displayFonts; // display font info, indexed by font name
272 // [DisplayFontParam]
273 GHash *displayCIDFonts; // display CID font info, indexed by
274 // collection [DisplayFontParam]
275 GHash *displayNamedCIDFonts; // display CID font info, indexed by
276 // font name [DisplayFontParam]
277 GString *psFile; // PostScript file or command (for xpdf)
278 int psPaperWidth; // paper size, in PostScript points, for
279 int psPaperHeight; // PostScript output
280 int psImageableLLX, // imageable area, in PostScript points,
281 psImageableLLY, // for PostScript output
282 psImageableURX,
283 psImageableURY;
284 GBool psCrop; // crop PS output to CropBox
285 GBool psExpandSmaller; // expand smaller pages to fill paper
286 GBool psShrinkLarger; // shrink larger pages to fit paper
287 GBool psCenter; // center pages on the paper
288 GBool psDuplex; // enable duplexing in PostScript?
289 PSLevel psLevel; // PostScript level to generate
290 GHash *psFonts; // PostScript font info, indexed by PDF
291 // font name [PSFontParam]
292 GList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
293 GList *psFonts16; // generic 16-bit fonts [PSFontParam]
294 GBool psEmbedType1; // embed Type 1 fonts?
295 GBool psEmbedTrueType; // embed TrueType fonts?
296 GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
297 GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
298 GBool psOPI; // generate PostScript OPI comments?
299 GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
300 GString *textEncoding; // encoding (unicodeMap) to use for text
301 // output
302 EndOfLineKind textEOL; // type of EOL marker to use for text
303 // output
304 GBool textPageBreaks; // insert end-of-page markers?
305 GBool textKeepTinyChars; // keep all characters in text output
306 GList *fontDirs; // list of font dirs [GString]
307 GString *initialZoom; // initial zoom level
308 GBool continuousView; // continuous view mode
309 GBool enableT1lib; // t1lib enable flag
310 GBool enableFreeType; // FreeType enable flag
311 GBool antialias; // anti-aliasing enable flag
312 GString *urlCommand; // command executed for URL links
313 GString *movieCommand; // command executed for movie annotations
314 GBool mapNumericCharNames; // map numeric char names (from font subsets)?
315 GBool printCommands; // print the drawing commands
316 GBool errQuiet; // suppress error messages?
317
318 CharCodeToUnicodeCache *cidToUnicodeCache;
319 CharCodeToUnicodeCache *unicodeToUnicodeCache;
320 UnicodeMapCache *unicodeMapCache;
321 CMapCache *cMapCache;
322
323 #ifdef ENABLE_PLUGINS
324 GList *plugins; // list of plugins [Plugin]
325 GList *securityHandlers; // list of loaded security handlers
326 // [XpdfSecurityHandler]
327 #endif
328
329 #if MULTITHREADED
330 GMutex mutex;
331 GMutex unicodeMapCacheMutex;
332 GMutex cMapCacheMutex;
333 #endif
334 };
335
336 #endif