1 //========================================================================
5 // Copyright 2001-2002 Glyph & Cog, LLC
7 //========================================================================
10 #define GLOBALPARAMS_H
18 #include "CharTypes.h"
24 class CharCodeToUnicode;
25 class CIDToUnicodeCache;
27 class UnicodeMapCache;
32 //------------------------------------------------------------------------
34 // The global parameters object.
35 extern GlobalParams *globalParams;
37 //------------------------------------------------------------------------
39 enum DisplayFontParamKind {
45 class DisplayFontParam {
48 GString *name; // font name for 8-bit fonts and named
49 // CID fonts; collection name for
51 DisplayFontParamKind kind;
65 DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
66 DisplayFontParam(char *nameA, char *xlfdA, char *encodingA);
70 // Font rasterizer control.
71 enum FontRastControl {
72 fontRastNone, // don't use this rasterizer
73 fontRastPlain, // use it, without anti-aliasing
74 fontRastAALow, // use it, with low-level anti-aliasing
75 fontRastAAHigh // use it, with high-level anti-aliasing
78 //------------------------------------------------------------------------
83 GString *pdfFontName; // PDF font name for 8-bit fonts and
84 // named 16-bit fonts; char collection
85 // name for generic 16-bit fonts
86 int wMode; // writing mode (0=horiz, 1=vert) for
88 GString *psFontName; // PostScript font name
89 GString *encoding; // encoding, for 16-bit fonts only
91 PSFontParam(GString *pdfFontNameA, int wModeA,
92 GString *psFontNameA, GString *encodingA);
96 //------------------------------------------------------------------------
107 //------------------------------------------------------------------------
115 //------------------------------------------------------------------------
120 // Initialize the global parameters by attempting to read a config
122 GlobalParams(char *cfgFileName);
128 CharCode getMacRomanCharCode(char *charName);
130 Unicode mapNameToUnicode(char *charName);
131 FILE *getCIDToUnicodeFile(GString *collection);
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() { return psFile; }
139 int getPSPaperWidth() { return psPaperWidth; }
140 int getPSPaperHeight() { return psPaperHeight; }
141 GBool getPSDuplex() { return psDuplex; }
142 PSLevel getPSLevel() { return psLevel; }
143 PSFontParam *getPSFont(GString *fontName);
144 PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
145 GBool getPSEmbedType1() { return psEmbedType1; }
146 GBool getPSEmbedTrueType() { return psEmbedTrueType; }
147 GBool getPSEmbedCIDPostScript() { return psEmbedCIDPostScript; }
148 GBool getPSEmbedCIDTrueType() { return psEmbedCIDTrueType; }
149 GBool getPSOPI() { return psOPI; }
150 GBool getPSASCIIHex() { return psASCIIHex; }
151 GString *getTextEncodingName() { return textEncoding; }
152 EndOfLineKind getTextEOL() { return textEOL; }
153 GString *findFontFile(GString *fontName, char *ext1, char *ext2);
154 GString *getInitialZoom() { return initialZoom; }
155 FontRastControl getT1libControl() { return t1libControl; }
156 FontRastControl getFreeTypeControl() { return freetypeControl; }
157 GString *getURLCommand() { return urlCommand; }
158 GBool getMapNumericCharNames() { return mapNumericCharNames; }
159 GBool getErrQuiet() { return errQuiet; }
161 CharCodeToUnicode *getCIDToUnicode(GString *collection);
162 UnicodeMap *getUnicodeMap(GString *encodingName);
163 CMap *getCMap(GString *collection, GString *cMapName);
164 UnicodeMap *getTextEncoding();
166 //----- functions to set parameters
168 void setPSFile(char *file);
169 GBool setPSPaperSize(char *size);
170 void setPSPaperWidth(int width);
171 void setPSPaperHeight(int height);
172 void setPSDuplex(GBool duplex);
173 void setPSLevel(PSLevel level);
174 void setPSEmbedType1(GBool embed);
175 void setPSEmbedTrueType(GBool embed);
176 void setPSEmbedCIDPostScript(GBool embed);
177 void setPSEmbedCIDTrueType(GBool embed);
178 void setPSOPI(GBool opi);
179 void setPSASCIIHex(GBool hex);
180 void setTextEncoding(char *encodingName);
181 GBool setTextEOL(char *s);
182 void setInitialZoom(char *s);
183 GBool setT1libControl(char *s);
184 GBool setFreeTypeControl(char *s);
185 void setErrQuiet(GBool errQuietA);
189 void parseFile(GString *fileName, FILE *f);
190 void parseNameToUnicode(GList *tokens, GString *fileName, int line);
191 void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
192 void parseUnicodeMap(GList *tokens, GString *fileName, int line);
193 void parseCMapDir(GList *tokens, GString *fileName, int line);
194 void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
195 void parseDisplayFont(GList *tokens, GHash *fontHash,
196 DisplayFontParamKind kind,
197 GString *fileName, int line);
198 void parsePSFile(GList *tokens, GString *fileName, int line);
199 void parsePSPaperSize(GList *tokens, GString *fileName, int line);
200 void parsePSLevel(GList *tokens, GString *fileName, int line);
201 void parsePSFont(GList *tokens, GString *fileName, int line);
202 void parsePSFont16(char *cmdName, GList *fontList,
203 GList *tokens, GString *fileName, int line);
204 void parseTextEncoding(GList *tokens, GString *fileName, int line);
205 void parseTextEOL(GList *tokens, GString *fileName, int line);
206 void parseFontDir(GList *tokens, GString *fileName, int line);
207 void parseInitialZoom(GList *tokens, GString *fileName, int line);
208 void parseFontRastControl(char *cmdName, FontRastControl *val,
209 GList *tokens, GString *fileName, int line);
210 void parseURLCommand(GList *tokens, GString *fileName, int line);
211 void parseYesNo(char *cmdName, GBool *flag,
212 GList *tokens, GString *fileName, int line);
213 GBool setFontRastControl(FontRastControl *val, char *s);
215 //----- static tables
217 NameToCharCode * // mapping from char name to
218 macRomanReverseMap; // MacRomanEncoding index
220 //----- user-modifiable settings
222 NameToCharCode * // mapping from char name to Unicode
224 GHash *cidToUnicodes; // files for mappings from char collections
225 // to Unicode, indexed by collection name
227 GHash *residentUnicodeMaps; // mappings from Unicode to char codes,
228 // indexed by encoding name [UnicodeMap]
229 GHash *unicodeMaps; // files for mappings from Unicode to char
230 // codes, indexed by encoding name [GString]
231 GHash *cMapDirs; // list of CMap dirs, indexed by collection
232 // name [GList[GString]]
233 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
234 GHash *displayFonts; // display font info, indexed by font name
235 // [DisplayFontParam]
236 GHash *displayCIDFonts; // display CID font info, indexed by
237 // collection [DisplayFontParam]
238 GHash *displayNamedCIDFonts; // display CID font info, indexed by
239 // font name [DisplayFontParam]
240 GString *psFile; // PostScript file or command (for xpdf)
241 int psPaperWidth; // paper size, in PostScript points, for
242 int psPaperHeight; // PostScript output
243 GBool psDuplex; // enable duplexing in PostScript?
244 PSLevel psLevel; // PostScript level to generate
245 GHash *psFonts; // PostScript font info, indexed by PDF
246 // font name [PSFontParam]
247 GList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
248 GList *psFonts16; // generic 16-bit fonts [PSFontParam]
249 GBool psEmbedType1; // embed Type 1 fonts?
250 GBool psEmbedTrueType; // embed TrueType fonts?
251 GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
252 GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
253 GBool psOPI; // generate PostScript OPI comments?
254 GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
255 GString *textEncoding; // encoding (unicodeMap) to use for text
257 EndOfLineKind textEOL; // type of EOL marker to use for text
259 GList *fontDirs; // list of font dirs [GString]
260 GString *initialZoom; // initial zoom level
261 FontRastControl t1libControl; // t1lib rasterization mode
262 FontRastControl // FreeType rasterization mode
264 GString *urlCommand; // command executed for URL links
265 GBool mapNumericCharNames; // map numeric char names (from font subsets)?
266 GBool errQuiet; // suppress error messages?
268 CIDToUnicodeCache *cidToUnicodeCache;
269 UnicodeMapCache *unicodeMapCache;
270 CMapCache *cMapCache;