1 //========================================================================
5 // Copyright 2001-2003 Glyph & Cog, LLC
7 //========================================================================
10 #define GLOBALPARAMS_H
14 #ifdef USE_GCC_PRAGMAS
19 #include <fontconfig/fontconfig.h>
21 #include "CharTypes.h"
31 class CharCodeToUnicode;
32 class CharCodeToUnicodeCache;
34 class UnicodeMapCache;
39 //------------------------------------------------------------------------
41 // The global parameters object.
42 extern GlobalParams *globalParams;
44 //------------------------------------------------------------------------
46 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;
67 DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
71 //------------------------------------------------------------------------
76 GString *pdfFontName; // PDF font name for 8-bit fonts and
77 // named 16-bit fonts; char collection
78 // name for generic 16-bit fonts
79 int wMode; // writing mode (0=horiz, 1=vert) for
81 GString *psFontName; // PostScript font name
82 GString *encoding; // encoding, for 16-bit fonts only
84 PSFontParam(GString *pdfFontNameA, int wModeA,
85 GString *psFontNameA, GString *encodingA);
89 //------------------------------------------------------------------------
100 //------------------------------------------------------------------------
108 //------------------------------------------------------------------------
113 // Initialize the global parameters by attempting to read a config
115 GlobalParams(char *cfgFileName);
119 void setupBaseFonts(char *dir);
120 void setupBaseFontsFc(FcConfig *fcConfig);
124 CharCode getMacRomanCharCode(char *charName);
126 Unicode mapNameToUnicode(char *charName);
127 UnicodeMap *getResidentUnicodeMap(GString *encodingName);
128 FILE *getUnicodeMapFile(GString *encodingName);
129 FILE *findCMapFile(GString *collection, GString *cMapName);
130 FILE *findToUnicodeFile(GString *name);
131 DisplayFontParam *getDisplayFont(GString *fontName);
132 DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
133 GString *getPSFile();
134 int getPSPaperWidth();
135 int getPSPaperHeight();
136 void getPSImageableArea(int *llx, int *lly, int *urx, int *ury);
139 GBool getPSExpandSmaller();
140 GBool getPSShrinkLarger();
142 PSLevel getPSLevel();
143 PSFontParam *getPSFont(GString *fontName);
144 PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
145 GBool getPSEmbedType1();
146 GBool getPSEmbedTrueType();
147 GBool getPSEmbedCIDPostScript();
148 GBool getPSEmbedCIDTrueType();
150 GBool getPSASCIIHex();
151 GString *getTextEncodingName();
152 EndOfLineKind getTextEOL();
153 GBool getTextPageBreaks();
154 GBool getTextKeepTinyChars();
155 GString *findFontFile(GString *fontName, char **exts);
156 GString *getInitialZoom();
157 GBool getEnableT1lib();
158 GBool getEnableFreeType();
159 GBool getAntialias();
160 GString *getURLCommand() { return urlCommand; }
161 GString *getMovieCommand() { return movieCommand; }
162 GBool getMapNumericCharNames();
163 GBool getPrintCommands();
166 CharCodeToUnicode *getCIDToUnicode(GString *collection);
167 CharCodeToUnicode *getUnicodeToUnicode(GString *fontName);
168 UnicodeMap *getUnicodeMap(GString *encodingName);
169 CMap *getCMap(GString *collection, GString *cMapName);
170 UnicodeMap *getTextEncoding();
172 //----- functions to set parameters
174 void addDisplayFont(DisplayFontParam *param);
175 void setPSFile(char *file);
176 GBool setPSPaperSize(char *size);
177 void setPSPaperWidth(int width);
178 void setPSPaperHeight(int height);
179 void setPSImageableArea(int llx, int lly, int urx, int ury);
180 void setPSDuplex(GBool duplex);
181 void setPSCrop(GBool crop);
182 void setPSExpandSmaller(GBool expand);
183 void setPSShrinkLarger(GBool shrink);
184 void setPSCenter(GBool center);
185 void setPSLevel(PSLevel level);
186 void setPSEmbedType1(GBool embed);
187 void setPSEmbedTrueType(GBool embed);
188 void setPSEmbedCIDPostScript(GBool embed);
189 void setPSEmbedCIDTrueType(GBool embed);
190 void setPSOPI(GBool opi);
191 void setPSASCIIHex(GBool hex);
192 void setTextEncoding(char *encodingName);
193 GBool setTextEOL(char *s);
194 void setTextPageBreaks(GBool pageBreaks);
195 void setTextKeepTinyChars(GBool keep);
196 void setInitialZoom(char *s);
197 GBool setEnableT1lib(char *s);
198 GBool setEnableFreeType(char *s);
199 GBool setAntialias(char *s);
200 void setMapNumericCharNames(GBool map);
201 void setPrintCommands(GBool printCommandsA);
202 void setErrQuiet(GBool errQuietA);
206 void parseFile(GString *fileName, FILE *f);
207 void parseNameToUnicode(GList *tokens, GString *fileName, int line);
208 void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
209 void parseUnicodeToUnicode(GList *tokens, GString *fileName, int line);
210 void parseUnicodeMap(GList *tokens, GString *fileName, int line);
211 void parseCMapDir(GList *tokens, GString *fileName, int line);
212 void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
213 void parseDisplayFont(GList *tokens, GHash *fontHash,
214 DisplayFontParamKind kind,
215 GString *fileName, int line);
216 void parsePSFile(GList *tokens, GString *fileName, int line);
217 void parsePSPaperSize(GList *tokens, GString *fileName, int line);
218 void parsePSImageableArea(GList *tokens, GString *fileName, int line);
219 void parsePSLevel(GList *tokens, GString *fileName, int line);
220 void parsePSFont(GList *tokens, GString *fileName, int line);
221 void parsePSFont16(char *cmdName, GList *fontList,
222 GList *tokens, GString *fileName, int line);
223 void parseTextEncoding(GList *tokens, GString *fileName, int line);
224 void parseTextEOL(GList *tokens, GString *fileName, int line);
225 void parseFontDir(GList *tokens, GString *fileName, int line);
226 void parseInitialZoom(GList *tokens, GString *fileName, int line);
227 void parseCommand(char *cmdName, GString **val,
228 GList *tokens, GString *fileName, int line);
229 void parseYesNo(char *cmdName, GBool *flag,
230 GList *tokens, GString *fileName, int line);
231 GBool parseYesNo2(char *token, GBool *flag);
232 UnicodeMap *getUnicodeMap2(GString *encodingName);
234 //----- static tables
236 NameToCharCode * // mapping from char name to
237 macRomanReverseMap; // MacRomanEncoding index
239 //----- user-modifiable settings
241 NameToCharCode * // mapping from char name to Unicode
243 GHash *cidToUnicodes; // files for mappings from char collections
244 // to Unicode, indexed by collection name
246 GHash *unicodeToUnicodes; // files for Unicode-to-Unicode mappings,
247 // indexed by font name pattern [GString]
248 GHash *residentUnicodeMaps; // mappings from Unicode to char codes,
249 // indexed by encoding name [UnicodeMap]
250 GHash *unicodeMaps; // files for mappings from Unicode to char
251 // codes, indexed by encoding name [GString]
252 GHash *cMapDirs; // list of CMap dirs, indexed by collection
253 // name [GList[GString]]
254 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
255 GHash *displayFonts; // display font info, indexed by font name
256 // [DisplayFontParam]
257 GHash *displayCIDFonts; // display CID font info, indexed by
258 // collection [DisplayFontParam]
259 GHash *displayNamedCIDFonts; // display CID font info, indexed by
260 // font name [DisplayFontParam]
261 GString *psFile; // PostScript file or command (for xpdf)
262 int psPaperWidth; // paper size, in PostScript points, for
263 int psPaperHeight; // PostScript output
264 int psImageableLLX, // imageable area, in PostScript points,
265 psImageableLLY, // for PostScript output
268 GBool psCrop; // crop PS output to CropBox
269 GBool psExpandSmaller; // expand smaller pages to fill paper
270 GBool psShrinkLarger; // shrink larger pages to fit paper
271 GBool psCenter; // center pages on the paper
272 GBool psDuplex; // enable duplexing in PostScript?
273 PSLevel psLevel; // PostScript level to generate
274 GHash *psFonts; // PostScript font info, indexed by PDF
275 // font name [PSFontParam]
276 GList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
277 GList *psFonts16; // generic 16-bit fonts [PSFontParam]
278 GBool psEmbedType1; // embed Type 1 fonts?
279 GBool psEmbedTrueType; // embed TrueType fonts?
280 GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
281 GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
282 GBool psOPI; // generate PostScript OPI comments?
283 GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
284 GString *textEncoding; // encoding (unicodeMap) to use for text
286 EndOfLineKind textEOL; // type of EOL marker to use for text
288 GBool textPageBreaks; // insert end-of-page markers?
289 GBool textKeepTinyChars; // keep all characters in text output
290 GList *fontDirs; // list of font dirs [GString]
291 GString *initialZoom; // initial zoom level
292 GBool enableT1lib; // t1lib enable flag
293 GBool enableFreeType; // FreeType enable flag
294 GBool antialias; // anti-aliasing enable flag
295 GString *urlCommand; // command executed for URL links
296 GString *movieCommand; // command executed for movie annotations
297 GBool mapNumericCharNames; // map numeric char names (from font subsets)?
298 GBool printCommands; // print the drawing commands
299 GBool errQuiet; // suppress error messages?
301 CharCodeToUnicodeCache *cidToUnicodeCache;
302 CharCodeToUnicodeCache *unicodeToUnicodeCache;
303 UnicodeMapCache *unicodeMapCache;
304 CMapCache *cMapCache;
308 GMutex unicodeMapCacheMutex;
309 GMutex cMapCacheMutex;