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;
36 struct XpdfSecurityHandler;
39 //------------------------------------------------------------------------
41 // The global parameters object.
42 extern GlobalParams *globalParams;
44 //------------------------------------------------------------------------
46 enum DisplayFontParamKind {
51 struct DisplayFontParamT1 {
55 struct DisplayFontParamTT {
59 class DisplayFontParam {
62 GString *name; // font name for 8-bit fonts and named
63 // CID fonts; collection name for
65 DisplayFontParamKind kind;
67 DisplayFontParamT1 t1;
68 DisplayFontParamTT tt;
71 DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
75 //------------------------------------------------------------------------
80 GString *pdfFontName; // PDF font name for 8-bit fonts and
81 // named 16-bit fonts; char collection
82 // name for generic 16-bit fonts
83 int wMode; // writing mode (0=horiz, 1=vert) for
85 GString *psFontName; // PostScript font name
86 GString *encoding; // encoding, for 16-bit fonts only
88 PSFontParam(GString *pdfFontNameA, int wModeA,
89 GString *psFontNameA, GString *encodingA);
93 //------------------------------------------------------------------------
104 //------------------------------------------------------------------------
112 //------------------------------------------------------------------------
117 // Initialize the global parameters by attempting to read a config
119 GlobalParams(char *cfgFileName);
123 void setBaseDir(char *dir);
124 void setupBaseFonts(char *dir);
128 CharCode getMacRomanCharCode(char *charName);
130 GString *getBaseDir();
131 Unicode mapNameToUnicode(char *charName);
132 UnicodeMap *getResidentUnicodeMap(GString *encodingName);
133 FILE *getUnicodeMapFile(GString *encodingName);
134 FILE *findCMapFile(GString *collection, GString *cMapName);
135 FILE *findToUnicodeFile(GString *name);
136 DisplayFontParam *getDisplayFont(GString *fontName);
137 DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
138 GString *getPSFile();
139 int getPSPaperWidth();
140 int getPSPaperHeight();
141 void getPSImageableArea(int *llx, int *lly, int *urx, int *ury);
144 GBool getPSExpandSmaller();
145 GBool getPSShrinkLarger();
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 GBool getContinuousView();
163 GBool getEnableT1lib();
164 GBool getEnableFreeType();
165 GBool getAntialias();
166 GString *getURLCommand() { return urlCommand; }
167 GString *getMovieCommand() { return movieCommand; }
168 GBool getMapNumericCharNames();
169 GBool getPrintCommands();
172 CharCodeToUnicode *getCIDToUnicode(GString *collection);
173 CharCodeToUnicode *getUnicodeToUnicode(GString *fontName);
174 UnicodeMap *getUnicodeMap(GString *encodingName);
175 CMap *getCMap(GString *collection, GString *cMapName);
176 UnicodeMap *getTextEncoding();
178 //----- functions to set parameters
180 void addDisplayFont(DisplayFontParam *param);
181 void setPSFile(char *file);
182 GBool setPSPaperSize(char *size);
183 void setPSPaperWidth(int width);
184 void setPSPaperHeight(int height);
185 void setPSImageableArea(int llx, int lly, int urx, int ury);
186 void setPSDuplex(GBool duplex);
187 void setPSCrop(GBool crop);
188 void setPSExpandSmaller(GBool expand);
189 void setPSShrinkLarger(GBool shrink);
190 void setPSCenter(GBool center);
191 void setPSLevel(PSLevel level);
192 void setPSEmbedType1(GBool embed);
193 void setPSEmbedTrueType(GBool embed);
194 void setPSEmbedCIDPostScript(GBool embed);
195 void setPSEmbedCIDTrueType(GBool embed);
196 void setPSOPI(GBool opi);
197 void setPSASCIIHex(GBool hex);
198 void setTextEncoding(char *encodingName);
199 GBool setTextEOL(char *s);
200 void setTextPageBreaks(GBool pageBreaks);
201 void setTextKeepTinyChars(GBool keep);
202 void setInitialZoom(char *s);
203 void setContinuousView(GBool cont);
204 GBool setEnableT1lib(char *s);
205 GBool setEnableFreeType(char *s);
206 GBool setAntialias(char *s);
207 void setMapNumericCharNames(GBool map);
208 void setPrintCommands(GBool printCommandsA);
209 void setErrQuiet(GBool errQuietA);
211 //----- security handlers
213 void addSecurityHandler(XpdfSecurityHandler *handler);
214 XpdfSecurityHandler *getSecurityHandler(char *name);
215 void parseFile(GString *fileName, FILE *f);
219 void parseNameToUnicode(GList *tokens, GString *fileName, int line);
220 void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
221 void parseUnicodeToUnicode(GList *tokens, GString *fileName, int line);
222 void parseUnicodeMap(GList *tokens, GString *fileName, int line);
223 void parseCMapDir(GList *tokens, GString *fileName, int line);
224 void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
225 void parseDisplayFont(GList *tokens, GHash *fontHash,
226 DisplayFontParamKind kind,
227 GString *fileName, int line);
228 void parsePSFile(GList *tokens, GString *fileName, int line);
229 void parsePSPaperSize(GList *tokens, GString *fileName, int line);
230 void parsePSImageableArea(GList *tokens, GString *fileName, int line);
231 void parsePSLevel(GList *tokens, GString *fileName, int line);
232 void parsePSFont(GList *tokens, GString *fileName, int line);
233 void parsePSFont16(char *cmdName, GList *fontList,
234 GList *tokens, GString *fileName, int line);
235 void parseTextEncoding(GList *tokens, GString *fileName, int line);
236 void parseTextEOL(GList *tokens, GString *fileName, int line);
237 void parseFontDir(GList *tokens, GString *fileName, int line);
238 void parseInitialZoom(GList *tokens, GString *fileName, int line);
239 void parseCommand(char *cmdName, GString **val,
240 GList *tokens, GString *fileName, int line);
241 void parseYesNo(char *cmdName, GBool *flag,
242 GList *tokens, GString *fileName, int line);
243 GBool parseYesNo2(char *token, GBool *flag);
244 UnicodeMap *getUnicodeMap2(GString *encodingName);
245 #ifdef ENABLE_PLUGINS
246 GBool loadPlugin(char *type, char *name);
249 //----- config file base path
253 //----- static tables
255 NameToCharCode * // mapping from char name to
256 macRomanReverseMap; // MacRomanEncoding index
258 //----- user-modifiable settings
260 GString *baseDir; // base directory - for plugins, etc.
261 NameToCharCode * // mapping from char name to Unicode
263 GHash *cidToUnicodes; // files for mappings from char collections
264 // to Unicode, indexed by collection name
266 GHash *unicodeToUnicodes; // files for Unicode-to-Unicode mappings,
267 // indexed by font name pattern [GString]
268 GHash *residentUnicodeMaps; // mappings from Unicode to char codes,
269 // indexed by encoding name [UnicodeMap]
270 GHash *unicodeMaps; // files for mappings from Unicode to char
271 // codes, indexed by encoding name [GString]
272 GHash *cMapDirs; // list of CMap dirs, indexed by collection
273 // name [GList[GString]]
274 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
275 GHash *displayFonts; // display font info, indexed by font name
276 // [DisplayFontParam]
277 GHash *displayCIDFonts; // display CID font info, indexed by
278 // collection [DisplayFontParam]
279 GHash *displayNamedCIDFonts; // display CID font info, indexed by
280 // font name [DisplayFontParam]
281 GString *psFile; // PostScript file or command (for xpdf)
282 int psPaperWidth; // paper size, in PostScript points, for
283 int psPaperHeight; // PostScript output
284 int psImageableLLX, // imageable area, in PostScript points,
285 psImageableLLY, // for PostScript output
288 GBool psCrop; // crop PS output to CropBox
289 GBool psExpandSmaller; // expand smaller pages to fill paper
290 GBool psShrinkLarger; // shrink larger pages to fit paper
291 GBool psCenter; // center pages on the paper
292 GBool psDuplex; // enable duplexing in PostScript?
293 PSLevel psLevel; // PostScript level to generate
294 GHash *psFonts; // PostScript font info, indexed by PDF
295 // font name [PSFontParam]
296 GList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
297 GList *psFonts16; // generic 16-bit fonts [PSFontParam]
298 GBool psEmbedType1; // embed Type 1 fonts?
299 GBool psEmbedTrueType; // embed TrueType fonts?
300 GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
301 GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
302 GBool psOPI; // generate PostScript OPI comments?
303 GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
304 GString *textEncoding; // encoding (unicodeMap) to use for text
306 EndOfLineKind textEOL; // type of EOL marker to use for text
308 GBool textPageBreaks; // insert end-of-page markers?
309 GBool textKeepTinyChars; // keep all characters in text output
310 GList *fontDirs; // list of font dirs [GString]
311 GString *initialZoom; // initial zoom level
312 GBool continuousView; // continuous view mode
313 GBool enableT1lib; // t1lib enable flag
314 GBool enableFreeType; // FreeType enable flag
315 GBool antialias; // anti-aliasing enable flag
316 GString *urlCommand; // command executed for URL links
317 GString *movieCommand; // command executed for movie annotations
318 GBool mapNumericCharNames; // map numeric char names (from font subsets)?
319 GBool printCommands; // print the drawing commands
320 GBool errQuiet; // suppress error messages?
322 CharCodeToUnicodeCache *cidToUnicodeCache;
323 CharCodeToUnicodeCache *unicodeToUnicodeCache;
324 UnicodeMapCache *unicodeMapCache;
325 CMapCache *cMapCache;
327 #ifdef ENABLE_PLUGINS
328 GList *plugins; // list of plugins [Plugin]
329 GList *securityHandlers; // list of loaded security handlers
330 // [XpdfSecurityHandler]
335 GMutex unicodeMapCacheMutex;
336 GMutex cMapCacheMutex;