source: trunk/poppler/mypoppler/poppler/GlobalParams.h @ 461

Last change on this file since 461 was 461, checked in by Silvan Scherrer, 11 years ago

poppler update to 0.14.2

File size: 11.4 KB
Line 
1//========================================================================
2//
3// GlobalParams.h
4//
5// Copyright 2001-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9//========================================================================
10//
11// Modified under the Poppler project - http://poppler.freedesktop.org
12//
13// All changes made under the Poppler project to this file are licensed
14// under GPL version 2 or later
15//
16// Copyright (C) 2005, 2007-2010 Albert Astals Cid <aacid@kde.org>
17// Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com>
18// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
19// Copyright (C) 2006 Kristian HÞgsberg <krh@redhat.com>
20// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
21// Copyright (C) 2009 Jonathan Kew <jonathan_kew@sil.org>
22// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com>
23// Copyright (C) 2009 William Bader <williambader@hotmail.com>
24// Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
25//
26// To see a description of the changes please see the Changelog file that
27// came with your tarball or type make ChangeLog if you are building from git
28//
29//========================================================================
30
31#ifndef GLOBALPARAMS_H
32#define GLOBALPARAMS_H
33
34#ifdef USE_GCC_PRAGMAS
35#pragma interface
36#endif
37
38#include <assert.h>
39#include "poppler-config.h"
40#include <stdio.h>
41#if WITH_FONTCONFIGURATION_FONTCONFIG
42#include <fontconfig/fontconfig.h>
43#endif
44#include "goo/gtypes.h"
45#include "CharTypes.h"
46
47#if MULTITHREADED
48#include "goo/GooMutex.h"
49#endif
50
51class GooString;
52class GooList;
53class GooHash;
54class NameToCharCode;
55class CharCodeToUnicode;
56class CharCodeToUnicodeCache;
57class UnicodeMap;
58class UnicodeMapCache;
59class CMap;
60class CMapCache;
61struct XpdfSecurityHandler;
62class GlobalParams;
63class GfxFont;
64class Stream;
65#ifdef _WIN32
66class WinFontList;
67#endif
68
69//------------------------------------------------------------------------
70
71// The global parameters object.
72extern GlobalParams *globalParams;
73
74//------------------------------------------------------------------------
75
76enum DisplayFontParamKind {
77  displayFontT1,
78  displayFontTT
79};
80
81struct DisplayFontParamT1 {
82  GooString *fileName;
83};
84
85struct DisplayFontParamTT {
86  GooString *fileName;
87  int faceIndex;
88};
89
90class DisplayFontParam {
91public:
92
93  GooString *name;              // font name for 8-bit fonts and named
94                                //   CID fonts; collection name for
95                                //   generic CID fonts
96  DisplayFontParamKind kind;
97  union {
98    DisplayFontParamT1 t1;
99    DisplayFontParamTT tt;
100  };
101
102  DisplayFontParam(GooString *nameA, DisplayFontParamKind kindA);
103  void setFileName(GooString *fileNameA) {
104    if (displayFontT1 == kind)
105        t1.fileName = fileNameA;
106    else {
107        assert(displayFontTT == kind);
108        tt.fileName = fileNameA;
109    }
110  } 
111  virtual ~DisplayFontParam();
112};
113
114//------------------------------------------------------------------------
115
116class PSFontParam {
117public:
118
119  GooString *pdfFontName;               // PDF font name for 8-bit fonts and
120                                //   named 16-bit fonts; char collection
121                                //   name for generic 16-bit fonts
122  int wMode;                    // writing mode (0=horiz, 1=vert) for
123                                //   16-bit fonts
124  GooString *psFontName;                // PostScript font name
125  GooString *encoding;          // encoding, for 16-bit fonts only
126
127  PSFontParam(GooString *pdfFontNameA, int wModeA,
128              GooString *psFontNameA, GooString *encodingA);
129  ~PSFontParam();
130};
131
132//------------------------------------------------------------------------
133
134enum PSLevel {
135  psLevel1,
136  psLevel1Sep,
137  psLevel2,
138  psLevel2Sep,
139  psLevel3,
140  psLevel3Sep
141};
142
143//------------------------------------------------------------------------
144
145enum EndOfLineKind {
146  eolUnix,                      // LF
147  eolDOS,                       // CR+LF
148  eolMac                        // CR
149};
150
151//------------------------------------------------------------------------
152
153enum ScreenType {
154  screenUnset,
155  screenDispersed,
156  screenClustered,
157  screenStochasticClustered
158};
159
160//------------------------------------------------------------------------
161
162class GlobalParams {
163public:
164
165  // Initialize the global parameters by attempting to read a config
166  // file.
167  GlobalParams(const char *customPopplerDataDir = NULL);
168
169  ~GlobalParams();
170
171  void setBaseDir(char *dir);
172
173#if WITH_FONTCONFIGURATION_WIN32
174  void setupBaseFonts(char *dir);
175#endif
176
177  //----- accessors
178
179  CharCode getMacRomanCharCode(char *charName);
180
181  GooString *getBaseDir();
182  Unicode mapNameToUnicode(char *charName);
183  UnicodeMap *getResidentUnicodeMap(GooString *encodingName);
184  FILE *getUnicodeMapFile(GooString *encodingName);
185  FILE *findCMapFile(GooString *collection, GooString *cMapName);
186  FILE *findToUnicodeFile(GooString *name);
187  DisplayFontParam *getDisplayFont(GfxFont *font);
188  GBool getPSExpandSmaller();
189  GBool getPSShrinkLarger();
190  GBool getPSCenter();
191  PSLevel getPSLevel();
192  PSFontParam *getPSFont(GooString *fontName);
193  PSFontParam *getPSFont16(GooString *fontName, GooString *collection, int wMode);
194  GBool getPSEmbedType1();
195  GBool getPSEmbedTrueType();
196  GBool getPSEmbedCIDPostScript();
197  GBool getPSEmbedCIDTrueType();
198  GBool getPSSubstFonts();
199  GBool getPSPreload();
200  GBool getPSOPI();
201  GBool getPSASCIIHex();
202  GooString *getTextEncodingName();
203  EndOfLineKind getTextEOL();
204  GBool getTextPageBreaks();
205  GBool getTextKeepTinyChars();
206  GooString *findFontFile(GooString *fontName, char **exts);
207  GBool getEnableFreeType();
208  GBool getAntialias();
209  GBool getVectorAntialias();
210  GBool getStrokeAdjust();
211  ScreenType getScreenType();
212  int getScreenSize();
213  int getScreenDotRadius();
214  double getScreenGamma();
215  double getScreenBlackThreshold();
216  double getScreenWhiteThreshold();
217  GBool getMapNumericCharNames();
218  GBool getMapUnknownCharNames();
219  GBool getPrintCommands();
220  GBool getProfileCommands();
221  GBool getErrQuiet();
222
223  CharCodeToUnicode *getCIDToUnicode(GooString *collection);
224  CharCodeToUnicode *getUnicodeToUnicode(GooString *fontName);
225  UnicodeMap *getUnicodeMap(GooString *encodingName);
226  CMap *getCMap(GooString *collection, GooString *cMapName, Stream *stream = NULL);
227  UnicodeMap *getTextEncoding();
228#ifdef ENABLE_PLUGINS
229  GBool loadPlugin(char *type, char *name);
230#endif
231
232  GooList *getEncodingNames();
233
234  //----- functions to set parameters
235  void setPSExpandSmaller(GBool expand);
236  void setPSShrinkLarger(GBool shrink);
237  void setPSCenter(GBool center);
238  void setPSLevel(PSLevel level);
239  void setPSEmbedType1(GBool embed);
240  void setPSEmbedTrueType(GBool embed);
241  void setPSEmbedCIDPostScript(GBool embed);
242  void setPSEmbedCIDTrueType(GBool embed);
243  void setPSSubstFonts(GBool substFonts);
244  void setPSPreload(GBool preload);
245  void setPSOPI(GBool opi);
246  void setPSASCIIHex(GBool hex);
247  void setTextEncoding(char *encodingName);
248  GBool setTextEOL(char *s);
249  void setTextPageBreaks(GBool pageBreaks);
250  void setTextKeepTinyChars(GBool keep);
251  GBool setEnableFreeType(char *s);
252  GBool setAntialias(char *s);
253  GBool setVectorAntialias(char *s);
254  void setStrokeAdjust(GBool strokeAdjust);
255  void setScreenType(ScreenType st);
256  void setScreenSize(int size);
257  void setScreenDotRadius(int radius);
258  void setScreenGamma(double gamma);
259  void setScreenBlackThreshold(double blackThreshold);
260  void setScreenWhiteThreshold(double whiteThreshold);
261  void setMapNumericCharNames(GBool map);
262  void setMapUnknownCharNames(GBool map);
263  void setPrintCommands(GBool printCommandsA);
264  void setProfileCommands(GBool profileCommandsA);
265  void setErrQuiet(GBool errQuietA);
266
267  //----- security handlers
268
269  void addSecurityHandler(XpdfSecurityHandler *handler);
270  XpdfSecurityHandler *getSecurityHandler(char *name);
271
272private:
273
274  void parseNameToUnicode(GooString *name);
275  GBool parseYesNo2(char *token, GBool *flag);
276  UnicodeMap *getUnicodeMap2(GooString *encodingName);
277
278  void scanEncodingDirs();
279  void addCIDToUnicode(GooString *collection, GooString *fileName);
280  void addUnicodeMap(GooString *encodingName, GooString *fileName);
281  void addCMapDir(GooString *collection, GooString *dir);
282
283  //----- static tables
284
285  NameToCharCode *              // mapping from char name to
286    macRomanReverseMap;         //   MacRomanEncoding index
287
288  //----- user-modifiable settings
289
290  GooString *baseDir;           // base directory - for plugins, etc.
291  NameToCharCode *              // mapping from char name to Unicode
292    nameToUnicode;
293  GooHash *cidToUnicodes;               // files for mappings from char collections
294                                //   to Unicode, indexed by collection name
295                                //   [GooString]
296  GooHash *unicodeToUnicodes;   // files for Unicode-to-Unicode mappings,
297                                //   indexed by font name pattern [GooString]
298  GooHash *residentUnicodeMaps; // mappings from Unicode to char codes,
299                                //   indexed by encoding name [UnicodeMap]
300  GooHash *unicodeMaps;         // files for mappings from Unicode to char
301                                //   codes, indexed by encoding name [GooString]
302  GooHash *cMapDirs;            // list of CMap dirs, indexed by collection
303                                //   name [GooList[GooString]]
304  GooList *toUnicodeDirs;               // list of ToUnicode CMap dirs [GooString]
305  GooHash *displayFonts;                // display font info, indexed by font name
306                                //   [DisplayFontParam]
307#ifdef _WIN32
308  GBool baseFontsInitialized;
309  WinFontList *winFontList;     // system TrueType fonts
310#endif
311  GBool psExpandSmaller;        // expand smaller pages to fill paper
312  GBool psShrinkLarger;         // shrink larger pages to fit paper
313  GBool psCenter;               // center pages on the paper
314  PSLevel psLevel;              // PostScript level to generate
315  GooHash *psFonts;             // PostScript font info, indexed by PDF
316                                //   font name [PSFontParam]
317  GooList *psNamedFonts16;      // named 16-bit fonts [PSFontParam]
318  GooList *psFonts16;           // generic 16-bit fonts [PSFontParam]
319  GBool psEmbedType1;           // embed Type 1 fonts?
320  GBool psEmbedTrueType;        // embed TrueType fonts?
321  GBool psEmbedCIDPostScript;   // embed CID PostScript fonts?
322  GBool psEmbedCIDTrueType;     // embed CID TrueType fonts?
323  GBool psSubstFonts;           // substitute missing fonts?
324  GBool psPreload;              // preload PostScript images and forms into
325                                //   memory
326  GBool psOPI;                  // generate PostScript OPI comments?
327  GBool psASCIIHex;             // use ASCIIHex instead of ASCII85?
328  GooString *textEncoding;      // encoding (unicodeMap) to use for text
329                                //   output
330  EndOfLineKind textEOL;        // type of EOL marker to use for text
331                                //   output
332  GBool textPageBreaks;         // insert end-of-page markers?
333  GBool textKeepTinyChars;      // keep all characters in text output
334  GooList *fontDirs;            // list of font dirs [GooString]
335  GBool enableFreeType;         // FreeType enable flag
336  GBool antialias;              // anti-aliasing enable flag
337  GBool vectorAntialias;        // vector anti-aliasing enable flag
338  GBool strokeAdjust;           // stroke adjustment enable flag
339  ScreenType screenType;        // halftone screen type
340  int screenSize;               // screen matrix size
341  int screenDotRadius;          // screen dot radius
342  double screenGamma;           // screen gamma correction
343  double screenBlackThreshold;  // screen black clamping threshold
344  double screenWhiteThreshold;  // screen white clamping threshold
345  GBool mapNumericCharNames;    // map numeric char names (from font subsets)?
346  GBool mapUnknownCharNames;    // map unknown char names?
347  GBool printCommands;          // print the drawing commands
348  GBool profileCommands;        // profile the drawing commands
349  GBool errQuiet;               // suppress error messages?
350
351  CharCodeToUnicodeCache *cidToUnicodeCache;
352  CharCodeToUnicodeCache *unicodeToUnicodeCache;
353  UnicodeMapCache *unicodeMapCache;
354  CMapCache *cMapCache;
355 
356#ifdef ENABLE_PLUGINS
357  GList *plugins;               // list of plugins [Plugin]
358  GList *securityHandlers;      // list of loaded security handlers
359                                //   [XpdfSecurityHandler]
360#endif
361
362#if MULTITHREADED
363  GooMutex mutex;
364  GooMutex unicodeMapCacheMutex;
365  GooMutex cMapCacheMutex;
366#endif
367
368  const char *popplerDataDir;
369};
370
371#endif
Note: See TracBrowser for help on using the repository browser.