]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/GlobalParams.h
b09925677510e8cf5ead42d1354b92ccb93a750d
[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 <fontconfig/fontconfig.h>
20 #include "gtypes.h"
21 #include "CharTypes.h"
22
23 #if MULTITHREADED
24 #include "GMutex.h"
25 #endif
26
27 class GString;
28 class GList;
29 class GHash;
30 class NameToCharCode;
31 class CharCodeToUnicode;
32 class CharCodeToUnicodeCache;
33 class UnicodeMap;
34 class UnicodeMapCache;
35 class CMap;
36 class CMapCache;
37 class GlobalParams;
38
39 //------------------------------------------------------------------------
40
41 // The global parameters object.
42 extern GlobalParams *globalParams;
43
44 //------------------------------------------------------------------------
45
46 enum DisplayFontParamKind {
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 *fileName;
61     } t1;
62     struct {
63       GString *fileName;
64     } tt;
65   };
66
67   DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
68   ~DisplayFontParam();
69 };
70
71 //------------------------------------------------------------------------
72
73 class PSFontParam {
74 public:
75
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
80                                 //   16-bit fonts
81   GString *psFontName;          // PostScript font name
82   GString *encoding;            // encoding, for 16-bit fonts only
83
84   PSFontParam(GString *pdfFontNameA, int wModeA,
85               GString *psFontNameA, GString *encodingA);
86   ~PSFontParam();
87 };
88
89 //------------------------------------------------------------------------
90
91 enum PSLevel {
92   psLevel1,
93   psLevel1Sep,
94   psLevel2,
95   psLevel2Sep,
96   psLevel3,
97   psLevel3Sep
98 };
99
100 //------------------------------------------------------------------------
101
102 enum EndOfLineKind {
103   eolUnix,                      // LF
104   eolDOS,                       // CR+LF
105   eolMac                        // CR
106 };
107
108 //------------------------------------------------------------------------
109
110 class GlobalParams {
111 public:
112
113   // Initialize the global parameters by attempting to read a config
114   // file.
115   GlobalParams(char *cfgFileName);
116
117   ~GlobalParams();
118
119   void setupBaseFonts(char *dir);
120   void setupBaseFontsFc(FcConfig *fcConfig);
121
122   //----- accessors
123
124   CharCode getMacRomanCharCode(char *charName);
125
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);
137   GBool getPSDuplex();
138   GBool getPSCrop();
139   GBool getPSExpandSmaller();
140   GBool getPSShrinkLarger();
141   GBool getPSCenter();
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();
149   GBool getPSOPI();
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();
164   GBool getErrQuiet();
165
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();
171
172   //----- functions to set parameters
173
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);
203
204 private:
205
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);
233
234   //----- static tables
235
236   NameToCharCode *              // mapping from char name to
237     macRomanReverseMap;         //   MacRomanEncoding index
238
239   //----- user-modifiable settings
240
241   NameToCharCode *              // mapping from char name to Unicode
242     nameToUnicode;
243   GHash *cidToUnicodes;         // files for mappings from char collections
244                                 //   to Unicode, indexed by collection name
245                                 //   [GString]
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
266       psImageableURX,
267       psImageableURY;
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
285                                 //   output
286   EndOfLineKind textEOL;        // type of EOL marker to use for text
287                                 //   output
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?
300
301   CharCodeToUnicodeCache *cidToUnicodeCache;
302   CharCodeToUnicodeCache *unicodeToUnicodeCache;
303   UnicodeMapCache *unicodeMapCache;
304   CMapCache *cMapCache;
305
306 #if MULTITHREADED
307   GMutex mutex;
308   GMutex unicodeMapCacheMutex;
309   GMutex cMapCacheMutex;
310 #endif
311 };
312
313 #endif