1 //========================================================================
5 // Copyright 2001-2003 Glyph & Cog, LLC
7 //========================================================================
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
16 // Copyright (C) 2005, 2007-2010, 2012, 2015 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, 2011, 2012, 2014, 2015 William Bader <williambader@hotmail.com>
24 // Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
25 // Copyright (C) 2011 Pino Toscano <pino@kde.org>
26 // Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
27 // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
28 // Copyright (C) 2013 Jason Crain <jason@aquaticape.us>
30 // To see a description of the changes please see the Changelog file that
31 // came with your tarball or type make ChangeLog if you are building from git
33 //========================================================================
35 #ifndef GLOBALPARAMS_H
36 #define GLOBALPARAMS_H
38 #ifdef USE_GCC_PRAGMAS
43 #include "poppler-config.h"
45 #include "goo/gtypes.h"
46 #include "CharTypes.h"
49 #include "goo/GooMutex.h"
56 class CharCodeToUnicode
;
57 class CharCodeToUnicodeCache
;
59 class UnicodeMapCache
;
62 struct XpdfSecurityHandler
;
68 //------------------------------------------------------------------------
70 // The global parameters object.
71 extern GlobalParams
*globalParams
;
73 //------------------------------------------------------------------------
82 //------------------------------------------------------------------------
87 GooString
*name
; // PDF font name for psResidentFont16;
88 // char collection name for psResidentFontCC
89 int wMode
; // writing mode (0=horiz, 1=vert)
90 GooString
*psFontName
; // PostScript font name
91 GooString
*encoding
; // encoding
93 PSFontParam16(GooString
*nameA
, int wModeA
,
94 GooString
*psFontNameA
, GooString
*encodingA
);
98 //------------------------------------------------------------------------
109 //------------------------------------------------------------------------
117 //------------------------------------------------------------------------
123 screenStochasticClustered
126 //------------------------------------------------------------------------
131 // Initialize the global parameters by attempting to read a config
133 GlobalParams(const char *customPopplerDataDir
= NULL
);
137 void setupBaseFonts(char *dir
);
141 CharCode
getMacRomanCharCode(char *charName
);
143 // Return Unicode values for character names. Used for general text
145 Unicode
mapNameToUnicodeText(const char *charName
);
147 // Return Unicode values for character names. Used for glyph
148 // lookups or text extraction with ZapfDingbats fonts.
149 Unicode
mapNameToUnicodeAll(const char *charName
);
151 UnicodeMap
*getResidentUnicodeMap(GooString
*encodingName
);
152 FILE *getUnicodeMapFile(GooString
*encodingName
);
153 FILE *findCMapFile(GooString
*collection
, GooString
*cMapName
);
154 FILE *findToUnicodeFile(GooString
*name
);
155 GooString
*findFontFile(GooString
*fontName
);
156 GooString
*findBase14FontFile(GooString
*base14Name
, GfxFont
*font
);
157 GooString
*findSystemFontFile(GfxFont
*font
, SysFontType
*type
,
158 int *fontNum
, GooString
*substituteFontName
= NULL
,
159 GooString
*base14Name
= NULL
);
160 GooString
*findCCFontFile(GooString
*collection
);
161 GBool
getPSExpandSmaller();
162 GBool
getPSShrinkLarger();
164 PSLevel
getPSLevel();
165 GooString
*getPSResidentFont(GooString
*fontName
);
166 GooList
*getPSResidentFonts();
167 PSFontParam16
*getPSResidentFont16(GooString
*fontName
, int wMode
);
168 PSFontParam16
*getPSResidentFontCC(GooString
*collection
, int wMode
);
169 GooString
*getTextEncodingName();
170 EndOfLineKind
getTextEOL();
171 GBool
getTextPageBreaks();
172 GBool
getTextKeepTinyChars();
173 GBool
getEnableFreeType();
174 GBool
getStrokeAdjust();
175 ScreenType
getScreenType();
177 int getScreenDotRadius();
178 double getScreenGamma();
179 double getScreenBlackThreshold();
180 double getScreenWhiteThreshold();
181 double getMinLineWidth();
182 GBool
getOverprintPreview() { return overprintPreview
; }
183 GBool
getMapNumericCharNames();
184 GBool
getMapUnknownCharNames();
185 GBool
getPrintCommands();
186 GBool
getProfileCommands();
189 CharCodeToUnicode
*getCIDToUnicode(GooString
*collection
);
190 CharCodeToUnicode
*getUnicodeToUnicode(GooString
*fontName
);
191 UnicodeMap
*getUnicodeMap(GooString
*encodingName
);
192 CMap
*getCMap(GooString
*collection
, GooString
*cMapName
, Stream
*stream
= NULL
);
193 UnicodeMap
*getTextEncoding();
194 #ifdef ENABLE_PLUGINS
195 GBool
loadPlugin(char *type
, char *name
);
198 GooList
*getEncodingNames();
200 //----- functions to set parameters
201 void addFontFile(GooString
*fontName
, GooString
*path
);
202 void setPSFile(char *file
);
203 void setPSExpandSmaller(GBool expand
);
204 void setPSShrinkLarger(GBool shrink
);
205 void setPSCenter(GBool center
);
206 void setPSLevel(PSLevel level
);
207 void setTextEncoding(char *encodingName
);
208 GBool
setTextEOL(char *s
);
209 void setTextPageBreaks(GBool pageBreaks
);
210 void setTextKeepTinyChars(GBool keep
);
211 GBool
setEnableFreeType(char *s
);
212 GBool
setDisableFreeTypeHinting(char *s
);
213 void setStrokeAdjust(GBool strokeAdjust
);
214 void setScreenType(ScreenType st
);
215 void setScreenSize(int size
);
216 void setScreenDotRadius(int radius
);
217 void setScreenGamma(double gamma
);
218 void setScreenBlackThreshold(double blackThreshold
);
219 void setScreenWhiteThreshold(double whiteThreshold
);
220 void setMinLineWidth(double minLineWidth
);
221 void setOverprintPreview(GBool overprintPreviewA
);
222 void setMapNumericCharNames(GBool map
);
223 void setMapUnknownCharNames(GBool map
);
224 void setPrintCommands(GBool printCommandsA
);
225 void setProfileCommands(GBool profileCommandsA
);
226 void setErrQuiet(GBool errQuietA
);
228 static GBool
parseYesNo2(const char *token
, GBool
*flag
);
230 //----- security handlers
232 void addSecurityHandler(XpdfSecurityHandler
*handler
);
233 XpdfSecurityHandler
*getSecurityHandler(char *name
);
237 void parseNameToUnicode(GooString
*name
);
238 UnicodeMap
*getUnicodeMap2(GooString
*encodingName
);
240 void scanEncodingDirs();
241 void addCIDToUnicode(GooString
*collection
, GooString
*fileName
);
242 void addUnicodeMap(GooString
*encodingName
, GooString
*fileName
);
243 void addCMapDir(GooString
*collection
, GooString
*dir
);
245 //----- static tables
247 NameToCharCode
* // mapping from char name to
248 macRomanReverseMap
; // MacRomanEncoding index
250 //----- user-modifiable settings
252 NameToCharCode
* // mapping from char name to Unicode for ZapfDingbats
253 nameToUnicodeZapfDingbats
;
254 NameToCharCode
* // mapping from char name to Unicode for text
255 nameToUnicodeText
; // extraction
256 GooHash
*cidToUnicodes
; // files for mappings from char collections
257 // to Unicode, indexed by collection name
259 GooHash
*unicodeToUnicodes
; // files for Unicode-to-Unicode mappings,
260 // indexed by font name pattern [GooString]
261 GooHash
*residentUnicodeMaps
; // mappings from Unicode to char codes,
262 // indexed by encoding name [UnicodeMap]
263 GooHash
*unicodeMaps
; // files for mappings from Unicode to char
264 // codes, indexed by encoding name [GooString]
265 GooHash
*cMapDirs
; // list of CMap dirs, indexed by collection
266 // name [GooList[GooString]]
267 GooList
*toUnicodeDirs
; // list of ToUnicode CMap dirs [GooString]
268 GBool baseFontsInitialized
;
270 GooHash
*substFiles
; // windows font substitutes (for CID fonts)
272 GooHash
*fontFiles
; // font files: font name mapped to path
274 GooList
*fontDirs
; // list of font dirs [GString]
275 GooHash
*ccFontFiles
; // character collection font files:
276 // collection name mapped to path [GString]
277 SysFontList
*sysFonts
; // system fonts
278 GooString
*psFile
; // PostScript file or command (for xpdf)
279 GBool psExpandSmaller
; // expand smaller pages to fill paper
280 GBool psShrinkLarger
; // shrink larger pages to fit paper
281 GBool psCenter
; // center pages on the paper
282 PSLevel psLevel
; // PostScript level to generate
283 GooHash
*psResidentFonts
; // 8-bit fonts resident in printer:
284 // PDF font name mapped to PS font name
286 GooList
*psResidentFonts16
; // 16-bit fonts resident in printer:
287 // PDF font name mapped to font info
289 GooList
*psResidentFontsCC
; // 16-bit character collection fonts
290 // resident in printer: collection name
291 // mapped to font info [PSFontParam16]
292 GooString
*textEncoding
; // encoding (unicodeMap) to use for text
294 EndOfLineKind textEOL
; // type of EOL marker to use for text
296 GBool textPageBreaks
; // insert end-of-page markers?
297 GBool textKeepTinyChars
; // keep all characters in text output
298 GBool enableFreeType
; // FreeType enable flag
299 GBool disableFreeTypeHinting
; // FreeType disable hinting flag
300 GBool strokeAdjust
; // stroke adjustment enable flag
301 ScreenType screenType
; // halftone screen type
302 int screenSize
; // screen matrix size
303 int screenDotRadius
; // screen dot radius
304 double screenGamma
; // screen gamma correction
305 double screenBlackThreshold
; // screen black clamping threshold
306 double screenWhiteThreshold
; // screen white clamping threshold
307 double minLineWidth
; // minimum line width
308 GBool overprintPreview
; // enable overprint preview
309 GBool mapNumericCharNames
; // map numeric char names (from font subsets)?
310 GBool mapUnknownCharNames
; // map unknown char names?
311 GBool printCommands
; // print the drawing commands
312 GBool profileCommands
; // profile the drawing commands
313 GBool errQuiet
; // suppress error messages?
314 double splashResolution
; // resolution when rasterizing images
316 CharCodeToUnicodeCache
*cidToUnicodeCache
;
317 CharCodeToUnicodeCache
*unicodeToUnicodeCache
;
318 UnicodeMapCache
*unicodeMapCache
;
319 CMapCache
*cMapCache
;
321 #ifdef ENABLE_PLUGINS
322 GooList
*plugins
; // list of plugins [Plugin]
323 GooList
*securityHandlers
; // list of loaded security handlers
324 // [XpdfSecurityHandler]
329 GooMutex unicodeMapCacheMutex
;
330 GooMutex cMapCacheMutex
;
333 const char *popplerDataDir
;