]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/GlobalParams.h
Import of Xpdf 2.00 for merge
[evince.git] / pdf / xpdf / GlobalParams.h
1 //========================================================================
2 //
3 // GlobalParams.h
4 //
5 // Copyright 2001-2002 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #ifndef GLOBALPARAMS_H
10 #define GLOBALPARAMS_H
11
12 #include <aconf.h>
13
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17
18 #include <stdio.h>
19 #include "gtypes.h"
20 #include "CharTypes.h"
21
22 class GString;
23 class GList;
24 class GHash;
25 class NameToCharCode;
26 class CharCodeToUnicode;
27 class CIDToUnicodeCache;
28 class UnicodeMap;
29 class UnicodeMapCache;
30 class CMap;
31 class CMapCache;
32 class GlobalParams;
33
34 //------------------------------------------------------------------------
35
36 // The global parameters object.
37 extern GlobalParams *globalParams;
38
39 //------------------------------------------------------------------------
40
41 enum DisplayFontParamKind {
42   displayFontX,
43   displayFontT1,
44   displayFontTT
45 };
46
47 class DisplayFontParam {
48 public:
49
50   GString *name;                // font name for 8-bit fonts and named
51                                 //   CID fonts; collection name for
52                                 //   generic CID fonts
53   DisplayFontParamKind kind;
54   union {
55     struct {
56       GString *xlfd;
57       GString *encoding;
58     } x;
59     struct {
60       GString *fileName;
61     } t1;
62     struct {
63       GString *fileName;
64     } tt;
65   };
66
67   DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
68   DisplayFontParam(char *nameA, char *xlfdA, char *encodingA);
69   ~DisplayFontParam();
70 };
71
72 // Font rasterizer control.
73 enum FontRastControl {
74   fontRastNone,                 // don't use this rasterizer
75   fontRastPlain,                // use it, without anti-aliasing
76   fontRastAALow,                // use it, with low-level anti-aliasing
77   fontRastAAHigh                // use it, with high-level anti-aliasing
78 };
79
80 //------------------------------------------------------------------------
81
82 class PSFontParam {
83 public:
84
85   GString *pdfFontName;         // PDF font name for 8-bit fonts and
86                                 //   named 16-bit fonts; char collection
87                                 //   name for generic 16-bit fonts
88   int wMode;                    // writing mode (0=horiz, 1=vert) for
89                                 //   16-bit fonts
90   GString *psFontName;          // PostScript font name
91   GString *encoding;            // encoding, for 16-bit fonts only
92
93   PSFontParam(GString *pdfFontNameA, int wModeA,
94               GString *psFontNameA, GString *encodingA);
95   ~PSFontParam();
96 };
97
98 //------------------------------------------------------------------------
99
100 enum PSLevel {
101   psLevel1,
102   psLevel1Sep,
103   psLevel2,
104   psLevel2Sep,
105   psLevel3,
106   psLevel3Sep
107 };
108
109 //------------------------------------------------------------------------
110
111 enum EndOfLineKind {
112   eolUnix,                      // LF
113   eolDOS,                       // CR+LF
114   eolMac                        // CR
115 };
116
117 //------------------------------------------------------------------------
118
119 class GlobalParams {
120 public:
121
122   // Initialize the global parameters by attempting to read a config
123   // file.
124   GlobalParams(char *cfgFileName);
125
126   ~GlobalParams();
127
128   //----- accessors
129
130   CharCode getMacRomanCharCode(char *charName);
131
132   Unicode mapNameToUnicode(char *charName);
133   FILE *getCIDToUnicodeFile(GString *collection);
134   UnicodeMap *getResidentUnicodeMap(GString *encodingName);
135   FILE *getUnicodeMapFile(GString *encodingName);
136   FILE *findCMapFile(GString *collection, GString *cMapName);
137   FILE *findToUnicodeFile(GString *name);
138   DisplayFontParam *getDisplayFont(GString *fontName);
139   DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
140   GString *getPSFile() { return psFile; }
141   int getPSPaperWidth() { return psPaperWidth; }
142   int getPSPaperHeight() { return psPaperHeight; }
143   GBool getPSDuplex() { return psDuplex; }
144   PSLevel getPSLevel() { return psLevel; }
145   PSFontParam *getPSFont(GString *fontName);
146   PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
147   GBool getPSEmbedType1() { return psEmbedType1; }
148   GBool getPSEmbedTrueType() { return psEmbedTrueType; }
149   GBool getPSEmbedCIDPostScript() { return psEmbedCIDPostScript; }
150   GBool getPSEmbedCIDTrueType() { return psEmbedCIDTrueType; }
151   GBool getPSOPI() { return psOPI; }
152   GBool getPSASCIIHex() { return psASCIIHex; }
153   GString *getTextEncodingName() { return textEncoding; }
154   EndOfLineKind getTextEOL() { return textEOL; }
155   GBool getTextKeepTinyChars() { return textKeepTinyChars; }
156   GString *findFontFile(GString *fontName, char *ext1, char *ext2);
157   GString *getInitialZoom() { return initialZoom; }
158   FontRastControl getT1libControl() { return t1libControl; }
159   FontRastControl getFreeTypeControl() { return freetypeControl; }
160   GString *getURLCommand() { return urlCommand; }
161   GString *getMovieCommand() { return movieCommand; }
162   GBool getMapNumericCharNames() { return mapNumericCharNames; }
163   GBool getPrintCommands() { return printCommands; }
164   GBool getErrQuiet() { return errQuiet; }
165
166   CharCodeToUnicode *getCIDToUnicode(GString *collection);
167   UnicodeMap *getUnicodeMap(GString *encodingName);
168   CMap *getCMap(GString *collection, GString *cMapName);
169   UnicodeMap *getTextEncoding();
170
171   //----- functions to set parameters
172
173   void addDisplayFont(DisplayFontParam *param);
174   void setPSFile(char *file);
175   GBool setPSPaperSize(char *size);
176   void setPSPaperWidth(int width);
177   void setPSPaperHeight(int height);
178   void setPSDuplex(GBool duplex);
179   void setPSLevel(PSLevel level);
180   void setPSEmbedType1(GBool embed);
181   void setPSEmbedTrueType(GBool embed);
182   void setPSEmbedCIDPostScript(GBool embed);
183   void setPSEmbedCIDTrueType(GBool embed);
184   void setPSOPI(GBool opi);
185   void setPSASCIIHex(GBool hex);
186   void setTextEncoding(char *encodingName);
187   GBool setTextEOL(char *s);
188   void setTextKeepTinyChars(GBool keep);
189   void setInitialZoom(char *s);
190   GBool setT1libControl(char *s);
191   GBool setFreeTypeControl(char *s);
192   void setMapNumericCharNames(GBool map);
193   void setPrintCommands(GBool printCommandsA);
194   void setErrQuiet(GBool errQuietA);
195
196 private:
197
198   void parseFile(GString *fileName, FILE *f);
199   void parseNameToUnicode(GList *tokens, GString *fileName, int line);
200   void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
201   void parseUnicodeMap(GList *tokens, GString *fileName, int line);
202   void parseCMapDir(GList *tokens, GString *fileName, int line);
203   void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
204   void parseDisplayFont(GList *tokens, GHash *fontHash,
205                         DisplayFontParamKind kind,
206                         GString *fileName, int line);
207   void parsePSFile(GList *tokens, GString *fileName, int line);
208   void parsePSPaperSize(GList *tokens, GString *fileName, int line);
209   void parsePSLevel(GList *tokens, GString *fileName, int line);
210   void parsePSFont(GList *tokens, GString *fileName, int line);
211   void parsePSFont16(char *cmdName, GList *fontList,
212                      GList *tokens, GString *fileName, int line);
213   void parseTextEncoding(GList *tokens, GString *fileName, int line);
214   void parseTextEOL(GList *tokens, GString *fileName, int line);
215   void parseFontDir(GList *tokens, GString *fileName, int line);
216   void parseInitialZoom(GList *tokens, GString *fileName, int line);
217   void parseFontRastControl(char *cmdName, FontRastControl *val,
218                             GList *tokens, GString *fileName, int line);
219   void parseCommand(char *cmdName, GString **val,
220                     GList *tokens, GString *fileName, int line);
221   void parseYesNo(char *cmdName, GBool *flag,
222                   GList *tokens, GString *fileName, int line);
223   GBool setFontRastControl(FontRastControl *val, char *s);
224
225   //----- static tables
226
227   NameToCharCode *              // mapping from char name to
228     macRomanReverseMap;         //   MacRomanEncoding index
229
230   //----- user-modifiable settings
231
232   NameToCharCode *              // mapping from char name to Unicode
233     nameToUnicode;
234   GHash *cidToUnicodes;         // files for mappings from char collections
235                                 //   to Unicode, indexed by collection name
236                                 //   [GString]
237   GHash *residentUnicodeMaps;   // mappings from Unicode to char codes,
238                                 //   indexed by encoding name [UnicodeMap]
239   GHash *unicodeMaps;           // files for mappings from Unicode to char
240                                 //   codes, indexed by encoding name [GString]
241   GHash *cMapDirs;              // list of CMap dirs, indexed by collection
242                                 //   name [GList[GString]]
243   GList *toUnicodeDirs;         // list of ToUnicode CMap dirs [GString]
244   GHash *displayFonts;          // display font info, indexed by font name
245                                 //   [DisplayFontParam]
246   GHash *displayCIDFonts;       // display CID font info, indexed by
247                                 //   collection [DisplayFontParam]
248   GHash *displayNamedCIDFonts;  // display CID font info, indexed by
249                                 //   font name [DisplayFontParam]
250   GString *psFile;              // PostScript file or command (for xpdf)
251   int psPaperWidth;             // paper size, in PostScript points, for
252   int psPaperHeight;            //   PostScript output
253   GBool psDuplex;               // enable duplexing in PostScript?
254   PSLevel psLevel;              // PostScript level to generate
255   GHash *psFonts;               // PostScript font info, indexed by PDF
256                                 //   font name [PSFontParam]
257   GList *psNamedFonts16;        // named 16-bit fonts [PSFontParam]
258   GList *psFonts16;             // generic 16-bit fonts [PSFontParam]
259   GBool psEmbedType1;           // embed Type 1 fonts?
260   GBool psEmbedTrueType;        // embed TrueType fonts?
261   GBool psEmbedCIDPostScript;   // embed CID PostScript fonts?
262   GBool psEmbedCIDTrueType;     // embed CID TrueType fonts?
263   GBool psOPI;                  // generate PostScript OPI comments?
264   GBool psASCIIHex;             // use ASCIIHex instead of ASCII85?
265   GString *textEncoding;        // encoding (unicodeMap) to use for text
266                                 //   output
267   EndOfLineKind textEOL;        // type of EOL marker to use for text
268                                 //   output
269   GBool textKeepTinyChars;      // keep all characters in text output
270   GList *fontDirs;              // list of font dirs [GString]
271   GString *initialZoom;         // initial zoom level
272   FontRastControl t1libControl; // t1lib rasterization mode
273   FontRastControl               // FreeType rasterization mode
274     freetypeControl;
275   GString *urlCommand;          // command executed for URL links
276   GString *movieCommand;        // command executed for movie annotations
277   GBool mapNumericCharNames;    // map numeric char names (from font subsets)?
278   GBool printCommands;          // print the drawing commands
279   GBool errQuiet;               // suppress error messages?
280
281   CIDToUnicodeCache *cidToUnicodeCache;
282   UnicodeMapCache *unicodeMapCache;
283   CMapCache *cMapCache;
284 };
285
286 #endif