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);
204 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 //----- static tables
234 NameToCharCode * // mapping from char name to
235 macRomanReverseMap; // MacRomanEncoding index
237 //----- user-modifiable settings
239 NameToCharCode * // mapping from char name to Unicode
241 GHash *cidToUnicodes; // files for mappings from char collections
242 // to Unicode, indexed by collection name
244 GHash *unicodeToUnicodes; // files for Unicode-to-Unicode mappings,
245 // indexed by font name pattern [GString]
246 GHash *residentUnicodeMaps; // mappings from Unicode to char codes,
247 // indexed by encoding name [UnicodeMap]
248 GHash *unicodeMaps; // files for mappings from Unicode to char
249 // codes, indexed by encoding name [GString]
250 GHash *cMapDirs; // list of CMap dirs, indexed by collection
251 // name [GList[GString]]
252 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
253 GHash *displayFonts; // display font info, indexed by font name
254 // [DisplayFontParam]
255 GHash *displayCIDFonts; // display CID font info, indexed by
256 // collection [DisplayFontParam]
257 GHash *displayNamedCIDFonts; // display CID font info, indexed by
258 // font name [DisplayFontParam]
259 GString *psFile; // PostScript file or command (for xpdf)
260 int psPaperWidth; // paper size, in PostScript points, for
261 int psPaperHeight; // PostScript output
262 int psImageableLLX, // imageable area, in PostScript points,
263 psImageableLLY, // for PostScript output
266 GBool psCrop; // crop PS output to CropBox
267 GBool psExpandSmaller; // expand smaller pages to fill paper
268 GBool psShrinkLarger; // shrink larger pages to fit paper
269 GBool psCenter; // center pages on the paper
270 GBool psDuplex; // enable duplexing in PostScript?
271 PSLevel psLevel; // PostScript level to generate
272 GHash *psFonts; // PostScript font info, indexed by PDF
273 // font name [PSFontParam]
274 GList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
275 GList *psFonts16; // generic 16-bit fonts [PSFontParam]
276 GBool psEmbedType1; // embed Type 1 fonts?
277 GBool psEmbedTrueType; // embed TrueType fonts?
278 GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
279 GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
280 GBool psOPI; // generate PostScript OPI comments?
281 GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
282 GString *textEncoding; // encoding (unicodeMap) to use for text
284 EndOfLineKind textEOL; // type of EOL marker to use for text
286 GBool textPageBreaks; // insert end-of-page markers?
287 GBool textKeepTinyChars; // keep all characters in text output
288 GList *fontDirs; // list of font dirs [GString]
289 GString *initialZoom; // initial zoom level
290 GBool enableT1lib; // t1lib enable flag
291 GBool enableFreeType; // FreeType enable flag
292 GBool antialias; // anti-aliasing enable flag
293 GString *urlCommand; // command executed for URL links
294 GString *movieCommand; // command executed for movie annotations
295 GBool mapNumericCharNames; // map numeric char names (from font subsets)?
296 GBool printCommands; // print the drawing commands
297 GBool errQuiet; // suppress error messages?
299 CharCodeToUnicodeCache *cidToUnicodeCache;
300 CharCodeToUnicodeCache *unicodeToUnicodeCache;
301 UnicodeMapCache *unicodeMapCache;
302 CMapCache *cMapCache;
306 GMutex unicodeMapCacheMutex;
307 GMutex cMapCacheMutex;