1 //========================================================================
5 // Copyright 2001-2003 Glyph & Cog, LLC
7 //========================================================================
10 #define GLOBALPARAMS_H
14 #ifdef USE_GCC_PRAGMAS
20 #include "CharTypes.h"
30 class CharCodeToUnicode;
31 class CharCodeToUnicodeCache;
33 class UnicodeMapCache;
38 //------------------------------------------------------------------------
40 // The global parameters object.
41 extern GlobalParams *globalParams;
43 //------------------------------------------------------------------------
45 enum DisplayFontParamKind {
50 class DisplayFontParam {
53 GString *name; // font name for 8-bit fonts and named
54 // CID fonts; collection name for
56 DisplayFontParamKind kind;
66 DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
70 //------------------------------------------------------------------------
75 GString *pdfFontName; // PDF font name for 8-bit fonts and
76 // named 16-bit fonts; char collection
77 // name for generic 16-bit fonts
78 int wMode; // writing mode (0=horiz, 1=vert) for
80 GString *psFontName; // PostScript font name
81 GString *encoding; // encoding, for 16-bit fonts only
83 PSFontParam(GString *pdfFontNameA, int wModeA,
84 GString *psFontNameA, GString *encodingA);
88 //------------------------------------------------------------------------
99 //------------------------------------------------------------------------
107 //------------------------------------------------------------------------
112 // Initialize the global parameters by attempting to read a config
114 GlobalParams(char *cfgFileName);
118 void setupBaseFonts(char *dir);
122 CharCode getMacRomanCharCode(char *charName);
124 Unicode mapNameToUnicode(char *charName);
125 UnicodeMap *getResidentUnicodeMap(GString *encodingName);
126 FILE *getUnicodeMapFile(GString *encodingName);
127 FILE *findCMapFile(GString *collection, GString *cMapName);
128 FILE *findToUnicodeFile(GString *name);
129 DisplayFontParam *getDisplayFont(GString *fontName);
130 DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
131 GString *getPSFile();
132 int getPSPaperWidth();
133 int getPSPaperHeight();
134 void getPSImageableArea(int *llx, int *lly, int *urx, int *ury);
137 GBool getPSExpandSmaller();
138 GBool getPSShrinkLarger();
140 PSLevel getPSLevel();
141 PSFontParam *getPSFont(GString *fontName);
142 PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
143 GBool getPSEmbedType1();
144 GBool getPSEmbedTrueType();
145 GBool getPSEmbedCIDPostScript();
146 GBool getPSEmbedCIDTrueType();
148 GBool getPSASCIIHex();
149 GString *getTextEncodingName();
150 EndOfLineKind getTextEOL();
151 GBool getTextPageBreaks();
152 GBool getTextKeepTinyChars();
153 GString *findFontFile(GString *fontName, char **exts);
154 GString *getInitialZoom();
155 GBool getEnableT1lib();
156 GBool getEnableFreeType();
157 GBool getAntialias();
158 GString *getURLCommand() { return urlCommand; }
159 GString *getMovieCommand() { return movieCommand; }
160 GBool getMapNumericCharNames();
161 GBool getPrintCommands();
164 CharCodeToUnicode *getCIDToUnicode(GString *collection);
165 CharCodeToUnicode *getUnicodeToUnicode(GString *fontName);
166 UnicodeMap *getUnicodeMap(GString *encodingName);
167 CMap *getCMap(GString *collection, GString *cMapName);
168 UnicodeMap *getTextEncoding();
170 //----- functions to set parameters
172 void addDisplayFont(DisplayFontParam *param);
173 void setPSFile(char *file);
174 GBool setPSPaperSize(char *size);
175 void setPSPaperWidth(int width);
176 void setPSPaperHeight(int height);
177 void setPSImageableArea(int llx, int lly, int urx, int ury);
178 void setPSDuplex(GBool duplex);
179 void setPSCrop(GBool crop);
180 void setPSExpandSmaller(GBool expand);
181 void setPSShrinkLarger(GBool shrink);
182 void setPSCenter(GBool center);
183 void setPSLevel(PSLevel level);
184 void setPSEmbedType1(GBool embed);
185 void setPSEmbedTrueType(GBool embed);
186 void setPSEmbedCIDPostScript(GBool embed);
187 void setPSEmbedCIDTrueType(GBool embed);
188 void setPSOPI(GBool opi);
189 void setPSASCIIHex(GBool hex);
190 void setTextEncoding(char *encodingName);
191 GBool setTextEOL(char *s);
192 void setTextPageBreaks(GBool pageBreaks);
193 void setTextKeepTinyChars(GBool keep);
194 void setInitialZoom(char *s);
195 GBool setEnableT1lib(char *s);
196 GBool setEnableFreeType(char *s);
197 GBool setAntialias(char *s);
198 void setMapNumericCharNames(GBool map);
199 void setPrintCommands(GBool printCommandsA);
200 void setErrQuiet(GBool errQuietA);
201 void parseFile(GString *fileName, FILE *f);
205 void parseNameToUnicode(GList *tokens, GString *fileName, int line);
206 void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
207 void parseUnicodeToUnicode(GList *tokens, GString *fileName, int line);
208 void parseUnicodeMap(GList *tokens, GString *fileName, int line);
209 void parseCMapDir(GList *tokens, GString *fileName, int line);
210 void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
211 void parseDisplayFont(GList *tokens, GHash *fontHash,
212 DisplayFontParamKind kind,
213 GString *fileName, int line);
214 void parsePSFile(GList *tokens, GString *fileName, int line);
215 void parsePSPaperSize(GList *tokens, GString *fileName, int line);
216 void parsePSImageableArea(GList *tokens, GString *fileName, int line);
217 void parsePSLevel(GList *tokens, GString *fileName, int line);
218 void parsePSFont(GList *tokens, GString *fileName, int line);
219 void parsePSFont16(char *cmdName, GList *fontList,
220 GList *tokens, GString *fileName, int line);
221 void parseTextEncoding(GList *tokens, GString *fileName, int line);
222 void parseTextEOL(GList *tokens, GString *fileName, int line);
223 void parseFontDir(GList *tokens, GString *fileName, int line);
224 void parseInitialZoom(GList *tokens, GString *fileName, int line);
225 void parseCommand(char *cmdName, GString **val,
226 GList *tokens, GString *fileName, int line);
227 void parseYesNo(char *cmdName, GBool *flag,
228 GList *tokens, GString *fileName, int line);
229 GBool parseYesNo2(char *token, GBool *flag);
230 UnicodeMap *getUnicodeMap2(GString *encodingName);
232 //----- config file base path
236 //----- static tables
238 NameToCharCode * // mapping from char name to
239 macRomanReverseMap; // MacRomanEncoding index
241 //----- user-modifiable settings
243 NameToCharCode * // mapping from char name to Unicode
245 GHash *cidToUnicodes; // files for mappings from char collections
246 // to Unicode, indexed by collection name
248 GHash *unicodeToUnicodes; // files for Unicode-to-Unicode mappings,
249 // indexed by font name pattern [GString]
250 GHash *residentUnicodeMaps; // mappings from Unicode to char codes,
251 // indexed by encoding name [UnicodeMap]
252 GHash *unicodeMaps; // files for mappings from Unicode to char
253 // codes, indexed by encoding name [GString]
254 GHash *cMapDirs; // list of CMap dirs, indexed by collection
255 // name [GList[GString]]
256 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
257 GHash *displayFonts; // display font info, indexed by font name
258 // [DisplayFontParam]
259 GHash *displayCIDFonts; // display CID font info, indexed by
260 // collection [DisplayFontParam]
261 GHash *displayNamedCIDFonts; // display CID font info, indexed by
262 // font name [DisplayFontParam]
263 GString *psFile; // PostScript file or command (for xpdf)
264 int psPaperWidth; // paper size, in PostScript points, for
265 int psPaperHeight; // PostScript output
266 int psImageableLLX, // imageable area, in PostScript points,
267 psImageableLLY, // for PostScript output
270 GBool psCrop; // crop PS output to CropBox
271 GBool psExpandSmaller; // expand smaller pages to fill paper
272 GBool psShrinkLarger; // shrink larger pages to fit paper
273 GBool psCenter; // center pages on the paper
274 GBool psDuplex; // enable duplexing in PostScript?
275 PSLevel psLevel; // PostScript level to generate
276 GHash *psFonts; // PostScript font info, indexed by PDF
277 // font name [PSFontParam]
278 GList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
279 GList *psFonts16; // generic 16-bit fonts [PSFontParam]
280 GBool psEmbedType1; // embed Type 1 fonts?
281 GBool psEmbedTrueType; // embed TrueType fonts?
282 GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
283 GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
284 GBool psOPI; // generate PostScript OPI comments?
285 GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
286 GString *textEncoding; // encoding (unicodeMap) to use for text
288 EndOfLineKind textEOL; // type of EOL marker to use for text
290 GBool textPageBreaks; // insert end-of-page markers?
291 GBool textKeepTinyChars; // keep all characters in text output
292 GList *fontDirs; // list of font dirs [GString]
293 GString *initialZoom; // initial zoom level
294 GBool enableT1lib; // t1lib enable flag
295 GBool enableFreeType; // FreeType enable flag
296 GBool antialias; // anti-aliasing enable flag
297 GString *urlCommand; // command executed for URL links
298 GString *movieCommand; // command executed for movie annotations
299 GBool mapNumericCharNames; // map numeric char names (from font subsets)?
300 GBool printCommands; // print the drawing commands
301 GBool errQuiet; // suppress error messages?
303 CharCodeToUnicodeCache *cidToUnicodeCache;
304 CharCodeToUnicodeCache *unicodeToUnicodeCache;
305 UnicodeMapCache *unicodeMapCache;
306 CMapCache *cMapCache;
310 GMutex unicodeMapCacheMutex;
311 GMutex cMapCacheMutex;