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);
218 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 //----- static tables
251 NameToCharCode * // mapping from char name to
252 macRomanReverseMap; // MacRomanEncoding index
254 //----- user-modifiable settings
256 GString *baseDir; // base directory - for plugins, etc.
257 NameToCharCode * // mapping from char name to Unicode
259 GHash *cidToUnicodes; // files for mappings from char collections
260 // to Unicode, indexed by collection name
262 GHash *unicodeToUnicodes; // files for Unicode-to-Unicode mappings,
263 // indexed by font name pattern [GString]
264 GHash *residentUnicodeMaps; // mappings from Unicode to char codes,
265 // indexed by encoding name [UnicodeMap]
266 GHash *unicodeMaps; // files for mappings from Unicode to char
267 // codes, indexed by encoding name [GString]
268 GHash *cMapDirs; // list of CMap dirs, indexed by collection
269 // name [GList[GString]]
270 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
271 GHash *displayFonts; // display font info, indexed by font name
272 // [DisplayFontParam]
273 GHash *displayCIDFonts; // display CID font info, indexed by
274 // collection [DisplayFontParam]
275 GHash *displayNamedCIDFonts; // display CID font info, indexed by
276 // font name [DisplayFontParam]
277 GString *psFile; // PostScript file or command (for xpdf)
278 int psPaperWidth; // paper size, in PostScript points, for
279 int psPaperHeight; // PostScript output
280 int psImageableLLX, // imageable area, in PostScript points,
281 psImageableLLY, // for PostScript output
284 GBool psCrop; // crop PS output to CropBox
285 GBool psExpandSmaller; // expand smaller pages to fill paper
286 GBool psShrinkLarger; // shrink larger pages to fit paper
287 GBool psCenter; // center pages on the paper
288 GBool psDuplex; // enable duplexing in PostScript?
289 PSLevel psLevel; // PostScript level to generate
290 GHash *psFonts; // PostScript font info, indexed by PDF
291 // font name [PSFontParam]
292 GList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
293 GList *psFonts16; // generic 16-bit fonts [PSFontParam]
294 GBool psEmbedType1; // embed Type 1 fonts?
295 GBool psEmbedTrueType; // embed TrueType fonts?
296 GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
297 GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
298 GBool psOPI; // generate PostScript OPI comments?
299 GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
300 GString *textEncoding; // encoding (unicodeMap) to use for text
302 EndOfLineKind textEOL; // type of EOL marker to use for text
304 GBool textPageBreaks; // insert end-of-page markers?
305 GBool textKeepTinyChars; // keep all characters in text output
306 GList *fontDirs; // list of font dirs [GString]
307 GString *initialZoom; // initial zoom level
308 GBool continuousView; // continuous view mode
309 GBool enableT1lib; // t1lib enable flag
310 GBool enableFreeType; // FreeType enable flag
311 GBool antialias; // anti-aliasing enable flag
312 GString *urlCommand; // command executed for URL links
313 GString *movieCommand; // command executed for movie annotations
314 GBool mapNumericCharNames; // map numeric char names (from font subsets)?
315 GBool printCommands; // print the drawing commands
316 GBool errQuiet; // suppress error messages?
318 CharCodeToUnicodeCache *cidToUnicodeCache;
319 CharCodeToUnicodeCache *unicodeToUnicodeCache;
320 UnicodeMapCache *unicodeMapCache;
321 CMapCache *cMapCache;
323 #ifdef ENABLE_PLUGINS
324 GList *plugins; // list of plugins [Plugin]
325 GList *securityHandlers; // list of loaded security handlers
326 // [XpdfSecurityHandler]
331 GMutex unicodeMapCacheMutex;
332 GMutex cMapCacheMutex;