1 //========================================================================
5 // Copyright 2001-2002 Glyph & Cog, LLC
7 //========================================================================
10 #define GLOBALPARAMS_H
14 #ifdef USE_GCC_PRAGMAS
20 #include "CharTypes.h"
26 class CharCodeToUnicode;
27 class CIDToUnicodeCache;
29 class UnicodeMapCache;
34 //------------------------------------------------------------------------
36 // The global parameters object.
37 extern GlobalParams *globalParams;
39 //------------------------------------------------------------------------
41 enum DisplayFontParamKind {
47 class DisplayFontParam {
50 GString *name; // font name for 8-bit fonts and named
51 // CID fonts; collection name for
53 DisplayFontParamKind kind;
67 DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
68 DisplayFontParam(char *nameA, char *xlfdA, char *encodingA);
72 // Font rasterizer control.
73 enum FontRastControl {
74 fontRastNone, // don't use this rasterizer
75 fontRastPlain, // use it, without anti-aliasing
76 fontRastAALow, // use it, with low-level anti-aliasing
77 fontRastAAHigh // use it, with high-level anti-aliasing
80 //------------------------------------------------------------------------
85 GString *pdfFontName; // PDF font name for 8-bit fonts and
86 // named 16-bit fonts; char collection
87 // name for generic 16-bit fonts
88 int wMode; // writing mode (0=horiz, 1=vert) for
90 GString *psFontName; // PostScript font name
91 GString *encoding; // encoding, for 16-bit fonts only
93 PSFontParam(GString *pdfFontNameA, int wModeA,
94 GString *psFontNameA, GString *encodingA);
98 //------------------------------------------------------------------------
109 //------------------------------------------------------------------------
117 //------------------------------------------------------------------------
122 // Initialize the global parameters by attempting to read a config
124 GlobalParams(char *cfgFileName);
130 CharCode getMacRomanCharCode(char *charName);
132 Unicode mapNameToUnicode(char *charName);
133 FILE *getCIDToUnicodeFile(GString *collection);
134 UnicodeMap *getResidentUnicodeMap(GString *encodingName);
135 FILE *getUnicodeMapFile(GString *encodingName);
136 FILE *findCMapFile(GString *collection, GString *cMapName);
137 FILE *findToUnicodeFile(GString *name);
138 DisplayFontParam *getDisplayFont(GString *fontName);
139 DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
140 GString *getPSFile() { return psFile; }
141 int getPSPaperWidth() { return psPaperWidth; }
142 int getPSPaperHeight() { return psPaperHeight; }
143 GBool getPSDuplex() { return psDuplex; }
144 PSLevel getPSLevel() { return psLevel; }
145 PSFontParam *getPSFont(GString *fontName);
146 PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
147 GBool getPSEmbedType1() { return psEmbedType1; }
148 GBool getPSEmbedTrueType() { return psEmbedTrueType; }
149 GBool getPSEmbedCIDPostScript() { return psEmbedCIDPostScript; }
150 GBool getPSEmbedCIDTrueType() { return psEmbedCIDTrueType; }
151 GBool getPSOPI() { return psOPI; }
152 GBool getPSASCIIHex() { return psASCIIHex; }
153 GString *getTextEncodingName() { return textEncoding; }
154 EndOfLineKind getTextEOL() { return textEOL; }
155 GBool getTextKeepTinyChars() { return textKeepTinyChars; }
156 GString *findFontFile(GString *fontName, char *ext1, char *ext2);
157 GString *getInitialZoom() { return initialZoom; }
158 FontRastControl getT1libControl() { return t1libControl; }
159 FontRastControl getFreeTypeControl() { return freetypeControl; }
160 GString *getURLCommand() { return urlCommand; }
161 GString *getMovieCommand() { return movieCommand; }
162 GBool getMapNumericCharNames() { return mapNumericCharNames; }
163 GBool getPrintCommands() { return printCommands; }
164 GBool getErrQuiet() { return errQuiet; }
166 CharCodeToUnicode *getCIDToUnicode(GString *collection);
167 UnicodeMap *getUnicodeMap(GString *encodingName);
168 CMap *getCMap(GString *collection, GString *cMapName);
169 UnicodeMap *getTextEncoding();
171 //----- functions to set parameters
173 void addDisplayFont(DisplayFontParam *param);
174 void setPSFile(char *file);
175 GBool setPSPaperSize(char *size);
176 void setPSPaperWidth(int width);
177 void setPSPaperHeight(int height);
178 void setPSDuplex(GBool duplex);
179 void setPSLevel(PSLevel level);
180 void setPSEmbedType1(GBool embed);
181 void setPSEmbedTrueType(GBool embed);
182 void setPSEmbedCIDPostScript(GBool embed);
183 void setPSEmbedCIDTrueType(GBool embed);
184 void setPSOPI(GBool opi);
185 void setPSASCIIHex(GBool hex);
186 void setTextEncoding(char *encodingName);
187 GBool setTextEOL(char *s);
188 void setTextKeepTinyChars(GBool keep);
189 void setInitialZoom(char *s);
190 GBool setT1libControl(char *s);
191 GBool setFreeTypeControl(char *s);
192 void setMapNumericCharNames(GBool map);
193 void setPrintCommands(GBool printCommandsA);
194 void setErrQuiet(GBool errQuietA);
198 void parseFile(GString *fileName, FILE *f);
199 void parseNameToUnicode(GList *tokens, GString *fileName, int line);
200 void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
201 void parseUnicodeMap(GList *tokens, GString *fileName, int line);
202 void parseCMapDir(GList *tokens, GString *fileName, int line);
203 void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
204 void parseDisplayFont(GList *tokens, GHash *fontHash,
205 DisplayFontParamKind kind,
206 GString *fileName, int line);
207 void parsePSFile(GList *tokens, GString *fileName, int line);
208 void parsePSPaperSize(GList *tokens, GString *fileName, int line);
209 void parsePSLevel(GList *tokens, GString *fileName, int line);
210 void parsePSFont(GList *tokens, GString *fileName, int line);
211 void parsePSFont16(char *cmdName, GList *fontList,
212 GList *tokens, GString *fileName, int line);
213 void parseTextEncoding(GList *tokens, GString *fileName, int line);
214 void parseTextEOL(GList *tokens, GString *fileName, int line);
215 void parseFontDir(GList *tokens, GString *fileName, int line);
216 void parseInitialZoom(GList *tokens, GString *fileName, int line);
217 void parseFontRastControl(char *cmdName, FontRastControl *val,
218 GList *tokens, GString *fileName, int line);
219 void parseCommand(char *cmdName, GString **val,
220 GList *tokens, GString *fileName, int line);
221 void parseYesNo(char *cmdName, GBool *flag,
222 GList *tokens, GString *fileName, int line);
223 GBool setFontRastControl(FontRastControl *val, char *s);
225 //----- static tables
227 NameToCharCode * // mapping from char name to
228 macRomanReverseMap; // MacRomanEncoding index
230 //----- user-modifiable settings
232 NameToCharCode * // mapping from char name to Unicode
234 GHash *cidToUnicodes; // files for mappings from char collections
235 // to Unicode, indexed by collection name
237 GHash *residentUnicodeMaps; // mappings from Unicode to char codes,
238 // indexed by encoding name [UnicodeMap]
239 GHash *unicodeMaps; // files for mappings from Unicode to char
240 // codes, indexed by encoding name [GString]
241 GHash *cMapDirs; // list of CMap dirs, indexed by collection
242 // name [GList[GString]]
243 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
244 GHash *displayFonts; // display font info, indexed by font name
245 // [DisplayFontParam]
246 GHash *displayCIDFonts; // display CID font info, indexed by
247 // collection [DisplayFontParam]
248 GHash *displayNamedCIDFonts; // display CID font info, indexed by
249 // font name [DisplayFontParam]
250 GString *psFile; // PostScript file or command (for xpdf)
251 int psPaperWidth; // paper size, in PostScript points, for
252 int psPaperHeight; // PostScript output
253 GBool psDuplex; // enable duplexing in PostScript?
254 PSLevel psLevel; // PostScript level to generate
255 GHash *psFonts; // PostScript font info, indexed by PDF
256 // font name [PSFontParam]
257 GList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
258 GList *psFonts16; // generic 16-bit fonts [PSFontParam]
259 GBool psEmbedType1; // embed Type 1 fonts?
260 GBool psEmbedTrueType; // embed TrueType fonts?
261 GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
262 GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
263 GBool psOPI; // generate PostScript OPI comments?
264 GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
265 GString *textEncoding; // encoding (unicodeMap) to use for text
267 EndOfLineKind textEOL; // type of EOL marker to use for text
269 GBool textKeepTinyChars; // keep all characters in text output
270 GList *fontDirs; // list of font dirs [GString]
271 GString *initialZoom; // initial zoom level
272 FontRastControl t1libControl; // t1lib rasterization mode
273 FontRastControl // FreeType rasterization mode
275 GString *urlCommand; // command executed for URL links
276 GString *movieCommand; // command executed for movie annotations
277 GBool mapNumericCharNames; // map numeric char names (from font subsets)?
278 GBool printCommands; // print the drawing commands
279 GBool errQuiet; // suppress error messages?
281 CIDToUnicodeCache *cidToUnicodeCache;
282 UnicodeMapCache *unicodeMapCache;
283 CMapCache *cMapCache;