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 {
51 class DisplayFontParam {
54 GString *name; // font name for 8-bit fonts and named
55 // CID fonts; collection name for
57 DisplayFontParamKind kind;
71 DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
72 DisplayFontParam(char *nameA, char *xlfdA, char *encodingA);
76 // Font rasterizer control.
77 enum FontRastControl {
78 fontRastNone, // don't use this rasterizer
79 fontRastPlain, // use it, without anti-aliasing
80 fontRastAALow, // use it, with low-level anti-aliasing
81 fontRastAAHigh // use it, with high-level anti-aliasing
84 //------------------------------------------------------------------------
89 GString *pdfFontName; // PDF font name for 8-bit fonts and
90 // named 16-bit fonts; char collection
91 // name for generic 16-bit fonts
92 int wMode; // writing mode (0=horiz, 1=vert) for
94 GString *psFontName; // PostScript font name
95 GString *encoding; // encoding, for 16-bit fonts only
97 PSFontParam(GString *pdfFontNameA, int wModeA,
98 GString *psFontNameA, GString *encodingA);
102 //------------------------------------------------------------------------
113 //------------------------------------------------------------------------
121 //------------------------------------------------------------------------
126 // Initialize the global parameters by attempting to read a config
128 GlobalParams(char *cfgFileName);
134 CharCode getMacRomanCharCode(char *charName);
136 Unicode mapNameToUnicode(char *charName);
137 UnicodeMap *getResidentUnicodeMap(GString *encodingName);
138 FILE *getUnicodeMapFile(GString *encodingName);
139 FILE *findCMapFile(GString *collection, GString *cMapName);
140 FILE *findToUnicodeFile(GString *name);
141 DisplayFontParam *getDisplayFont(GString *fontName);
142 DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
143 GString *getPSFile();
144 int getPSPaperWidth();
145 int getPSPaperHeight();
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();
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 FontRastControl getT1libControl();
163 FontRastControl getFreeTypeControl();
164 GString *getURLCommand() { return urlCommand; }
165 GString *getMovieCommand() { return movieCommand; }
166 GBool getMapNumericCharNames();
167 GBool getPrintCommands();
170 CharCodeToUnicode *getCIDToUnicode(GString *collection);
171 CharCodeToUnicode *getUnicodeToUnicode(GString *fontName);
172 UnicodeMap *getUnicodeMap(GString *encodingName);
173 CMap *getCMap(GString *collection, GString *cMapName);
174 UnicodeMap *getTextEncoding();
176 //----- functions to set parameters
178 void addDisplayFont(DisplayFontParam *param);
179 void setPSFile(char *file);
180 GBool setPSPaperSize(char *size);
181 void setPSPaperWidth(int width);
182 void setPSPaperHeight(int height);
183 void setPSDuplex(GBool duplex);
184 void setPSLevel(PSLevel level);
185 void setPSEmbedType1(GBool embed);
186 void setPSEmbedTrueType(GBool embed);
187 void setPSEmbedCIDPostScript(GBool embed);
188 void setPSEmbedCIDTrueType(GBool embed);
189 void setPSOPI(GBool opi);
190 void setPSASCIIHex(GBool hex);
191 void setTextEncoding(char *encodingName);
192 GBool setTextEOL(char *s);
193 void setTextPageBreaks(GBool pageBreaks);
194 void setTextKeepTinyChars(GBool keep);
195 void setInitialZoom(char *s);
196 GBool setT1libControl(char *s);
197 GBool setFreeTypeControl(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 parsePSLevel(GList *tokens, GString *fileName, int line);
217 void parsePSFont(GList *tokens, GString *fileName, int line);
218 void parsePSFont16(char *cmdName, GList *fontList,
219 GList *tokens, GString *fileName, int line);
220 void parseTextEncoding(GList *tokens, GString *fileName, int line);
221 void parseTextEOL(GList *tokens, GString *fileName, int line);
222 void parseFontDir(GList *tokens, GString *fileName, int line);
223 void parseInitialZoom(GList *tokens, GString *fileName, int line);
224 void parseFontRastControl(char *cmdName, FontRastControl *val,
225 GList *tokens, GString *fileName, int line);
226 void parseCommand(char *cmdName, GString **val,
227 GList *tokens, GString *fileName, int line);
228 void parseYesNo(char *cmdName, GBool *flag,
229 GList *tokens, GString *fileName, int line);
230 UnicodeMap *getUnicodeMap2(GString *encodingName);
231 GBool setFontRastControl(FontRastControl *val, char *s);
233 //----- static tables
235 NameToCharCode * // mapping from char name to
236 macRomanReverseMap; // MacRomanEncoding index
238 //----- user-modifiable settings
240 NameToCharCode * // mapping from char name to Unicode
242 GHash *cidToUnicodes; // files for mappings from char collections
243 // to Unicode, indexed by collection name
245 GHash *unicodeToUnicodes; // files for Unicode-to-Unicode mappings,
246 // indexed by font name pattern [GString]
247 GHash *residentUnicodeMaps; // mappings from Unicode to char codes,
248 // indexed by encoding name [UnicodeMap]
249 GHash *unicodeMaps; // files for mappings from Unicode to char
250 // codes, indexed by encoding name [GString]
251 GHash *cMapDirs; // list of CMap dirs, indexed by collection
252 // name [GList[GString]]
253 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
254 GHash *displayFonts; // display font info, indexed by font name
255 // [DisplayFontParam]
256 GHash *displayCIDFonts; // display CID font info, indexed by
257 // collection [DisplayFontParam]
258 GHash *displayNamedCIDFonts; // display CID font info, indexed by
259 // font name [DisplayFontParam]
260 GString *psFile; // PostScript file or command (for xpdf)
261 int psPaperWidth; // paper size, in PostScript points, for
262 int psPaperHeight; // PostScript output
263 GBool psDuplex; // enable duplexing in PostScript?
264 PSLevel psLevel; // PostScript level to generate
265 GHash *psFonts; // PostScript font info, indexed by PDF
266 // font name [PSFontParam]
267 GList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
268 GList *psFonts16; // generic 16-bit fonts [PSFontParam]
269 GBool psEmbedType1; // embed Type 1 fonts?
270 GBool psEmbedTrueType; // embed TrueType fonts?
271 GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
272 GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
273 GBool psOPI; // generate PostScript OPI comments?
274 GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
275 GString *textEncoding; // encoding (unicodeMap) to use for text
277 EndOfLineKind textEOL; // type of EOL marker to use for text
279 GBool textPageBreaks; // insert end-of-page markers?
280 GBool textKeepTinyChars; // keep all characters in text output
281 GList *fontDirs; // list of font dirs [GString]
282 GString *initialZoom; // initial zoom level
283 FontRastControl t1libControl; // t1lib rasterization mode
284 FontRastControl // FreeType rasterization mode
286 GString *urlCommand; // command executed for URL links
287 GString *movieCommand; // command executed for movie annotations
288 GBool mapNumericCharNames; // map numeric char names (from font subsets)?
289 GBool printCommands; // print the drawing commands
290 GBool errQuiet; // suppress error messages?
292 CharCodeToUnicodeCache *cidToUnicodeCache;
293 CharCodeToUnicodeCache *unicodeToUnicodeCache;
294 UnicodeMapCache *unicodeMapCache;
295 CMapCache *cMapCache;
299 GMutex unicodeMapCacheMutex;
300 GMutex cMapCacheMutex;