]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/GlobalParams.h
472beed9902fddf13916c047fd821daac9bab4b7
[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 CharCodeToUnicodeCache;
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   UnicodeMap *getResidentUnicodeMap(GString *encodingName);
138   FILE *getUnicodeMapFile(GString *encodingName);
139   FILE *findCMapFile(GString *collection, GString *cMapName);
140   FILE *findToUnicodeFile(GString *name);
141   DisplayFontParam *getDisplayFont(GString *fontName);
142   DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
143   GString *getPSFile();
144   int getPSPaperWidth();
145   int getPSPaperHeight();
146   GBool getPSDuplex();
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();
154   GBool getPSOPI();
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   FontRastControl getT1libControl();
163   FontRastControl getFreeTypeControl();
164   GString *getURLCommand() { return urlCommand; }
165   GString *getMovieCommand() { return movieCommand; }
166   GBool getMapNumericCharNames();
167   GBool getPrintCommands();
168   GBool getErrQuiet();
169
170   CharCodeToUnicode *getCIDToUnicode(GString *collection);
171   CharCodeToUnicode *getUnicodeToUnicode(GString *fontName);
172   UnicodeMap *getUnicodeMap(GString *encodingName);
173   CMap *getCMap(GString *collection, GString *cMapName);
174   UnicodeMap *getTextEncoding();
175
176   //----- functions to set parameters
177
178   void addDisplayFont(DisplayFontParam *param);
179   void setPSFile(char *file);
180   GBool setPSPaperSize(char *size);
181   void setPSPaperWidth(int width);
182   void setPSPaperHeight(int height);
183   void setPSDuplex(GBool duplex);
184   void setPSLevel(PSLevel level);
185   void setPSEmbedType1(GBool embed);
186   void setPSEmbedTrueType(GBool embed);
187   void setPSEmbedCIDPostScript(GBool embed);
188   void setPSEmbedCIDTrueType(GBool embed);
189   void setPSOPI(GBool opi);
190   void setPSASCIIHex(GBool hex);
191   void setTextEncoding(char *encodingName);
192   GBool setTextEOL(char *s);
193   void setTextPageBreaks(GBool pageBreaks);
194   void setTextKeepTinyChars(GBool keep);
195   void setInitialZoom(char *s);
196   GBool setT1libControl(char *s);
197   GBool setFreeTypeControl(char *s);
198   void setMapNumericCharNames(GBool map);
199   void setPrintCommands(GBool printCommandsA);
200   void setErrQuiet(GBool errQuietA);
201
202 private:
203
204   void parseFile(GString *fileName, FILE *f);
205   void parseNameToUnicode(GList *tokens, GString *fileName, int line);
206   void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
207   void parseUnicodeToUnicode(GList *tokens, GString *fileName, int line);
208   void parseUnicodeMap(GList *tokens, GString *fileName, int line);
209   void parseCMapDir(GList *tokens, GString *fileName, int line);
210   void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
211   void parseDisplayFont(GList *tokens, GHash *fontHash,
212                         DisplayFontParamKind kind,
213                         GString *fileName, int line);
214   void parsePSFile(GList *tokens, GString *fileName, int line);
215   void parsePSPaperSize(GList *tokens, GString *fileName, int line);
216   void parsePSLevel(GList *tokens, GString *fileName, int line);
217   void parsePSFont(GList *tokens, GString *fileName, int line);
218   void parsePSFont16(char *cmdName, GList *fontList,
219                      GList *tokens, GString *fileName, int line);
220   void parseTextEncoding(GList *tokens, GString *fileName, int line);
221   void parseTextEOL(GList *tokens, GString *fileName, int line);
222   void parseFontDir(GList *tokens, GString *fileName, int line);
223   void parseInitialZoom(GList *tokens, GString *fileName, int line);
224   void parseFontRastControl(char *cmdName, FontRastControl *val,
225                             GList *tokens, GString *fileName, int line);
226   void parseCommand(char *cmdName, GString **val,
227                     GList *tokens, GString *fileName, int line);
228   void parseYesNo(char *cmdName, GBool *flag,
229                   GList *tokens, GString *fileName, int line);
230   UnicodeMap *getUnicodeMap2(GString *encodingName);
231   GBool setFontRastControl(FontRastControl *val, char *s);
232
233   //----- static tables
234
235   NameToCharCode *              // mapping from char name to
236     macRomanReverseMap;         //   MacRomanEncoding index
237
238   //----- user-modifiable settings
239
240   NameToCharCode *              // mapping from char name to Unicode
241     nameToUnicode;
242   GHash *cidToUnicodes;         // files for mappings from char collections
243                                 //   to Unicode, indexed by collection name
244                                 //   [GString]
245   GHash *unicodeToUnicodes;     // files for Unicode-to-Unicode mappings,
246                                 //   indexed by font name pattern [GString]
247   GHash *residentUnicodeMaps;   // mappings from Unicode to char codes,
248                                 //   indexed by encoding name [UnicodeMap]
249   GHash *unicodeMaps;           // files for mappings from Unicode to char
250                                 //   codes, indexed by encoding name [GString]
251   GHash *cMapDirs;              // list of CMap dirs, indexed by collection
252                                 //   name [GList[GString]]
253   GList *toUnicodeDirs;         // list of ToUnicode CMap dirs [GString]
254   GHash *displayFonts;          // display font info, indexed by font name
255                                 //   [DisplayFontParam]
256   GHash *displayCIDFonts;       // display CID font info, indexed by
257                                 //   collection [DisplayFontParam]
258   GHash *displayNamedCIDFonts;  // display CID font info, indexed by
259                                 //   font name [DisplayFontParam]
260   GString *psFile;              // PostScript file or command (for xpdf)
261   int psPaperWidth;             // paper size, in PostScript points, for
262   int psPaperHeight;            //   PostScript output
263   GBool psDuplex;               // enable duplexing in PostScript?
264   PSLevel psLevel;              // PostScript level to generate
265   GHash *psFonts;               // PostScript font info, indexed by PDF
266                                 //   font name [PSFontParam]
267   GList *psNamedFonts16;        // named 16-bit fonts [PSFontParam]
268   GList *psFonts16;             // generic 16-bit fonts [PSFontParam]
269   GBool psEmbedType1;           // embed Type 1 fonts?
270   GBool psEmbedTrueType;        // embed TrueType fonts?
271   GBool psEmbedCIDPostScript;   // embed CID PostScript fonts?
272   GBool psEmbedCIDTrueType;     // embed CID TrueType fonts?
273   GBool psOPI;                  // generate PostScript OPI comments?
274   GBool psASCIIHex;             // use ASCIIHex instead of ASCII85?
275   GString *textEncoding;        // encoding (unicodeMap) to use for text
276                                 //   output
277   EndOfLineKind textEOL;        // type of EOL marker to use for text
278                                 //   output
279   GBool textPageBreaks;         // insert end-of-page markers?
280   GBool textKeepTinyChars;      // keep all characters in text output
281   GList *fontDirs;              // list of font dirs [GString]
282   GString *initialZoom;         // initial zoom level
283   FontRastControl t1libControl; // t1lib rasterization mode
284   FontRastControl               // FreeType rasterization mode
285     freetypeControl;
286   GString *urlCommand;          // command executed for URL links
287   GString *movieCommand;        // command executed for movie annotations
288   GBool mapNumericCharNames;    // map numeric char names (from font subsets)?
289   GBool printCommands;          // print the drawing commands
290   GBool errQuiet;               // suppress error messages?
291
292   CharCodeToUnicodeCache *cidToUnicodeCache;
293   CharCodeToUnicodeCache *unicodeToUnicodeCache;
294   UnicodeMapCache *unicodeMapCache;
295   CMapCache *cMapCache;
296
297 #if MULTITHREADED
298   GMutex mutex;
299   GMutex unicodeMapCacheMutex;
300   GMutex cMapCacheMutex;
301 #endif
302 };
303
304 #endif