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 Martin Kretzschmar <martink@gnome.org>
17 // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
18 // Copyright (C) 2005, 2007-2010, 2012, 2015 Albert Astals Cid <aacid@kde.org>
19 // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com>
20 // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>
21 // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
22 // Copyright (C) 2006 Ed Catmur <ed@catmur.co.uk>
23 // Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
24 // Copyright (C) 2007, 2009 Jonathan Kew <jonathan_kew@sil.org>
25 // Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com>
26 // Copyright (C) 2009, 2011, 2012, 2015 William Bader <williambader@hotmail.com>
27 // Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
28 // Copyright (C) 2010, 2012 Hib Eris <hib@hiberis.nl>
29 // Copyright (C) 2010 Patrick Spendrin <ps_ml@gmx.de>
30 // Copyright (C) 2010 Jakub Wilk <jwilk@jwilk.net>
31 // Copyright (C) 2011 Pino Toscano <pino@kde.org>
32 // Copyright (C) 2011 Koji Otani <sho@bbr.jp>
33 // Copyright (C) 2012 Yi Yang <ahyangyi@gmail.com>
34 // Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
35 // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
36 // Copyright (C) 2012 Peter Breitenlohner <peb@mppmu.mpg.de>
37 // Copyright (C) 2013, 2014 Jason Crain <jason@aquaticape.us>
39 // To see a description of the changes please see the Changelog file that
40 // came with your tarball or type make ChangeLog if you are building from git
42 //========================================================================
46 #ifdef USE_GCC_PRAGMAS
47 #pragma implementation
60 # include <mbstring.h>
63 #include "goo/GooString.h"
64 #include "goo/GooList.h"
65 #include "goo/GooHash.h"
66 #include "goo/gfile.h"
68 #include "NameToCharCode.h"
69 #include "CharCodeToUnicode.h"
70 #include "UnicodeMap.h"
72 #include "BuiltinFontTables.h"
73 #include "FontEncodingTables.h"
75 # include "XpdfPluginAPI.h"
77 #include "GlobalParams.h"
80 #if WITH_FONTCONFIGURATION_FONTCONFIG
81 #include <fontconfig/fontconfig.h>
85 # define strcasecmp stricmp
91 # define lockGlobalParams gLockMutex(&mutex)
92 # define lockUnicodeMapCache gLockMutex(&unicodeMapCacheMutex)
93 # define lockCMapCache gLockMutex(&cMapCacheMutex)
94 # define unlockGlobalParams gUnlockMutex(&mutex)
95 # define unlockUnicodeMapCache gUnlockMutex(&unicodeMapCacheMutex)
96 # define unlockCMapCache gUnlockMutex(&cMapCacheMutex)
98 # define lockGlobalParams
99 # define lockUnicodeMapCache
100 # define lockCMapCache
101 # define unlockGlobalParams
102 # define unlockUnicodeMapCache
103 # define unlockCMapCache
106 #ifndef FC_WEIGHT_BOOK
107 #define FC_WEIGHT_BOOK 75
110 #include "NameToUnicodeTable.h"
111 #include "UnicodeMapTables.h"
114 #ifdef ENABLE_PLUGINS
116 extern XpdfPluginVecTable xpdfPluginVecTable
;
120 //------------------------------------------------------------------------
122 #define cidToUnicodeCacheSize 4
123 #define unicodeToUnicodeCacheSize 4
125 //------------------------------------------------------------------------
127 GlobalParams
*globalParams
= NULL
;
129 //------------------------------------------------------------------------
131 //------------------------------------------------------------------------
133 PSFontParam16::PSFontParam16(GooString
*nameA
, int wModeA
,
134 GooString
*psFontNameA
, GooString
*encodingA
) {
137 psFontName
= psFontNameA
;
138 encoding
= encodingA
;
141 PSFontParam16::~PSFontParam16() {
147 #if ENABLE_RELOCATABLE && defined(_WIN32)
149 /* search for data relative to where we are installed */
151 static HMODULE hmodule
;
155 DllMain (HINSTANCE hinstDLL
,
161 case DLL_PROCESS_ATTACH
:
171 get_poppler_datadir (void)
173 static char retval
[MAX_PATH
];
174 static int beenhere
= 0;
181 if (!GetModuleFileName (hmodule
, (CHAR
*) retval
, sizeof(retval
) - 20))
182 return POPPLER_DATADIR
;
184 p
= _mbsrchr ((unsigned char *) retval
, '\\');
186 p
= _mbsrchr ((unsigned char *) retval
, '\\');
188 if (stricmp ((const char *) (p
+1), "bin") == 0)
191 strcat (retval
, "\\share\\poppler");
198 #undef POPPLER_DATADIR
199 #define POPPLER_DATADIR get_poppler_datadir ()
203 //------------------------------------------------------------------------
205 //------------------------------------------------------------------------
217 int fontNum
; // for TrueType collections
218 GooString
*substituteName
;
220 SysFontInfo(GooString
*nameA
, GBool boldA
, GBool italicA
, GBool obliqueA
, GBool fixedWidthA
,
221 GooString
*pathA
, SysFontType typeA
, int fontNumA
, GooString
*substituteNameA
);
223 GBool
match(SysFontInfo
*fi
);
224 GBool
match(GooString
*nameA
, GBool boldA
, GBool italicA
, GBool obliqueA
, GBool fixedWidthA
);
225 GBool
match(GooString
*nameA
, GBool boldA
, GBool italicA
);
228 SysFontInfo::SysFontInfo(GooString
*nameA
, GBool boldA
, GBool italicA
, GBool obliqueA
, GBool fixedWidthA
,
229 GooString
*pathA
, SysFontType typeA
, int fontNumA
, GooString
*substituteNameA
) {
234 fixedWidth
= fixedWidthA
;
238 substituteName
= substituteNameA
;
241 SysFontInfo::~SysFontInfo() {
244 delete substituteName
;
247 GBool
SysFontInfo::match(SysFontInfo
*fi
) {
248 return !strcasecmp(name
->getCString(), fi
->name
->getCString()) &&
249 bold
== fi
->bold
&& italic
== fi
->italic
&& oblique
== fi
->oblique
&& fixedWidth
== fi
->fixedWidth
;
252 GBool
SysFontInfo::match(GooString
*nameA
, GBool boldA
, GBool italicA
, GBool obliqueA
, GBool fixedWidthA
) {
253 return !strcasecmp(name
->getCString(), nameA
->getCString()) &&
254 bold
== boldA
&& italic
== italicA
&& oblique
== obliqueA
&& fixedWidth
== fixedWidthA
;
257 GBool
SysFontInfo::match(GooString
*nameA
, GBool boldA
, GBool italicA
) {
258 return !strcasecmp(name
->getCString(), nameA
->getCString()) &&
259 bold
== boldA
&& italic
== italicA
;
262 //------------------------------------------------------------------------
264 //------------------------------------------------------------------------
271 SysFontInfo
*find(GooString
*name
, GBool isFixedWidth
, GBool exact
);
274 void scanWindowsFonts(GooString
*winFontDir
);
276 #ifdef WITH_FONTCONFIGURATION_FONTCONFIG
277 void addFcFont(SysFontInfo
*si
) {fonts
->append(si
);}
282 SysFontInfo
*makeWindowsFont(char *name
, int fontNum
,
286 GooList
*fonts
; // [SysFontInfo]
289 SysFontList::SysFontList() {
290 fonts
= new GooList();
293 SysFontList::~SysFontList() {
294 deleteGooList(fonts
, SysFontInfo
);
297 SysFontInfo
*SysFontList::find(GooString
*name
, GBool fixedWidth
, GBool exact
) {
299 GBool bold
, italic
, oblique
;
304 name2
= name
->copy();
306 // remove space, comma, dash chars
308 while (i
< name2
->getLength()) {
309 c
= name2
->getChar(i
);
310 if (c
== ' ' || c
== ',' || c
== '-') {
316 n
= name2
->getLength();
318 // remove trailing "MT" (Foo-MT, Foo-BoldMT, etc.)
319 if (n
> 2 && !strcmp(name2
->getCString() + n
- 2, "MT")) {
320 name2
->del(n
- 2, 2);
324 // look for "Regular"
325 if (n
> 7 && !strcmp(name2
->getCString() + n
- 7, "Regular")) {
326 name2
->del(n
- 7, 7);
331 if (n
> 6 && !strcmp(name2
->getCString() + n
- 6, "Italic")) {
332 name2
->del(n
- 6, 6);
339 // look for "Oblique"
340 if (n
> 6 && !strcmp(name2
->getCString() + n
- 7, "Oblique")) {
341 name2
->del(n
- 7, 7);
349 if (n
> 4 && !strcmp(name2
->getCString() + n
- 4, "Bold")) {
350 name2
->del(n
- 4, 4);
357 // remove trailing "MT" (FooMT-Bold, etc.)
358 if (n
> 2 && !strcmp(name2
->getCString() + n
- 2, "MT")) {
359 name2
->del(n
- 2, 2);
363 // remove trailing "PS"
364 if (n
> 2 && !strcmp(name2
->getCString() + n
- 2, "PS")) {
365 name2
->del(n
- 2, 2);
369 // remove trailing "IdentityH"
370 if (n
> 9 && !strcmp(name2
->getCString() + n
- 9, "IdentityH")) {
371 name2
->del(n
- 9, 9);
375 // search for the font
377 for (i
= 0; i
< fonts
->getLength(); ++i
) {
378 fi
= (SysFontInfo
*)fonts
->get(i
);
379 if (fi
->match(name2
, bold
, italic
, oblique
, fixedWidth
)) {
384 if (!fi
&& !exact
&& bold
) {
385 // try ignoring the bold flag
386 for (i
= 0; i
< fonts
->getLength(); ++i
) {
387 fi
= (SysFontInfo
*)fonts
->get(i
);
388 if (fi
->match(name2
, gFalse
, italic
)) {
394 if (!fi
&& !exact
&& (bold
|| italic
)) {
395 // try ignoring the bold and italic flags
396 for (i
= 0; i
< fonts
->getLength(); ++i
) {
397 fi
= (SysFontInfo
*)fonts
->get(i
);
398 if (fi
->match(name2
, gFalse
, gFalse
)) {
410 #ifdef ENABLE_PLUGINS
411 //------------------------------------------------------------------------
413 //------------------------------------------------------------------------
418 static Plugin
*load(char *type
, char *name
);
424 Plugin(HMODULE libA
);
432 Plugin
*Plugin::load(char *type
, char *name
) {
435 XpdfPluginVecTable
*vt
;
436 XpdfBool (*xpdfInitPlugin
)(void);
443 path
= new GooString(POPPLER_DATADIR
);
444 appendToPath(path
, "plugins");
445 appendToPath(path
, type
);
446 appendToPath(path
, name
);
449 path
->append(".dll");
450 if (!(libA
= LoadLibrary(path
->getCString()))) {
451 error(errIO
, -1, "Failed to load plugin '{0:t}'", path
);
454 if (!(vt
= (XpdfPluginVecTable
*)
455 GetProcAddress(libA
, "xpdfPluginVecTable"))) {
456 error(errIO
, -1, "Failed to find xpdfPluginVecTable in plugin '{0:t}'",
461 //~ need to deal with other extensions here
463 if (!(dlA
= dlopen(path
->getCString(), RTLD_NOW
))) {
464 error(errIO
, -1, "Failed to load plugin '{0:t}': {1:s}",
468 if (!(vt
= (XpdfPluginVecTable
*)dlsym(dlA
, "xpdfPluginVecTable"))) {
469 error(errIO
, -1, "Failed to find xpdfPluginVecTable in plugin '{0:t}'",
475 if (vt
->version
!= xpdfPluginVecTable
.version
) {
476 error(errIO
, -1, "Plugin '{0:t}' is wrong version", path
);
479 memcpy(vt
, &xpdfPluginVecTable
, sizeof(xpdfPluginVecTable
));
482 if (!(xpdfInitPlugin
= (XpdfBool (*)(void))
483 GetProcAddress(libA
, "xpdfInitPlugin"))) {
484 error(errIO
, -1, "Failed to find xpdfInitPlugin in plugin '{0:t}'",
489 if (!(xpdfInitPlugin
= (XpdfBool (*)(void))dlsym(dlA
, "xpdfInitPlugin"))) {
490 error(errIO
, -1, "Failed to find xpdfInitPlugin in plugin '{0:t}'",
496 if (!(*xpdfInitPlugin
)()) {
497 error(errIO
, -1, "Initialization of plugin '{0:t}' failed", path
);
502 plugin
= new Plugin(libA
);
504 plugin
= new Plugin(dlA
);
522 Plugin::Plugin(HMODULE libA
) {
526 Plugin::Plugin(void *dlA
) {
532 void (*xpdfFreePlugin
)(void);
535 if ((xpdfFreePlugin
= (void (*)(void))
536 GetProcAddress(lib
, "xpdfFreePlugin"))) {
541 if ((xpdfFreePlugin
= (void (*)(void))dlsym(dl
, "xpdfFreePlugin"))) {
548 #endif // ENABLE_PLUGINS
550 //------------------------------------------------------------------------
552 //------------------------------------------------------------------------
554 GlobalParams::GlobalParams(const char *customPopplerDataDir
)
555 : popplerDataDir(customPopplerDataDir
)
562 gInitMutex(&unicodeMapCacheMutex
);
563 gInitMutex(&cMapCacheMutex
);
566 initBuiltinFontTables();
568 // scan the encoding in reverse because we want the lowest-numbered
569 // index for each char name ('space' is encoded twice)
570 macRomanReverseMap
= new NameToCharCode();
571 for (i
= 255; i
>= 0; --i
) {
572 if (macRomanEncoding
[i
]) {
573 macRomanReverseMap
->add(macRomanEncoding
[i
], (CharCode
)i
);
578 substFiles
= new GooHash(gTrue
);
580 nameToUnicodeZapfDingbats
= new NameToCharCode();
581 nameToUnicodeText
= new NameToCharCode();
582 cidToUnicodes
= new GooHash(gTrue
);
583 unicodeToUnicodes
= new GooHash(gTrue
);
584 residentUnicodeMaps
= new GooHash();
585 unicodeMaps
= new GooHash(gTrue
);
586 cMapDirs
= new GooHash(gTrue
);
587 toUnicodeDirs
= new GooList();
588 fontFiles
= new GooHash(gTrue
);
589 fontDirs
= new GooList();
590 ccFontFiles
= new GooHash(gTrue
);
591 sysFonts
= new SysFontList();
592 psExpandSmaller
= gFalse
;
593 psShrinkLarger
= gTrue
;
597 psResidentFonts
= new GooHash(gTrue
);
598 psResidentFonts16
= new GooList();
599 psResidentFontsCC
= new GooList();
600 textEncoding
= new GooString("UTF-8");
608 textPageBreaks
= gTrue
;
609 textKeepTinyChars
= gFalse
;
610 enableFreeType
= gTrue
;
611 strokeAdjust
= gTrue
;
612 screenType
= screenUnset
;
614 screenDotRadius
= -1;
616 screenBlackThreshold
= 0.0;
617 screenWhiteThreshold
= 1.0;
619 overprintPreview
= gFalse
;
620 mapNumericCharNames
= gTrue
;
621 mapUnknownCharNames
= gTrue
;
622 printCommands
= gFalse
;
623 profileCommands
= gFalse
;
626 cidToUnicodeCache
= new CharCodeToUnicodeCache(cidToUnicodeCacheSize
);
627 unicodeToUnicodeCache
=
628 new CharCodeToUnicodeCache(unicodeToUnicodeCacheSize
);
629 unicodeMapCache
= new UnicodeMapCache();
630 cMapCache
= new CMapCache();
632 baseFontsInitialized
= gFalse
;
633 #ifdef ENABLE_PLUGINS
634 plugins
= new GooList();
635 securityHandlers
= new GooList();
638 // set up the initial nameToUnicode tables
639 for (i
= 0; nameToUnicodeZapfDingbatsTab
[i
].name
; ++i
) {
640 nameToUnicodeZapfDingbats
->add(nameToUnicodeZapfDingbatsTab
[i
].name
, nameToUnicodeZapfDingbatsTab
[i
].u
);
643 for (i
= 0; nameToUnicodeTextTab
[i
].name
; ++i
) {
644 nameToUnicodeText
->add(nameToUnicodeTextTab
[i
].name
, nameToUnicodeTextTab
[i
].u
);
647 // set up the residentUnicodeMaps table
648 map
= new UnicodeMap("Latin1", gFalse
,
649 latin1UnicodeMapRanges
, latin1UnicodeMapLen
);
650 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
651 map
= new UnicodeMap("ASCII7", gFalse
,
652 ascii7UnicodeMapRanges
, ascii7UnicodeMapLen
);
653 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
654 map
= new UnicodeMap("Symbol", gFalse
,
655 symbolUnicodeMapRanges
, symbolUnicodeMapLen
);
656 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
657 map
= new UnicodeMap("ZapfDingbats", gFalse
, zapfDingbatsUnicodeMapRanges
,
658 zapfDingbatsUnicodeMapLen
);
659 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
660 map
= new UnicodeMap("UTF-8", gTrue
, &mapUTF8
);
661 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
662 map
= new UnicodeMap("UCS-2", gTrue
, &mapUCS2
);
663 residentUnicodeMaps
->add(map
->getEncodingName(), map
);
668 void GlobalParams::scanEncodingDirs() {
671 const char *dataRoot
= popplerDataDir
? popplerDataDir
: POPPLER_DATADIR
;
673 // allocate buffer large enough to append "/nameToUnicode"
674 size_t bufSize
= strlen(dataRoot
) + strlen("/nameToUnicode") + 1;
675 char *dataPathBuffer
= new char[bufSize
];
677 snprintf(dataPathBuffer
, bufSize
, "%s/nameToUnicode", dataRoot
);
678 dir
= new GDir(dataPathBuffer
, gTrue
);
679 while (entry
= dir
->getNextEntry(), entry
!= NULL
) {
680 if (!entry
->isDir()) {
681 parseNameToUnicode(entry
->getFullPath());
687 snprintf(dataPathBuffer
, bufSize
, "%s/cidToUnicode", dataRoot
);
688 dir
= new GDir(dataPathBuffer
, gFalse
);
689 while (entry
= dir
->getNextEntry(), entry
!= NULL
) {
690 addCIDToUnicode(entry
->getName(), entry
->getFullPath());
695 snprintf(dataPathBuffer
, bufSize
, "%s/unicodeMap", dataRoot
);
696 dir
= new GDir(dataPathBuffer
, gFalse
);
697 while (entry
= dir
->getNextEntry(), entry
!= NULL
) {
698 addUnicodeMap(entry
->getName(), entry
->getFullPath());
703 snprintf(dataPathBuffer
, bufSize
, "%s/cMap", dataRoot
);
704 dir
= new GDir(dataPathBuffer
, gFalse
);
705 while (entry
= dir
->getNextEntry(), entry
!= NULL
) {
706 addCMapDir(entry
->getName(), entry
->getFullPath());
707 toUnicodeDirs
->append(entry
->getFullPath()->copy());
712 delete[] dataPathBuffer
;
715 void GlobalParams::parseNameToUnicode(GooString
*name
) {
723 if (!(f
= openFile(name
->getCString(), "r"))) {
724 error(errIO
, -1, "Couldn't open 'nameToUnicode' file '{0:t}'",
729 while (getLine(buf
, sizeof(buf
), f
)) {
730 tok1
= strtok_r(buf
, " \t\r\n", &tokptr
);
731 tok2
= strtok_r(NULL
, " \t\r\n", &tokptr
);
733 sscanf(tok1
, "%x", &u
);
734 nameToUnicodeText
->add(tok2
, u
);
736 error(errConfig
, -1, "Bad line in 'nameToUnicode' file ({0:t}:{1:d})",
744 void GlobalParams::addCIDToUnicode(GooString
*collection
,
745 GooString
*fileName
) {
748 if ((old
= (GooString
*)cidToUnicodes
->remove(collection
))) {
751 cidToUnicodes
->add(collection
->copy(), fileName
->copy());
754 void GlobalParams::addUnicodeMap(GooString
*encodingName
, GooString
*fileName
)
758 if ((old
= (GooString
*)unicodeMaps
->remove(encodingName
))) {
761 unicodeMaps
->add(encodingName
->copy(), fileName
->copy());
764 void GlobalParams::addCMapDir(GooString
*collection
, GooString
*dir
) {
767 if (!(list
= (GooList
*)cMapDirs
->lookup(collection
))) {
768 list
= new GooList();
769 cMapDirs
->add(collection
->copy(), list
);
771 list
->append(dir
->copy());
774 GBool
GlobalParams::parseYesNo2(const char *token
, GBool
*flag
) {
775 if (!strcmp(token
, "yes")) {
777 } else if (!strcmp(token
, "no")) {
785 GlobalParams::~GlobalParams() {
786 freeBuiltinFontTables();
788 delete macRomanReverseMap
;
790 delete nameToUnicodeZapfDingbats
;
791 delete nameToUnicodeText
;
792 deleteGooHash(cidToUnicodes
, GooString
);
793 deleteGooHash(unicodeToUnicodes
, GooString
);
794 deleteGooHash(residentUnicodeMaps
, UnicodeMap
);
795 deleteGooHash(unicodeMaps
, GooString
);
796 deleteGooList(toUnicodeDirs
, GooString
);
797 deleteGooHash(fontFiles
, GooString
);
798 deleteGooList(fontDirs
, GooString
);
799 deleteGooHash(ccFontFiles
, GooString
);
801 deleteGooHash(substFiles
, GooString
);
807 deleteGooHash(psResidentFonts
, GooString
);
808 deleteGooList(psResidentFonts16
, PSFontParam16
);
809 deleteGooList(psResidentFontsCC
, PSFontParam16
);
814 cMapDirs
->startIter(&iter
);
816 while (cMapDirs
->getNext(&iter
, &key
, &val
)) {
817 GooList
* list
= (GooList
*)val
;
818 deleteGooList(list
, GooString
);
822 delete cidToUnicodeCache
;
823 delete unicodeToUnicodeCache
;
824 delete unicodeMapCache
;
827 #ifdef ENABLE_PLUGINS
828 delete securityHandlers
;
829 deleteGooList(plugins
, Plugin
);
833 gDestroyMutex(&mutex
);
834 gDestroyMutex(&unicodeMapCacheMutex
);
835 gDestroyMutex(&cMapCacheMutex
);
839 //------------------------------------------------------------------------
841 //------------------------------------------------------------------------
843 CharCode
GlobalParams::getMacRomanCharCode(char *charName
) {
844 // no need to lock - macRomanReverseMap is constant
845 return macRomanReverseMap
->lookup(charName
);
848 Unicode
GlobalParams::mapNameToUnicodeAll(const char *charName
) {
849 // no need to lock - nameToUnicodeZapfDingbats and nameToUnicodeText are constant
850 Unicode u
= nameToUnicodeZapfDingbats
->lookup(charName
);
852 u
= nameToUnicodeText
->lookup(charName
);
856 Unicode
GlobalParams::mapNameToUnicodeText(const char *charName
) {
857 // no need to lock - nameToUnicodeText is constant
858 return nameToUnicodeText
->lookup(charName
);
861 UnicodeMap
*GlobalParams::getResidentUnicodeMap(GooString
*encodingName
) {
865 map
= (UnicodeMap
*)residentUnicodeMaps
->lookup(encodingName
);
873 FILE *GlobalParams::getUnicodeMapFile(GooString
*encodingName
) {
878 if ((fileName
= (GooString
*)unicodeMaps
->lookup(encodingName
))) {
879 f
= openFile(fileName
->getCString(), "r");
887 FILE *GlobalParams::findCMapFile(GooString
*collection
, GooString
*cMapName
) {
895 if (!(list
= (GooList
*)cMapDirs
->lookup(collection
))) {
899 for (i
= 0; i
< list
->getLength(); ++i
) {
900 dir
= (GooString
*)list
->get(i
);
901 fileName
= appendToPath(dir
->copy(), cMapName
->getCString());
902 f
= openFile(fileName
->getCString(), "r");
913 FILE *GlobalParams::findToUnicodeFile(GooString
*name
) {
914 GooString
*dir
, *fileName
;
919 for (i
= 0; i
< toUnicodeDirs
->getLength(); ++i
) {
920 dir
= (GooString
*)toUnicodeDirs
->get(i
);
921 fileName
= appendToPath(dir
->copy(), name
->getCString());
922 f
= openFile(fileName
->getCString(), "r");
933 #if WITH_FONTCONFIGURATION_FONTCONFIG
934 static GBool
findModifier(const char *name
, const char *modifier
, const char **start
)
941 match
= strstr(name
, modifier
);
943 if (*start
== NULL
|| match
< *start
)
952 static const char *getFontLang(GfxFont
*font
)
956 // find the language we want the font to support
957 if (font
->isCIDFont())
959 GooString
*collection
= ((GfxCIDFont
*)font
)->getCollection();
962 if (strcmp(collection
->getCString(), "Adobe-GB1") == 0)
963 lang
= "zh-cn"; // Simplified Chinese
964 else if (strcmp(collection
->getCString(), "Adobe-CNS1") == 0)
965 lang
= "zh-tw"; // Traditional Chinese
966 else if (strcmp(collection
->getCString(), "Adobe-Japan1") == 0)
967 lang
= "ja"; // Japanese
968 else if (strcmp(collection
->getCString(), "Adobe-Japan2") == 0)
969 lang
= "ja"; // Japanese
970 else if (strcmp(collection
->getCString(), "Adobe-Korea1") == 0)
971 lang
= "ko"; // Korean
972 else if (strcmp(collection
->getCString(), "Adobe-UCS") == 0)
974 else if (strcmp(collection
->getCString(), "Adobe-Identity") == 0)
978 error(errUnimplemented
, -1, "Unknown CID font collection, please report to poppler bugzilla.");
988 static FcPattern
*buildFcPattern(GfxFont
*font
, GooString
*base14Name
)
994 bool deleteFamily
= false;
995 char *family
, *name
, *modifiers
;
999 // this is all heuristics will be overwritten if font had proper info
1000 name
= (base14Name
== NULL
) ? font
->getName()->getCString() : base14Name
->getCString();
1002 modifiers
= strchr (name
, ',');
1003 if (modifiers
== NULL
)
1004 modifiers
= strchr (name
, '-');
1006 // remove the - from the names, for some reason, Fontconfig does not
1007 // understand "MS-Mincho" but does with "MS Mincho"
1008 int len
= strlen(name
);
1009 for (int i
= 0; i
< len
; i
++)
1010 name
[i
] = (name
[i
] == '-' ? ' ' : name
[i
]);
1013 findModifier(modifiers
, "Regular", &start
);
1014 findModifier(modifiers
, "Roman", &start
);
1016 if (findModifier(modifiers
, "Oblique", &start
))
1017 slant
= FC_SLANT_OBLIQUE
;
1018 if (findModifier(modifiers
, "Italic", &start
))
1019 slant
= FC_SLANT_ITALIC
;
1020 if (findModifier(modifiers
, "Bold", &start
))
1021 weight
= FC_WEIGHT_BOLD
;
1022 if (findModifier(modifiers
, "Light", &start
))
1023 weight
= FC_WEIGHT_LIGHT
;
1024 if (findModifier(modifiers
, "Medium", &start
))
1025 weight
= FC_WEIGHT_MEDIUM
;
1026 if (findModifier(modifiers
, "Condensed", &start
))
1027 width
= FC_WIDTH_CONDENSED
;
1030 // There have been "modifiers" in the name, crop them to obtain
1032 family
= new char[len
+1];
1033 strcpy(family
, name
);
1034 int pos
= (modifiers
- name
);
1036 deleteFamily
= true;
1043 if (font
->isFixedWidth())
1046 weight
= FC_WEIGHT_BOLD
;
1047 if (font
->isItalic())
1048 slant
= FC_SLANT_ITALIC
;
1050 // if the FontDescriptor specified a family name use it
1051 if (font
->getFamily()) {
1054 deleteFamily
= false;
1056 family
= font
->getFamily()->getCString();
1059 // if the FontDescriptor specified a weight use it
1060 switch (font
-> getWeight())
1062 case GfxFont::W100
: weight
= FC_WEIGHT_EXTRALIGHT
; break;
1063 case GfxFont::W200
: weight
= FC_WEIGHT_LIGHT
; break;
1064 case GfxFont::W300
: weight
= FC_WEIGHT_BOOK
; break;
1065 case GfxFont::W400
: weight
= FC_WEIGHT_NORMAL
; break;
1066 case GfxFont::W500
: weight
= FC_WEIGHT_MEDIUM
; break;
1067 case GfxFont::W600
: weight
= FC_WEIGHT_DEMIBOLD
; break;
1068 case GfxFont::W700
: weight
= FC_WEIGHT_BOLD
; break;
1069 case GfxFont::W800
: weight
= FC_WEIGHT_EXTRABOLD
; break;
1070 case GfxFont::W900
: weight
= FC_WEIGHT_BLACK
; break;
1074 // if the FontDescriptor specified a width use it
1075 switch (font
-> getStretch())
1077 case GfxFont::UltraCondensed
: width
= FC_WIDTH_ULTRACONDENSED
; break;
1078 case GfxFont::ExtraCondensed
: width
= FC_WIDTH_EXTRACONDENSED
; break;
1079 case GfxFont::Condensed
: width
= FC_WIDTH_CONDENSED
; break;
1080 case GfxFont::SemiCondensed
: width
= FC_WIDTH_SEMICONDENSED
; break;
1081 case GfxFont::Normal
: width
= FC_WIDTH_NORMAL
; break;
1082 case GfxFont::SemiExpanded
: width
= FC_WIDTH_SEMIEXPANDED
; break;
1083 case GfxFont::Expanded
: width
= FC_WIDTH_EXPANDED
; break;
1084 case GfxFont::ExtraExpanded
: width
= FC_WIDTH_EXTRAEXPANDED
; break;
1085 case GfxFont::UltraExpanded
: width
= FC_WIDTH_ULTRAEXPANDED
; break;
1089 const char *lang
= getFontLang(font
);
1091 p
= FcPatternBuild(NULL
,
1092 FC_FAMILY
, FcTypeString
, family
,
1093 FC_LANG
, FcTypeString
, lang
,
1095 if (slant
!= -1) FcPatternAddInteger(p
, FC_SLANT
, slant
);
1096 if (weight
!= -1) FcPatternAddInteger(p
, FC_WEIGHT
, weight
);
1097 if (width
!= -1) FcPatternAddInteger(p
, FC_WIDTH
, width
);
1098 if (spacing
!= -1) FcPatternAddInteger(p
, FC_SPACING
, spacing
);
1106 GooString
*GlobalParams::findFontFile(GooString
*fontName
) {
1107 static const char *exts
[] = { ".pfa", ".pfb", ".ttf", ".ttc", ".otf" };
1108 GooString
*path
, *dir
;
1110 GooString
*fontNameU
;
1116 setupBaseFonts(NULL
);
1118 if ((path
= (GooString
*)fontFiles
->lookup(fontName
))) {
1119 path
= path
->copy();
1123 for (i
= 0; i
< fontDirs
->getLength(); ++i
) {
1124 dir
= (GooString
*)fontDirs
->get(i
);
1125 for (j
= 0; j
< (int)(sizeof(exts
) / sizeof(exts
[0])); ++j
) {
1128 fontNameU
= fileNameToUTF8(fontName
->getCString());
1129 path
= appendToPath(dir
->copy(), fontNameU
->getCString());
1132 path
= appendToPath(dir
->copy(), fontName
->getCString());
1135 if ((f
= openFile(path
->getCString(), "rb"))) {
1147 /* if you can't or don't want to use Fontconfig, you need to implement
1148 this function for your platform. For Windows, it's in GlobalParamsWin.cc
1150 #if WITH_FONTCONFIGURATION_FONTCONFIG
1151 // not needed for fontconfig
1152 void GlobalParams::setupBaseFonts(char *dir
) {
1155 GooString
*GlobalParams::findBase14FontFile(GooString
*base14Name
, GfxFont
*font
) {
1159 return findSystemFontFile(font
, &type
, &fontNum
, NULL
, base14Name
);
1162 GooString
*GlobalParams::findSystemFontFile(GfxFont
*font
,
1164 int *fontNum
, GooString
*substituteFontName
, GooString
*base14Name
) {
1165 SysFontInfo
*fi
= NULL
;
1167 GooString
*path
= NULL
;
1168 GooString
*fontName
= font
->getName();
1169 GooString substituteName
;
1170 if (!fontName
) return NULL
;
1173 if ((fi
= sysFonts
->find(fontName
, font
->isFixedWidth(), gTrue
))) {
1174 path
= fi
->path
->copy();
1176 *fontNum
= fi
->fontNum
;
1177 substituteName
.Set(fi
->substituteName
->getCString());
1184 FcLangSet
*lb
= NULL
;
1185 p
= buildFcPattern(font
, base14Name
);
1189 FcConfigSubstitute(NULL
, p
, FcMatchPattern
);
1190 FcDefaultSubstitute(p
);
1191 set
= FcFontSort(NULL
, p
, FcFalse
, NULL
, &res
);
1195 // find the language we want the font to support
1196 const char *lang
= getFontLang(font
);
1197 if (strcmp(lang
,"xx") != 0) {
1198 lb
= FcLangSetCreate();
1199 FcLangSetAdd(lb
,(FcChar8
*)lang
);
1204 first: fonts support the language
1205 second: all fonts (fall back)
1209 for (i
= 0; i
< set
->nfont
; ++i
)
1211 res
= FcPatternGetString(set
->fonts
[i
], FC_FILE
, 0, &s
);
1212 if (res
!= FcResultMatch
|| !s
)
1216 res
= FcPatternGetLangSet(set
->fonts
[i
], FC_LANG
, 0, &l
);
1217 if (res
!= FcResultMatch
|| !FcLangSetContains(l
,lb
)) {
1222 res
= FcPatternGetString(set
->fonts
[i
], FC_FULLNAME
, 0, &s2
);
1223 if (res
== FcResultMatch
&& s2
) {
1224 substituteName
.Set((char*)s2
);
1226 // fontconfig does not extract fullname for some fonts
1227 // create the fullname from family and style
1228 res
= FcPatternGetString(set
->fonts
[i
], FC_FAMILY
, 0, &s2
);
1229 if (res
== FcResultMatch
&& s2
) {
1230 substituteName
.Set((char*)s2
);
1231 res
= FcPatternGetString(set
->fonts
[i
], FC_STYLE
, 0, &s2
);
1232 if (res
== FcResultMatch
&& s2
) {
1233 GooString
*style
= new GooString((char*)s2
);
1234 if (style
->cmp("Regular") != 0) {
1235 substituteName
.append(" ");
1236 substituteName
.append(style
);
1242 ext
= strrchr((char*)s
,'.');
1245 if (!strncasecmp(ext
,".ttf",4) || !strncasecmp(ext
, ".ttc", 4) || !strncasecmp(ext
, ".otf", 4))
1248 GBool bold
= font
->isBold();
1249 GBool italic
= font
->isItalic();
1250 GBool oblique
= gFalse
;
1251 FcPatternGetInteger(set
->fonts
[i
], FC_WEIGHT
, 0, &weight
);
1252 FcPatternGetInteger(set
->fonts
[i
], FC_SLANT
, 0, &slant
);
1253 if (weight
== FC_WEIGHT_DEMIBOLD
|| weight
== FC_WEIGHT_BOLD
1254 || weight
== FC_WEIGHT_EXTRABOLD
|| weight
== FC_WEIGHT_BLACK
)
1258 if (slant
== FC_SLANT_ITALIC
)
1260 if (slant
== FC_SLANT_OBLIQUE
)
1263 *type
= (!strncasecmp(ext
,".ttc",4)) ? sysFontTTC
: sysFontTTF
;
1264 FcPatternGetInteger(set
->fonts
[i
], FC_INDEX
, 0, fontNum
);
1265 fi
= new SysFontInfo(fontName
->copy(), bold
, italic
, oblique
, font
->isFixedWidth(),
1266 new GooString((char*)s
), *type
, *fontNum
, substituteName
.copy());
1267 sysFonts
->addFcFont(fi
);
1268 path
= new GooString((char*)s
);
1270 else if (!strncasecmp(ext
,".pfa",4) || !strncasecmp(ext
,".pfb",4))
1273 GBool bold
= font
->isBold();
1274 GBool italic
= font
->isItalic();
1275 GBool oblique
= gFalse
;
1276 FcPatternGetInteger(set
->fonts
[i
], FC_WEIGHT
, 0, &weight
);
1277 FcPatternGetInteger(set
->fonts
[i
], FC_SLANT
, 0, &slant
);
1278 if (weight
== FC_WEIGHT_DEMIBOLD
|| weight
== FC_WEIGHT_BOLD
1279 || weight
== FC_WEIGHT_EXTRABOLD
|| weight
== FC_WEIGHT_BLACK
)
1283 if (slant
== FC_SLANT_ITALIC
)
1285 if (slant
== FC_SLANT_OBLIQUE
)
1288 *type
= (!strncasecmp(ext
,".pfa",4)) ? sysFontPFA
: sysFontPFB
;
1289 FcPatternGetInteger(set
->fonts
[i
], FC_INDEX
, 0, fontNum
);
1290 fi
= new SysFontInfo(fontName
->copy(), bold
, italic
, oblique
, font
->isFixedWidth(),
1291 new GooString((char*)s
), *type
, *fontNum
, substituteName
.copy());
1292 sysFonts
->addFcFont(fi
);
1293 path
= new GooString((char*)s
);
1300 FcLangSetDestroy(lb
);
1303 /* scan all fonts of the list */
1307 FcFontSetDestroy(set
);
1309 if (path
== NULL
&& (fi
= sysFonts
->find(fontName
, font
->isFixedWidth(), gFalse
))) {
1310 path
= fi
->path
->copy();
1312 *fontNum
= fi
->fontNum
;
1314 if (substituteFontName
) {
1315 substituteFontName
->Set(substituteName
.getCString());
1319 FcPatternDestroy(p
);
1324 #elif WITH_FONTCONFIGURATION_WIN32
1325 #include "GlobalParamsWin.cc"
1327 GooString
*GlobalParams::findBase14FontFile(GooString
*base14Name
, GfxFont
*font
) {
1328 return findFontFile(base14Name
);
1331 GooString
*GlobalParams::findBase14FontFile(GooString
*base14Name
, GfxFont
*font
) {
1332 return findFontFile(base14Name
);
1337 const char *t1FileName
;
1338 const char *ttFileName
;
1339 } displayFontTab
[] = {
1340 {"Courier", "n022003l.pfb", "cour.ttf"},
1341 {"Courier-Bold", "n022004l.pfb", "courbd.ttf"},
1342 {"Courier-BoldOblique", "n022024l.pfb", "courbi.ttf"},
1343 {"Courier-Oblique", "n022023l.pfb", "couri.ttf"},
1344 {"Helvetica", "n019003l.pfb", "arial.ttf"},
1345 {"Helvetica-Bold", "n019004l.pfb", "arialbd.ttf"},
1346 {"Helvetica-BoldOblique", "n019024l.pfb", "arialbi.ttf"},
1347 {"Helvetica-Oblique", "n019023l.pfb", "ariali.ttf"},
1348 {"Symbol", "s050000l.pfb", NULL
},
1349 {"Times-Bold", "n021004l.pfb", "timesbd.ttf"},
1350 {"Times-BoldItalic", "n021024l.pfb", "timesbi.ttf"},
1351 {"Times-Italic", "n021023l.pfb", "timesi.ttf"},
1352 {"Times-Roman", "n021003l.pfb", "times.ttf"},
1353 {"ZapfDingbats", "d050000l.pfb", NULL
},
1357 static const char *displayFontDirs
[] = {
1358 "/usr/share/ghostscript/fonts",
1359 "/usr/local/share/ghostscript/fonts",
1360 "/usr/share/fonts/default/Type1",
1361 "/usr/share/fonts/default/ghostscript",
1362 "/usr/share/fonts/type1/gsfonts",
1366 void GlobalParams::setupBaseFonts(char *dir
) {
1367 GooString
*fontName
;
1368 GooString
*fileName
;
1372 for (i
= 0; displayFontTab
[i
].name
; ++i
) {
1373 if (fontFiles
->lookup(displayFontTab
[i
].name
)) {
1376 fontName
= new GooString(displayFontTab
[i
].name
);
1379 fileName
= appendToPath(new GooString(dir
), displayFontTab
[i
].t1FileName
);
1380 if ((f
= fopen(fileName
->getCString(), "rb"))) {
1387 for (j
= 0; !fileName
&& displayFontDirs
[j
]; ++j
) {
1388 fileName
= appendToPath(new GooString(displayFontDirs
[j
]),
1389 displayFontTab
[i
].t1FileName
);
1390 if ((f
= fopen(fileName
->getCString(), "rb"))) {
1398 error(errConfig
, -1, "No display font for '{0:s}'",
1399 displayFontTab
[i
].name
);
1403 addFontFile(fontName
, fileName
);
1408 GooString
*GlobalParams::findSystemFontFile(GfxFont
*font
,
1410 int *fontNum
, GooString
* /*substituteFontName*/,
1411 GooString
* /*base14Name*/) {
1417 if ((fi
= sysFonts
->find(font
->getName(), font
->isFixedWidth(), gFalse
))) {
1418 path
= fi
->path
->copy();
1420 *fontNum
= fi
->fontNum
;
1427 GooString
*GlobalParams::findCCFontFile(GooString
*collection
) {
1431 if ((path
= (GooString
*)ccFontFiles
->lookup(collection
))) {
1432 path
= path
->copy();
1439 GBool
GlobalParams::getPSExpandSmaller() {
1443 f
= psExpandSmaller
;
1448 GBool
GlobalParams::getPSShrinkLarger() {
1457 GBool
GlobalParams::getPSCenter() {
1466 PSLevel
GlobalParams::getPSLevel() {
1475 GooString
*GlobalParams::getPSResidentFont(GooString
*fontName
) {
1479 psName
= (GooString
*)psResidentFonts
->lookup(fontName
);
1484 GooList
*GlobalParams::getPSResidentFonts() {
1490 names
= new GooList();
1492 psResidentFonts
->startIter(&iter
);
1493 while (psResidentFonts
->getNext(&iter
, &name
, (void **)&psName
)) {
1494 names
->append(psName
->copy());
1500 PSFontParam16
*GlobalParams::getPSResidentFont16(GooString
*fontName
,
1507 for (i
= 0; i
< psResidentFonts16
->getLength(); ++i
) {
1508 p
= (PSFontParam16
*)psResidentFonts16
->get(i
);
1509 if (!(p
->name
->cmp(fontName
)) && p
->wMode
== wMode
) {
1518 PSFontParam16
*GlobalParams::getPSResidentFontCC(GooString
*collection
,
1525 for (i
= 0; i
< psResidentFontsCC
->getLength(); ++i
) {
1526 p
= (PSFontParam16
*)psResidentFontsCC
->get(i
);
1527 if (!(p
->name
->cmp(collection
)) && p
->wMode
== wMode
) {
1536 GooString
*GlobalParams::getTextEncodingName() {
1540 s
= textEncoding
->copy();
1545 EndOfLineKind
GlobalParams::getTextEOL() {
1554 GBool
GlobalParams::getTextPageBreaks() {
1558 pageBreaks
= textPageBreaks
;
1563 GBool
GlobalParams::getTextKeepTinyChars() {
1567 tiny
= textKeepTinyChars
;
1572 GBool
GlobalParams::getEnableFreeType() {
1581 GBool
GlobalParams::getStrokeAdjust() {
1590 ScreenType
GlobalParams::getScreenType() {
1599 int GlobalParams::getScreenSize() {
1608 int GlobalParams::getScreenDotRadius() {
1612 r
= screenDotRadius
;
1617 double GlobalParams::getScreenGamma() {
1621 gamma
= screenGamma
;
1626 double GlobalParams::getScreenBlackThreshold() {
1630 thresh
= screenBlackThreshold
;
1635 double GlobalParams::getScreenWhiteThreshold() {
1639 thresh
= screenWhiteThreshold
;
1644 double GlobalParams::getMinLineWidth() {
1645 double minLineWidthA
;
1648 minLineWidthA
= minLineWidth
;
1650 return minLineWidthA
;
1653 GBool
GlobalParams::getMapNumericCharNames() {
1657 map
= mapNumericCharNames
;
1662 GBool
GlobalParams::getMapUnknownCharNames() {
1666 map
= mapUnknownCharNames
;
1671 GBool
GlobalParams::getPrintCommands() {
1680 GBool
GlobalParams::getProfileCommands() {
1684 p
= profileCommands
;
1689 GBool
GlobalParams::getErrQuiet() {
1690 // no locking -- this function may get called from inside a locked
1695 CharCodeToUnicode
*GlobalParams::getCIDToUnicode(GooString
*collection
) {
1696 GooString
*fileName
;
1697 CharCodeToUnicode
*ctu
;
1700 if (!(ctu
= cidToUnicodeCache
->getCharCodeToUnicode(collection
))) {
1701 if ((fileName
= (GooString
*)cidToUnicodes
->lookup(collection
)) &&
1702 (ctu
= CharCodeToUnicode::parseCIDToUnicode(fileName
, collection
))) {
1703 cidToUnicodeCache
->add(ctu
);
1710 CharCodeToUnicode
*GlobalParams::getUnicodeToUnicode(GooString
*fontName
) {
1713 unicodeToUnicodes
->startIter(&iter
);
1714 GooString
*fileName
= NULL
;
1715 GooString
*fontPattern
;
1717 while (!fileName
&& unicodeToUnicodes
->getNext(&iter
, &fontPattern
, &val
)) {
1718 if (strstr(fontName
->getCString(), fontPattern
->getCString())) {
1719 unicodeToUnicodes
->killIter(&iter
);
1720 fileName
= (GooString
*)val
;
1723 CharCodeToUnicode
*ctu
= NULL
;
1725 ctu
= unicodeToUnicodeCache
->getCharCodeToUnicode(fileName
);
1727 ctu
= CharCodeToUnicode::parseUnicodeToUnicode(fileName
);
1729 unicodeToUnicodeCache
->add(ctu
);
1736 UnicodeMap
*GlobalParams::getUnicodeMap(GooString
*encodingName
) {
1737 return getUnicodeMap2(encodingName
);
1740 UnicodeMap
*GlobalParams::getUnicodeMap2(GooString
*encodingName
) {
1743 if (!(map
= getResidentUnicodeMap(encodingName
))) {
1744 lockUnicodeMapCache
;
1745 map
= unicodeMapCache
->getUnicodeMap(encodingName
);
1746 unlockUnicodeMapCache
;
1751 CMap
*GlobalParams::getCMap(GooString
*collection
, GooString
*cMapName
, Stream
*stream
) {
1755 cMap
= cMapCache
->getCMap(collection
, cMapName
, stream
);
1760 UnicodeMap
*GlobalParams::getTextEncoding() {
1761 return getUnicodeMap2(textEncoding
);
1764 GooList
*GlobalParams::getEncodingNames()
1766 GooList
*result
= new GooList
;
1770 residentUnicodeMaps
->startIter(&iter
);
1771 while (residentUnicodeMaps
->getNext(&iter
, &key
, &val
)) {
1772 result
->append(key
);
1774 residentUnicodeMaps
->killIter(&iter
);
1775 unicodeMaps
->startIter(&iter
);
1776 while (unicodeMaps
->getNext(&iter
, &key
, &val
)) {
1777 result
->append(key
);
1779 unicodeMaps
->killIter(&iter
);
1783 //------------------------------------------------------------------------
1784 // functions to set parameters
1785 //------------------------------------------------------------------------
1787 void GlobalParams::addFontFile(GooString
*fontName
, GooString
*path
) {
1789 fontFiles
->add(fontName
, path
);
1793 void GlobalParams::setPSFile(char *file
) {
1798 psFile
= new GooString(file
);
1802 void GlobalParams::setPSExpandSmaller(GBool expand
) {
1804 psExpandSmaller
= expand
;
1808 void GlobalParams::setPSShrinkLarger(GBool shrink
) {
1810 psShrinkLarger
= shrink
;
1814 void GlobalParams::setPSCenter(GBool center
) {
1820 void GlobalParams::setPSLevel(PSLevel level
) {
1826 void GlobalParams::setTextEncoding(char *encodingName
) {
1828 delete textEncoding
;
1829 textEncoding
= new GooString(encodingName
);
1833 GBool
GlobalParams::setTextEOL(char *s
) {
1835 if (!strcmp(s
, "unix")) {
1837 } else if (!strcmp(s
, "dos")) {
1839 } else if (!strcmp(s
, "mac")) {
1849 void GlobalParams::setTextPageBreaks(GBool pageBreaks
) {
1851 textPageBreaks
= pageBreaks
;
1855 void GlobalParams::setTextKeepTinyChars(GBool keep
) {
1857 textKeepTinyChars
= keep
;
1861 GBool
GlobalParams::setEnableFreeType(char *s
) {
1865 ok
= parseYesNo2(s
, &enableFreeType
);
1870 GBool
GlobalParams::setDisableFreeTypeHinting(char *s
) {
1874 ok
= parseYesNo2(s
, &disableFreeTypeHinting
);
1879 void GlobalParams::setStrokeAdjust(GBool adjust
)
1882 strokeAdjust
= adjust
;
1886 void GlobalParams::setScreenType(ScreenType st
)
1893 void GlobalParams::setScreenSize(int size
)
1900 void GlobalParams::setScreenDotRadius(int radius
)
1903 screenDotRadius
= radius
;
1907 void GlobalParams::setScreenGamma(double gamma
)
1910 screenGamma
= gamma
;
1914 void GlobalParams::setScreenBlackThreshold(double blackThreshold
)
1917 screenBlackThreshold
= blackThreshold
;
1921 void GlobalParams::setScreenWhiteThreshold(double whiteThreshold
)
1924 screenWhiteThreshold
= whiteThreshold
;
1928 void GlobalParams::setMinLineWidth(double minLineWidthA
)
1931 minLineWidth
= minLineWidthA
;
1935 void GlobalParams::setOverprintPreview(GBool overprintPreviewA
) {
1937 overprintPreview
= overprintPreviewA
;
1941 void GlobalParams::setMapNumericCharNames(GBool map
) {
1943 mapNumericCharNames
= map
;
1947 void GlobalParams::setMapUnknownCharNames(GBool map
) {
1949 mapUnknownCharNames
= map
;
1953 void GlobalParams::setPrintCommands(GBool printCommandsA
) {
1955 printCommands
= printCommandsA
;
1959 void GlobalParams::setProfileCommands(GBool profileCommandsA
) {
1961 profileCommands
= profileCommandsA
;
1965 void GlobalParams::setErrQuiet(GBool errQuietA
) {
1967 errQuiet
= errQuietA
;
1971 void GlobalParams::addSecurityHandler(XpdfSecurityHandler
*handler
) {
1972 #ifdef ENABLE_PLUGINS
1974 securityHandlers
->append(handler
);
1979 XpdfSecurityHandler
*GlobalParams::getSecurityHandler(char *name
) {
1980 #ifdef ENABLE_PLUGINS
1981 XpdfSecurityHandler
*hdlr
;
1985 for (i
= 0; i
< securityHandlers
->getLength(); ++i
) {
1986 hdlr
= (XpdfSecurityHandler
*)securityHandlers
->get(i
);
1987 if (!strcasecmp(hdlr
->name
, name
)) {
1994 if (!loadPlugin("security", name
)) {
1999 for (i
= 0; i
< securityHandlers
->getLength(); ++i
) {
2000 hdlr
= (XpdfSecurityHandler
*)securityHandlers
->get(i
);
2001 if (!strcmp(hdlr
->name
, name
)) {
2014 #ifdef ENABLE_PLUGINS
2015 //------------------------------------------------------------------------
2017 //------------------------------------------------------------------------
2019 GBool
GlobalParams::loadPlugin(char *type
, char *name
) {
2022 if (!(plugin
= Plugin::load(type
, name
))) {
2026 plugins
->append(plugin
);
2031 #endif // ENABLE_PLUGINS