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