1 //========================================================================
5 // Copyright 2001-2002 Glyph & Cog, LLC
7 //========================================================================
10 #define GLOBALPARAMS_H
14 #ifdef USE_GCC_PRAGMAS
20 #include "CharTypes.h"
30 class CharCodeToUnicode;
31 class CIDToUnicodeCache;
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 FILE *getCIDToUnicodeFile(GString *collection);
138 UnicodeMap *getResidentUnicodeMap(GString *encodingName);
139 FILE *getUnicodeMapFile(GString *encodingName);
140 FILE *findCMapFile(GString *collection, GString *cMapName);
141 FILE *findToUnicodeFile(GString *name);
142 DisplayFontParam *getDisplayFont(GString *fontName);
143 DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
144 GString *getPSFile();
145 int getPSPaperWidth();
146 int getPSPaperHeight();
148 PSLevel getPSLevel();
149 PSFontParam *getPSFont(GString *fontName);
150 PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
151 GBool getPSEmbedType1();
152 GBool getPSEmbedTrueType();
153 GBool getPSEmbedCIDPostScript();
154 GBool getPSEmbedCIDTrueType();
156 GBool getPSASCIIHex();
157 EndOfLineKind getTextEOL();
158 GBool getTextKeepTinyChars();
159 GString *findFontFile(GString *fontName, char *ext1, char *ext2);
160 GString *getInitialZoom();
161 FontRastControl getT1libControl();
162 FontRastControl getFreeTypeControl();
163 GString *getURLCommand() { return urlCommand; }
164 GString *getMovieCommand() { return movieCommand; }
165 GBool getMapNumericCharNames();
166 GBool getPrintCommands();
169 CharCodeToUnicode *getCIDToUnicode(GString *collection);
170 UnicodeMap *getUnicodeMap(GString *encodingName);
171 CMap *getCMap(GString *collection, GString *cMapName);
172 UnicodeMap *getTextEncoding();
174 //----- functions to set parameters
176 void addDisplayFont(DisplayFontParam *param);
177 void setPSFile(char *file);
178 GBool setPSPaperSize(char *size);
179 void setPSPaperWidth(int width);
180 void setPSPaperHeight(int height);
181 void setPSDuplex(GBool duplex);
182 void setPSLevel(PSLevel level);
183 void setPSEmbedType1(GBool embed);
184 void setPSEmbedTrueType(GBool embed);
185 void setPSEmbedCIDPostScript(GBool embed);
186 void setPSEmbedCIDTrueType(GBool embed);
187 void setPSOPI(GBool opi);
188 void setPSASCIIHex(GBool hex);
189 void setTextEncoding(char *encodingName);
190 GBool setTextEOL(char *s);
191 void setTextKeepTinyChars(GBool keep);
192 void setInitialZoom(char *s);
193 GBool setT1libControl(char *s);
194 GBool setFreeTypeControl(char *s);
195 void setMapNumericCharNames(GBool map);
196 void setPrintCommands(GBool printCommandsA);
197 void setErrQuiet(GBool errQuietA);
201 void parseFile(GString *fileName, FILE *f);
202 void parseNameToUnicode(GList *tokens, GString *fileName, int line);
203 void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
204 void parseUnicodeMap(GList *tokens, GString *fileName, int line);
205 void parseCMapDir(GList *tokens, GString *fileName, int line);
206 void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
207 void parseDisplayFont(GList *tokens, GHash *fontHash,
208 DisplayFontParamKind kind,
209 GString *fileName, int line);
210 void parsePSFile(GList *tokens, GString *fileName, int line);
211 void parsePSPaperSize(GList *tokens, GString *fileName, int line);
212 void parsePSLevel(GList *tokens, GString *fileName, int line);
213 void parsePSFont(GList *tokens, GString *fileName, int line);
214 void parsePSFont16(char *cmdName, GList *fontList,
215 GList *tokens, GString *fileName, int line);
216 void parseTextEncoding(GList *tokens, GString *fileName, int line);
217 void parseTextEOL(GList *tokens, GString *fileName, int line);
218 void parseFontDir(GList *tokens, GString *fileName, int line);
219 void parseInitialZoom(GList *tokens, GString *fileName, int line);
220 void parseFontRastControl(char *cmdName, FontRastControl *val,
221 GList *tokens, GString *fileName, int line);
222 void parseCommand(char *cmdName, GString **val,
223 GList *tokens, GString *fileName, int line);
224 void parseYesNo(char *cmdName, GBool *flag,
225 GList *tokens, GString *fileName, int line);
226 UnicodeMap *getUnicodeMap2(GString *encodingName);
227 GBool setFontRastControl(FontRastControl *val, char *s);
229 //----- static tables
231 NameToCharCode * // mapping from char name to
232 macRomanReverseMap; // MacRomanEncoding index
234 //----- user-modifiable settings
236 NameToCharCode * // mapping from char name to Unicode
238 GHash *cidToUnicodes; // files for mappings from char collections
239 // to Unicode, indexed by collection name
241 GHash *residentUnicodeMaps; // mappings from Unicode to char codes,
242 // indexed by encoding name [UnicodeMap]
243 GHash *unicodeMaps; // files for mappings from Unicode to char
244 // codes, indexed by encoding name [GString]
245 GHash *cMapDirs; // list of CMap dirs, indexed by collection
246 // name [GList[GString]]
247 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
248 GHash *displayFonts; // display font info, indexed by font name
249 // [DisplayFontParam]
250 GHash *displayCIDFonts; // display CID font info, indexed by
251 // collection [DisplayFontParam]
252 GHash *displayNamedCIDFonts; // display CID font info, indexed by
253 // font name [DisplayFontParam]
254 GString *psFile; // PostScript file or command (for xpdf)
255 int psPaperWidth; // paper size, in PostScript points, for
256 int psPaperHeight; // PostScript output
257 GBool psDuplex; // enable duplexing in PostScript?
258 PSLevel psLevel; // PostScript level to generate
259 GHash *psFonts; // PostScript font info, indexed by PDF
260 // font name [PSFontParam]
261 GList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
262 GList *psFonts16; // generic 16-bit fonts [PSFontParam]
263 GBool psEmbedType1; // embed Type 1 fonts?
264 GBool psEmbedTrueType; // embed TrueType fonts?
265 GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
266 GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
267 GBool psOPI; // generate PostScript OPI comments?
268 GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
269 GString *textEncoding; // encoding (unicodeMap) to use for text
271 EndOfLineKind textEOL; // type of EOL marker to use for text
273 GBool textKeepTinyChars; // keep all characters in text output
274 GList *fontDirs; // list of font dirs [GString]
275 GString *initialZoom; // initial zoom level
276 FontRastControl t1libControl; // t1lib rasterization mode
277 FontRastControl // FreeType rasterization mode
279 GString *urlCommand; // command executed for URL links
280 GString *movieCommand; // command executed for movie annotations
281 GBool mapNumericCharNames; // map numeric char names (from font subsets)?
282 GBool printCommands; // print the drawing commands
283 GBool errQuiet; // suppress error messages?
285 CIDToUnicodeCache *cidToUnicodeCache;
286 UnicodeMapCache *unicodeMapCache;
287 CMapCache *cMapCache;