1
//========================================================================
5
// Copyright 2001-2003 Glyph & Cog, LLC
7
//========================================================================
11
#ifdef USE_GCC_PRAGMAS
12
#pragma implementation
35
#include "NameToCharCode.h"
36
#include "CharCodeToUnicode.h"
37
#include "UnicodeMap.h"
39
#include "BuiltinFontTables.h"
40
#include "FontEncodingTables.h"
42
# include "XpdfPluginAPI.h"
44
#include "GlobalParams.h"
47
# define strcasecmp stricmp
51
# define lockGlobalParams gLockMutex(&mutex)
52
# define lockUnicodeMapCache gLockMutex(&unicodeMapCacheMutex)
53
# define lockCMapCache gLockMutex(&cMapCacheMutex)
54
# define unlockGlobalParams gUnlockMutex(&mutex)
55
# define unlockUnicodeMapCache gUnlockMutex(&unicodeMapCacheMutex)
56
# define unlockCMapCache gUnlockMutex(&cMapCacheMutex)
58
# define lockGlobalParams
59
# define lockUnicodeMapCache
60
# define lockCMapCache
61
# define unlockGlobalParams
62
# define unlockUnicodeMapCache
63
# define unlockCMapCache
66
#include "NameToUnicodeTable.h"
67
#include "UnicodeMapTables.h"
72
extern XpdfPluginVecTable xpdfPluginVecTable;
76
//------------------------------------------------------------------------
78
#define cidToUnicodeCacheSize 4
79
#define unicodeToUnicodeCacheSize 4
81
//------------------------------------------------------------------------
85
const char *t1FileName;
86
const char *ttFileName;
87
} displayFontTab[] = {
88
{"Courier", "n022003l.pfb", "cour.ttf"},
89
{"Courier-Bold", "n022004l.pfb", "courbd.ttf"},
90
{"Courier-BoldOblique", "n022024l.pfb", "courbi.ttf"},
91
{"Courier-Oblique", "n022023l.pfb", "couri.ttf"},
92
{"Helvetica", "n019003l.pfb", "arial.ttf"},
93
{"Helvetica-Bold", "n019004l.pfb", "arialbd.ttf"},
94
{"Helvetica-BoldOblique", "n019024l.pfb", "arialbi.ttf"},
95
{"Helvetica-Oblique", "n019023l.pfb", "ariali.ttf"},
96
{"Symbol", "s050000l.pfb", NULL},
97
{"Times-Bold", "n021004l.pfb", "timesbd.ttf"},
98
{"Times-BoldItalic", "n021024l.pfb", "timesbi.ttf"},
99
{"Times-Italic", "n021023l.pfb", "timesi.ttf"},
100
{"Times-Roman", "n021003l.pfb", "times.ttf"},
101
{"ZapfDingbats", "d050000l.pfb", NULL},
106
static const char *displayFontDirs[] = {
112
static const char *displayFontDirs[] = {
113
"/usr/share/ghostscript/fonts",
114
"/usr/local/share/ghostscript/fonts",
115
"/usr/share/fonts/default/Type1",
116
"/usr/share/fonts/default/ghostscript",
117
"/usr/share/fonts/type1/gsfonts",
122
//------------------------------------------------------------------------
124
GlobalParams *globalParams = NULL;
126
//------------------------------------------------------------------------
128
//------------------------------------------------------------------------
130
PSFontParam16::PSFontParam16(GString *nameA, int wModeA,
131
GString *psFontNameA, GString *encodingA) {
134
psFontName = psFontNameA;
135
encoding = encodingA;
138
PSFontParam16::~PSFontParam16() {
144
//------------------------------------------------------------------------
146
//------------------------------------------------------------------------
156
int fontNum; // for TrueType collections
158
SysFontInfo(GString *nameA, GBool boldA, GBool italicA,
159
GString *pathA, SysFontType typeA, int fontNumA);
161
GBool match(SysFontInfo *fi);
162
GBool match(GString *nameA, GBool boldA, GBool italicA);
165
SysFontInfo::SysFontInfo(GString *nameA, GBool boldA, GBool italicA,
166
GString *pathA, SysFontType typeA, int fontNumA) {
175
SysFontInfo::~SysFontInfo() {
180
GBool SysFontInfo::match(SysFontInfo *fi) {
181
return !strcasecmp(name->getCString(), fi->name->getCString()) &&
182
bold == fi->bold && italic == fi->italic;
185
GBool SysFontInfo::match(GString *nameA, GBool boldA, GBool italicA) {
186
return !strcasecmp(name->getCString(), nameA->getCString()) &&
187
bold == boldA && italic == italicA;
190
//------------------------------------------------------------------------
192
//------------------------------------------------------------------------
199
SysFontInfo *find(GString *name);
202
void scanWindowsFonts(char *winFontDir);
208
SysFontInfo *makeWindowsFont(char *name, int fontNum,
212
GList *fonts; // [SysFontInfo]
215
SysFontList::SysFontList() {
219
SysFontList::~SysFontList() {
220
deleteGList(fonts, SysFontInfo);
223
SysFontInfo *SysFontList::find(GString *name) {
230
name2 = name->copy();
232
// remove space, comma, dash chars
234
while (i < name2->getLength()) {
235
c = name2->getChar(i);
236
if (c == ' ' || c == ',' || c == '-') {
242
n = name2->getLength();
244
// remove trailing "MT" (Foo-MT, Foo-BoldMT, etc.)
245
if (n > 2 && !strcmp(name2->getCString() + n - 2, "MT")) {
246
name2->del(n - 2, 2);
250
// look for "Regular"
251
if (n > 7 && !strcmp(name2->getCString() + n - 7, "Regular")) {
252
name2->del(n - 7, 7);
257
if (n > 6 && !strcmp(name2->getCString() + n - 6, "Italic")) {
258
name2->del(n - 6, 6);
266
if (n > 4 && !strcmp(name2->getCString() + n - 4, "Bold")) {
267
name2->del(n - 4, 4);
274
// remove trailing "MT" (FooMT-Bold, etc.)
275
if (n > 2 && !strcmp(name2->getCString() + n - 2, "MT")) {
276
name2->del(n - 2, 2);
280
// remove trailing "PS"
281
if (n > 2 && !strcmp(name2->getCString() + n - 2, "PS")) {
282
name2->del(n - 2, 2);
286
// remove trailing "IdentityH"
287
if (n > 9 && !strcmp(name2->getCString() + n - 9, "IdentityH")) {
288
name2->del(n - 9, 9);
292
// search for the font
294
for (i = 0; i < fonts->getLength(); ++i) {
295
fi = (SysFontInfo *)fonts->get(i);
296
if (fi->match(name2, bold, italic)) {
302
// try ignoring the bold flag
303
for (i = 0; i < fonts->getLength(); ++i) {
304
fi = (SysFontInfo *)fonts->get(i);
305
if (fi->match(name2, gFalse, italic)) {
311
if (!fi && (bold || italic)) {
312
// try ignoring the bold and italic flags
313
for (i = 0; i < fonts->getLength(); ++i) {
314
fi = (SysFontInfo *)fonts->get(i);
315
if (fi->match(name2, gFalse, gFalse)) {
327
void SysFontList::scanWindowsFonts(char *winFontDir) {
328
OSVERSIONINFO version;
330
DWORD idx, valNameLen, dataLen, type;
332
char valName[1024], data[1024];
337
version.dwOSVersionInfoSize = sizeof(version);
338
GetVersionEx(&version);
339
if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
340
path = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts\\";
342
path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Fonts\\";
344
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, path, 0,
345
KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
346
®Key) == ERROR_SUCCESS) {
349
valNameLen = sizeof(valName) - 1;
350
dataLen = sizeof(data) - 1;
351
if (RegEnumValue(regKey, idx, valName, &valNameLen, NULL,
352
&type, (LPBYTE)data, &dataLen) != ERROR_SUCCESS) {
355
if (type == REG_SZ &&
356
valNameLen > 0 && valNameLen < sizeof(valName) &&
357
dataLen > 0 && dataLen < sizeof(data)) {
358
valName[valNameLen] = '\0';
359
data[dataLen] = '\0';
361
if (!strcasecmp(data + n - 4, ".ttf") ||
362
!strcasecmp(data + n - 4, ".ttc")) {
363
fontPath = new GString(data);
364
if (!(dataLen >= 3 && data[1] == ':' && data[2] == '\\')) {
365
fontPath->insert(0, '\\');
366
fontPath->insert(0, winFontDir);
371
p1 = strstr(p0, " & ");
376
p1 = p0 + strlen(p0);
378
fonts->append(makeWindowsFont(p0, fontNum,
379
fontPath->getCString()));
392
SysFontInfo *SysFontList::makeWindowsFont(char *name, int fontNum,
402
bold = italic = gFalse;
404
// remove trailing ' (TrueType)'
405
if (n > 11 && !strncmp(name + n - 11, " (TrueType)", 11)) {
409
// remove trailing ' Italic'
410
if (n > 7 && !strncmp(name + n - 7, " Italic", 7)) {
415
// remove trailing ' Bold'
416
if (n > 5 && !strncmp(name + n - 5, " Bold", 5)) {
421
// remove trailing ' Regular'
422
if (n > 5 && !strncmp(name + n - 8, " Regular", 8)) {
426
//----- normalize the font name
427
s = new GString(name, n);
429
while (i < s->getLength()) {
431
if (c == ' ' || c == ',' || c == '-') {
438
if (!strcasecmp(path + strlen(path) - 4, ".ttc")) {
443
return new SysFontInfo(s, bold, italic, new GString(path), type, fontNum);
447
//------------------------------------------------------------------------
449
//------------------------------------------------------------------------
451
KeyBinding::KeyBinding(int codeA, int modsA, int contextA, const char *cmd0) {
456
cmds->append(new GString(cmd0));
459
KeyBinding::KeyBinding(int codeA, int modsA, int contextA,
460
const char *cmd0, const char *cmd1) {
465
cmds->append(new GString(cmd0));
466
cmds->append(new GString(cmd1));
469
KeyBinding::KeyBinding(int codeA, int modsA, int contextA, GList *cmdsA) {
476
KeyBinding::~KeyBinding() {
477
deleteGList(cmds, GString);
480
#ifdef ENABLE_PLUGINS
481
//------------------------------------------------------------------------
483
//------------------------------------------------------------------------
488
static Plugin *load(char *type, char *name);
494
Plugin(HMODULE libA);
502
Plugin *Plugin::load(char *type, char *name) {
505
XpdfPluginVecTable *vt;
506
XpdfBool (*xpdfInitPlugin)(void);
513
path = globalParams->getBaseDir();
514
appendToPath(path, "plugins");
515
appendToPath(path, type);
516
appendToPath(path, name);
519
path->append(".dll");
520
if (!(libA = LoadLibrary(path->getCString()))) {
521
error(errIO, -1, "Failed to load plugin '{0:t}'", path);
524
if (!(vt = (XpdfPluginVecTable *)
525
GetProcAddress(libA, "xpdfPluginVecTable"))) {
526
error(errIO, -1, "Failed to find xpdfPluginVecTable in plugin '{0:t}'",
531
//~ need to deal with other extensions here
533
if (!(dlA = dlopen(path->getCString(), RTLD_NOW))) {
534
error(errIO, -1, "Failed to load plugin '{0:t}': {1:s}",
538
if (!(vt = (XpdfPluginVecTable *)dlsym(dlA, "xpdfPluginVecTable"))) {
539
error(errIO, -1, "Failed to find xpdfPluginVecTable in plugin '{0:t}'",
545
if (vt->version != xpdfPluginVecTable.version) {
546
error(errIO, -1, "Plugin '{0:t}' is wrong version", path);
549
memcpy(vt, &xpdfPluginVecTable, sizeof(xpdfPluginVecTable));
552
if (!(xpdfInitPlugin = (XpdfBool (*)(void))
553
GetProcAddress(libA, "xpdfInitPlugin"))) {
554
error(errIO, -1, "Failed to find xpdfInitPlugin in plugin '{0:t}'",
559
if (!(xpdfInitPlugin = (XpdfBool (*)(void))dlsym(dlA, "xpdfInitPlugin"))) {
560
error(errIO, -1, "Failed to find xpdfInitPlugin in plugin '{0:t}'",
566
if (!(*xpdfInitPlugin)()) {
567
error(errIO, -1, "Initialization of plugin '{0:t}' failed", path);
572
plugin = new Plugin(libA);
574
plugin = new Plugin(dlA);
592
Plugin::Plugin(HMODULE libA) {
596
Plugin::Plugin(void *dlA) {
602
void (*xpdfFreePlugin)(void);
605
if ((xpdfFreePlugin = (void (*)(void))
606
GetProcAddress(lib, "xpdfFreePlugin"))) {
611
if ((xpdfFreePlugin = (void (*)(void))dlsym(dl, "xpdfFreePlugin"))) {
618
#endif // ENABLE_PLUGINS
620
//------------------------------------------------------------------------
622
//------------------------------------------------------------------------
624
GlobalParams::GlobalParams(char *cfgFileName) {
632
gInitMutex(&unicodeMapCacheMutex);
633
gInitMutex(&cMapCacheMutex);
636
initBuiltinFontTables();
638
// scan the encoding in reverse because we want the lowest-numbered
639
// index for each char name ('space' is encoded twice)
640
macRomanReverseMap = new NameToCharCode();
641
for (i = 255; i >= 0; --i) {
642
if (macRomanEncoding[i]) {
643
macRomanReverseMap->add(macRomanEncoding[i], (CharCode)i);
648
// baseDir will be set by a call to setBaseDir
649
baseDir = new GString();
651
baseDir = appendToPath(getHomeDir(), ".xpdf");
653
nameToUnicode = new NameToCharCode();
654
cidToUnicodes = new GHash(gTrue);
655
unicodeToUnicodes = new GHash(gTrue);
656
residentUnicodeMaps = new GHash();
657
unicodeMaps = new GHash(gTrue);
658
cMapDirs = new GHash(gTrue);
659
toUnicodeDirs = new GList();
660
fontFiles = new GHash(gTrue);
661
fontDirs = new GList();
662
ccFontFiles = new GHash(gTrue);
663
sysFonts = new SysFontList();
666
const struct paper *paperType;
668
if ((paperName = systempapername())) {
669
paperType = paperinfo(paperName);
670
psPaperWidth = (int)paperpswidth(paperType);
671
psPaperHeight = (int)paperpsheight(paperType);
673
error(errConfig, -1, "No paper information available - using defaults");
674
psPaperWidth = defPaperWidth;
675
psPaperHeight = defPaperHeight;
679
psPaperWidth = defPaperWidth;
680
psPaperHeight = defPaperHeight;
682
psImageableLLX = psImageableLLY = 0;
683
psImageableURX = psPaperWidth;
684
psImageableURY = psPaperHeight;
686
psExpandSmaller = gFalse;
687
psShrinkLarger = gTrue;
692
psResidentFonts = new GHash(gTrue);
693
psResidentFonts16 = new GList();
694
psResidentFontsCC = new GList();
695
psEmbedType1 = gTrue;
696
psEmbedTrueType = gTrue;
697
psEmbedCIDPostScript = gTrue;
698
psEmbedCIDTrueType = gTrue;
699
psFontPassthrough = gFalse;
703
psUncompressPreloadedImages = gFalse;
704
psRasterResolution = 300;
705
psRasterMono = gFalse;
706
psAlwaysRasterize = gFalse;
707
textEncoding = new GString("Latin1");
715
textPageBreaks = gTrue;
716
textKeepTinyChars = gFalse;
717
initialZoom = new GString("125");
718
continuousView = gFalse;
720
enableFreeType = gTrue;
721
disableFreeTypeHinting = gFalse;
723
vectorAntialias = gTrue;
724
antialiasPrinting = gFalse;
725
strokeAdjust = gTrue;
726
screenType = screenUnset;
728
screenDotRadius = -1;
730
screenBlackThreshold = 0.0;
731
screenWhiteThreshold = 1.0;
733
drawAnnotations = gTrue;
734
overprintPreview = gFalse;
735
launchCommand = NULL;
738
mapNumericCharNames = gTrue;
739
mapUnknownCharNames = gFalse;
740
createDefaultKeyBindings();
741
printCommands = gFalse;
744
cidToUnicodeCache = new CharCodeToUnicodeCache(cidToUnicodeCacheSize);
745
unicodeToUnicodeCache =
746
new CharCodeToUnicodeCache(unicodeToUnicodeCacheSize);
747
unicodeMapCache = new UnicodeMapCache();
748
cMapCache = new CMapCache();
750
#ifdef ENABLE_PLUGINS
751
plugins = new GList();
752
securityHandlers = new GList();
755
// set up the initial nameToUnicode table
756
for (i = 0; nameToUnicodeTab[i].name; ++i) {
757
nameToUnicode->add(nameToUnicodeTab[i].name, nameToUnicodeTab[i].u);
760
// set up the residentUnicodeMaps table
761
map = new UnicodeMap("Latin1", gFalse,
762
latin1UnicodeMapRanges, latin1UnicodeMapLen);
763
residentUnicodeMaps->add(map->getEncodingName(), map);
764
map = new UnicodeMap("ASCII7", gFalse,
765
ascii7UnicodeMapRanges, ascii7UnicodeMapLen);
766
residentUnicodeMaps->add(map->getEncodingName(), map);
767
map = new UnicodeMap("Symbol", gFalse,
768
symbolUnicodeMapRanges, symbolUnicodeMapLen);
769
residentUnicodeMaps->add(map->getEncodingName(), map);
770
map = new UnicodeMap("ZapfDingbats", gFalse, zapfDingbatsUnicodeMapRanges,
771
zapfDingbatsUnicodeMapLen);
772
residentUnicodeMaps->add(map->getEncodingName(), map);
773
map = new UnicodeMap("UTF-8", gTrue, &mapUTF8);
774
residentUnicodeMaps->add(map->getEncodingName(), map);
775
map = new UnicodeMap("UCS-2", gTrue, &mapUCS2);
776
residentUnicodeMaps->add(map->getEncodingName(), map);
778
// look for a user config file, then a system-wide config file
781
if (cfgFileName && cfgFileName[0]) {
782
fileName = new GString(cfgFileName);
783
if (!(f = fopen(fileName->getCString(), "r"))) {
788
fileName = appendToPath(getHomeDir(), xpdfUserConfigFile);
789
if (!(f = fopen(fileName->getCString(), "r"))) {
796
i = GetModuleFileName(NULL, buf, sizeof(buf));
797
if (i <= 0 || i >= sizeof(buf)) {
798
// error or path too long for buffer - just use the current dir
801
fileName = grabPath(buf);
802
appendToPath(fileName, xpdfSysConfigFile);
804
fileName = new GString(xpdfSysConfigFile);
806
if (!(f = fopen(fileName->getCString(), "r"))) {
811
parseFile(fileName, f);
817
void GlobalParams::createDefaultKeyBindings() {
818
keyBindings = new GList();
820
//----- mouse buttons
821
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress1, xpdfKeyModNone,
822
xpdfKeyContextAny, "startSelection"));
823
keyBindings->append(new KeyBinding(xpdfKeyCodeMouseRelease1, xpdfKeyModNone,
824
xpdfKeyContextAny, "endSelection",
826
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress2, xpdfKeyModNone,
827
xpdfKeyContextAny, "startPan"));
828
keyBindings->append(new KeyBinding(xpdfKeyCodeMouseRelease2, xpdfKeyModNone,
829
xpdfKeyContextAny, "endPan"));
830
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress3, xpdfKeyModNone,
831
xpdfKeyContextAny, "postPopupMenu"));
832
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress4, xpdfKeyModNone,
834
"scrollUpPrevPage(16)"));
835
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress5, xpdfKeyModNone,
837
"scrollDownNextPage(16)"));
838
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress6, xpdfKeyModNone,
839
xpdfKeyContextAny, "scrollLeft(16)"));
840
keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress7, xpdfKeyModNone,
841
xpdfKeyContextAny, "scrollRight(16)"));
844
keyBindings->append(new KeyBinding(xpdfKeyCodeHome, xpdfKeyModCtrl,
845
xpdfKeyContextAny, "gotoPage(1)"));
846
keyBindings->append(new KeyBinding(xpdfKeyCodeHome, xpdfKeyModNone,
847
xpdfKeyContextAny, "scrollToTopLeft"));
848
keyBindings->append(new KeyBinding(xpdfKeyCodeEnd, xpdfKeyModCtrl,
849
xpdfKeyContextAny, "gotoLastPage"));
850
keyBindings->append(new KeyBinding(xpdfKeyCodeEnd, xpdfKeyModNone,
852
"scrollToBottomRight"));
853
keyBindings->append(new KeyBinding(xpdfKeyCodePgUp, xpdfKeyModNone,
854
xpdfKeyContextAny, "pageUp"));
855
keyBindings->append(new KeyBinding(xpdfKeyCodeBackspace, xpdfKeyModNone,
856
xpdfKeyContextAny, "pageUp"));
857
keyBindings->append(new KeyBinding(xpdfKeyCodeDelete, xpdfKeyModNone,
858
xpdfKeyContextAny, "pageUp"));
859
keyBindings->append(new KeyBinding(xpdfKeyCodePgDn, xpdfKeyModNone,
860
xpdfKeyContextAny, "pageDown"));
861
keyBindings->append(new KeyBinding(' ', xpdfKeyModNone,
862
xpdfKeyContextAny, "pageDown"));
863
keyBindings->append(new KeyBinding(xpdfKeyCodeLeft, xpdfKeyModNone,
864
xpdfKeyContextAny, "scrollLeft(16)"));
865
keyBindings->append(new KeyBinding(xpdfKeyCodeRight, xpdfKeyModNone,
866
xpdfKeyContextAny, "scrollRight(16)"));
867
keyBindings->append(new KeyBinding(xpdfKeyCodeUp, xpdfKeyModNone,
868
xpdfKeyContextAny, "scrollUp(16)"));
869
keyBindings->append(new KeyBinding(xpdfKeyCodeDown, xpdfKeyModNone,
870
xpdfKeyContextAny, "scrollDown(16)"));
871
keyBindings->append(new KeyBinding('o', xpdfKeyModNone,
872
xpdfKeyContextAny, "open"));
873
keyBindings->append(new KeyBinding('O', xpdfKeyModNone,
874
xpdfKeyContextAny, "open"));
875
keyBindings->append(new KeyBinding('r', xpdfKeyModNone,
876
xpdfKeyContextAny, "reload"));
877
keyBindings->append(new KeyBinding('R', xpdfKeyModNone,
878
xpdfKeyContextAny, "reload"));
879
keyBindings->append(new KeyBinding('f', xpdfKeyModNone,
880
xpdfKeyContextAny, "find"));
881
keyBindings->append(new KeyBinding('F', xpdfKeyModNone,
882
xpdfKeyContextAny, "find"));
883
keyBindings->append(new KeyBinding('f', xpdfKeyModCtrl,
884
xpdfKeyContextAny, "find"));
885
keyBindings->append(new KeyBinding('g', xpdfKeyModCtrl,
886
xpdfKeyContextAny, "findNext"));
887
keyBindings->append(new KeyBinding('p', xpdfKeyModCtrl,
888
xpdfKeyContextAny, "print"));
889
keyBindings->append(new KeyBinding('n', xpdfKeyModNone,
890
xpdfKeyContextScrLockOff, "nextPage"));
891
keyBindings->append(new KeyBinding('N', xpdfKeyModNone,
892
xpdfKeyContextScrLockOff, "nextPage"));
893
keyBindings->append(new KeyBinding('n', xpdfKeyModNone,
894
xpdfKeyContextScrLockOn,
895
"nextPageNoScroll"));
896
keyBindings->append(new KeyBinding('N', xpdfKeyModNone,
897
xpdfKeyContextScrLockOn,
898
"nextPageNoScroll"));
899
keyBindings->append(new KeyBinding('p', xpdfKeyModNone,
900
xpdfKeyContextScrLockOff, "prevPage"));
901
keyBindings->append(new KeyBinding('P', xpdfKeyModNone,
902
xpdfKeyContextScrLockOff, "prevPage"));
903
keyBindings->append(new KeyBinding('p', xpdfKeyModNone,
904
xpdfKeyContextScrLockOn,
905
"prevPageNoScroll"));
906
keyBindings->append(new KeyBinding('P', xpdfKeyModNone,
907
xpdfKeyContextScrLockOn,
908
"prevPageNoScroll"));
909
keyBindings->append(new KeyBinding('v', xpdfKeyModNone,
910
xpdfKeyContextAny, "goForward"));
911
keyBindings->append(new KeyBinding('b', xpdfKeyModNone,
912
xpdfKeyContextAny, "goBackward"));
913
keyBindings->append(new KeyBinding('g', xpdfKeyModNone,
914
xpdfKeyContextAny, "focusToPageNum"));
915
keyBindings->append(new KeyBinding('0', xpdfKeyModNone,
916
xpdfKeyContextAny, "zoomPercent(125)"));
917
keyBindings->append(new KeyBinding('+', xpdfKeyModNone,
918
xpdfKeyContextAny, "zoomIn"));
919
keyBindings->append(new KeyBinding('-', xpdfKeyModNone,
920
xpdfKeyContextAny, "zoomOut"));
921
keyBindings->append(new KeyBinding('z', xpdfKeyModNone,
922
xpdfKeyContextAny, "zoomFitPage"));
923
keyBindings->append(new KeyBinding('w', xpdfKeyModNone,
924
xpdfKeyContextAny, "zoomFitWidth"));
925
keyBindings->append(new KeyBinding('h', xpdfKeyModNone,
926
xpdfKeyContextAny, "zoomFitHeight"));
927
keyBindings->append(new KeyBinding('f', xpdfKeyModAlt,
929
"toggleFullScreenMode"));
930
keyBindings->append(new KeyBinding('l', xpdfKeyModCtrl,
931
xpdfKeyContextAny, "redraw"));
932
keyBindings->append(new KeyBinding('w', xpdfKeyModCtrl,
933
xpdfKeyContextAny, "closeWindow"));
934
keyBindings->append(new KeyBinding('?', xpdfKeyModNone,
935
xpdfKeyContextAny, "about"));
936
keyBindings->append(new KeyBinding('q', xpdfKeyModNone,
937
xpdfKeyContextAny, "quit"));
938
keyBindings->append(new KeyBinding('Q', xpdfKeyModNone,
939
xpdfKeyContextAny, "quit"));
942
void GlobalParams::parseFile(GString *fileName, FILE *f) {
947
while (getLine(buf, sizeof(buf) - 1, f)) {
948
parseLine(buf, fileName, line);
953
void GlobalParams::parseLine(char *buf, GString *fileName, int line) {
955
GString *cmd, *incFile;
959
// break the line into tokens
960
tokens = new GList();
963
for (; *p1 && isspace(*p1); ++p1) ;
967
if (*p1 == '"' || *p1 == '\'') {
968
for (p2 = p1 + 1; *p2 && *p2 != *p1; ++p2) ;
971
for (p2 = p1 + 1; *p2 && !isspace(*p2); ++p2) ;
973
tokens->append(new GString(p1, (int)(p2 - p1)));
974
p1 = *p2 ? p2 + 1 : p2;
978
if (tokens->getLength() > 0 &&
979
((GString *)tokens->get(0))->getChar(0) != '#') {
980
cmd = (GString *)tokens->get(0);
981
if (!cmd->cmp("include")) {
982
if (tokens->getLength() == 2) {
983
incFile = (GString *)tokens->get(1);
984
if ((f2 = openFile(incFile->getCString(), "r"))) {
985
parseFile(incFile, f2);
989
"Couldn't find included config file: '{0:t}' ({1:t}:{2:d})",
990
incFile, fileName, line);
993
error(errConfig, -1, "Bad 'include' config file command ({0:t}:{1:d})",
996
} else if (!cmd->cmp("nameToUnicode")) {
997
parseNameToUnicode(tokens, fileName, line);
998
} else if (!cmd->cmp("cidToUnicode")) {
999
parseCIDToUnicode(tokens, fileName, line);
1000
} else if (!cmd->cmp("unicodeToUnicode")) {
1001
parseUnicodeToUnicode(tokens, fileName, line);
1002
} else if (!cmd->cmp("unicodeMap")) {
1003
parseUnicodeMap(tokens, fileName, line);
1004
} else if (!cmd->cmp("cMapDir")) {
1005
parseCMapDir(tokens, fileName, line);
1006
} else if (!cmd->cmp("toUnicodeDir")) {
1007
parseToUnicodeDir(tokens, fileName, line);
1008
} else if (!cmd->cmp("fontFile")) {
1009
parseFontFile(tokens, fileName, line);
1010
} else if (!cmd->cmp("fontDir")) {
1011
parseFontDir(tokens, fileName, line);
1012
} else if (!cmd->cmp("fontFileCC")) {
1013
parseFontFileCC(tokens, fileName, line);
1014
} else if (!cmd->cmp("psFile")) {
1015
parsePSFile(tokens, fileName, line);
1016
} else if (!cmd->cmp("psPaperSize")) {
1017
parsePSPaperSize(tokens, fileName, line);
1018
} else if (!cmd->cmp("psImageableArea")) {
1019
parsePSImageableArea(tokens, fileName, line);
1020
} else if (!cmd->cmp("psCrop")) {
1021
parseYesNo("psCrop", &psCrop, tokens, fileName, line);
1022
} else if (!cmd->cmp("psExpandSmaller")) {
1023
parseYesNo("psExpandSmaller", &psExpandSmaller,
1024
tokens, fileName, line);
1025
} else if (!cmd->cmp("psShrinkLarger")) {
1026
parseYesNo("psShrinkLarger", &psShrinkLarger, tokens, fileName, line);
1027
} else if (!cmd->cmp("psCenter")) {
1028
parseYesNo("psCenter", &psCenter, tokens, fileName, line);
1029
} else if (!cmd->cmp("psDuplex")) {
1030
parseYesNo("psDuplex", &psDuplex, tokens, fileName, line);
1031
} else if (!cmd->cmp("psLevel")) {
1032
parsePSLevel(tokens, fileName, line);
1033
} else if (!cmd->cmp("psResidentFont")) {
1034
parsePSResidentFont(tokens, fileName, line);
1035
} else if (!cmd->cmp("psResidentFont16")) {
1036
parsePSResidentFont16(tokens, fileName, line);
1037
} else if (!cmd->cmp("psResidentFontCC")) {
1038
parsePSResidentFontCC(tokens, fileName, line);
1039
} else if (!cmd->cmp("psEmbedType1Fonts")) {
1040
parseYesNo("psEmbedType1", &psEmbedType1, tokens, fileName, line);
1041
} else if (!cmd->cmp("psEmbedTrueTypeFonts")) {
1042
parseYesNo("psEmbedTrueType", &psEmbedTrueType,
1043
tokens, fileName, line);
1044
} else if (!cmd->cmp("psEmbedCIDPostScriptFonts")) {
1045
parseYesNo("psEmbedCIDPostScript", &psEmbedCIDPostScript,
1046
tokens, fileName, line);
1047
} else if (!cmd->cmp("psEmbedCIDTrueTypeFonts")) {
1048
parseYesNo("psEmbedCIDTrueType", &psEmbedCIDTrueType,
1049
tokens, fileName, line);
1050
} else if (!cmd->cmp("psFontPassthrough")) {
1051
parseYesNo("psFontPassthrough", &psFontPassthrough,
1052
tokens, fileName, line);
1053
} else if (!cmd->cmp("psPreload")) {
1054
parseYesNo("psPreload", &psPreload, tokens, fileName, line);
1055
} else if (!cmd->cmp("psOPI")) {
1056
parseYesNo("psOPI", &psOPI, tokens, fileName, line);
1057
} else if (!cmd->cmp("psASCIIHex")) {
1058
parseYesNo("psASCIIHex", &psASCIIHex, tokens, fileName, line);
1059
} else if (!cmd->cmp("psUncompressPreloadedImages")) {
1060
parseYesNo("psUncompressPreloadedImages", &psUncompressPreloadedImages,
1061
tokens, fileName, line);
1062
} else if (!cmd->cmp("psRasterResolution")) {
1063
parseFloat("psRasterResolution", &psRasterResolution,
1064
tokens, fileName, line);
1065
} else if (!cmd->cmp("psRasterMono")) {
1066
parseYesNo("psRasterMono", &psRasterMono, tokens, fileName, line);
1067
} else if (!cmd->cmp("psAlwaysRasterize")) {
1068
parseYesNo("psAlwaysRasterize", &psAlwaysRasterize,
1069
tokens, fileName, line);
1070
} else if (!cmd->cmp("textEncoding")) {
1071
parseTextEncoding(tokens, fileName, line);
1072
} else if (!cmd->cmp("textEOL")) {
1073
parseTextEOL(tokens, fileName, line);
1074
} else if (!cmd->cmp("textPageBreaks")) {
1075
parseYesNo("textPageBreaks", &textPageBreaks,
1076
tokens, fileName, line);
1077
} else if (!cmd->cmp("textKeepTinyChars")) {
1078
parseYesNo("textKeepTinyChars", &textKeepTinyChars,
1079
tokens, fileName, line);
1080
} else if (!cmd->cmp("initialZoom")) {
1081
parseInitialZoom(tokens, fileName, line);
1082
} else if (!cmd->cmp("continuousView")) {
1083
parseYesNo("continuousView", &continuousView, tokens, fileName, line);
1084
} else if (!cmd->cmp("enableT1lib")) {
1085
parseYesNo("enableT1lib", &enableT1lib, tokens, fileName, line);
1086
} else if (!cmd->cmp("enableFreeType")) {
1087
parseYesNo("enableFreeType", &enableFreeType, tokens, fileName, line);
1088
} else if (!cmd->cmp("disableFreeTypeHinting")) {
1089
parseYesNo("disableFreeTypeHinting", &disableFreeTypeHinting,
1090
tokens, fileName, line);
1091
} else if (!cmd->cmp("antialias")) {
1092
parseYesNo("antialias", &antialias, tokens, fileName, line);
1093
} else if (!cmd->cmp("vectorAntialias")) {
1094
parseYesNo("vectorAntialias", &vectorAntialias,
1095
tokens, fileName, line);
1096
} else if (!cmd->cmp("antialiasPrinting")) {
1097
parseYesNo("antialiasPrinting", &antialiasPrinting,
1098
tokens, fileName, line);
1099
} else if (!cmd->cmp("strokeAdjust")) {
1100
parseYesNo("strokeAdjust", &strokeAdjust, tokens, fileName, line);
1101
} else if (!cmd->cmp("screenType")) {
1102
parseScreenType(tokens, fileName, line);
1103
} else if (!cmd->cmp("screenSize")) {
1104
parseInteger("screenSize", &screenSize, tokens, fileName, line);
1105
} else if (!cmd->cmp("screenDotRadius")) {
1106
parseInteger("screenDotRadius", &screenDotRadius,
1107
tokens, fileName, line);
1108
} else if (!cmd->cmp("screenGamma")) {
1109
parseFloat("screenGamma", &screenGamma,
1110
tokens, fileName, line);
1111
} else if (!cmd->cmp("screenBlackThreshold")) {
1112
parseFloat("screenBlackThreshold", &screenBlackThreshold,
1113
tokens, fileName, line);
1114
} else if (!cmd->cmp("screenWhiteThreshold")) {
1115
parseFloat("screenWhiteThreshold", &screenWhiteThreshold,
1116
tokens, fileName, line);
1117
} else if (!cmd->cmp("minLineWidth")) {
1118
parseFloat("minLineWidth", &minLineWidth,
1119
tokens, fileName, line);
1120
} else if (!cmd->cmp("drawAnnotations")) {
1121
parseYesNo("drawAnnotations", &drawAnnotations,
1122
tokens, fileName, line);
1123
} else if (!cmd->cmp("overprintPreview")) {
1124
parseYesNo("overprintPreview", &overprintPreview,
1125
tokens, fileName, line);
1126
} else if (!cmd->cmp("launchCommand")) {
1127
parseCommand("launchCommand", &launchCommand, tokens, fileName, line);
1128
} else if (!cmd->cmp("urlCommand")) {
1129
parseCommand("urlCommand", &urlCommand, tokens, fileName, line);
1130
} else if (!cmd->cmp("movieCommand")) {
1131
parseCommand("movieCommand", &movieCommand, tokens, fileName, line);
1132
} else if (!cmd->cmp("mapNumericCharNames")) {
1133
parseYesNo("mapNumericCharNames", &mapNumericCharNames,
1134
tokens, fileName, line);
1135
} else if (!cmd->cmp("mapUnknownCharNames")) {
1136
parseYesNo("mapUnknownCharNames", &mapUnknownCharNames,
1137
tokens, fileName, line);
1138
} else if (!cmd->cmp("bind")) {
1139
parseBind(tokens, fileName, line);
1140
} else if (!cmd->cmp("unbind")) {
1141
parseUnbind(tokens, fileName, line);
1142
} else if (!cmd->cmp("printCommands")) {
1143
parseYesNo("printCommands", &printCommands, tokens, fileName, line);
1144
} else if (!cmd->cmp("errQuiet")) {
1145
parseYesNo("errQuiet", &errQuiet, tokens, fileName, line);
1147
error(errConfig, -1, "Unknown config file command '{0:t}' ({1:t}:{2:d})",
1148
cmd, fileName, line);
1149
if (!cmd->cmp("displayFontX") ||
1150
!cmd->cmp("displayNamedCIDFontX") ||
1151
!cmd->cmp("displayCIDFontX")) {
1152
error(errConfig, -1, "Xpdf no longer supports X fonts");
1153
} else if (!cmd->cmp("t1libControl") || !cmd->cmp("freetypeControl")) {
1154
error(errConfig, -1,
1155
"The t1libControl and freetypeControl options have been replaced by the enableT1lib, enableFreeType, and antialias options");
1156
} else if (!cmd->cmp("fontpath") || !cmd->cmp("fontmap")) {
1157
error(errConfig, -1,
1158
"The config file format has changed since Xpdf 0.9x");
1163
deleteGList(tokens, GString);
1166
void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
1175
if (tokens->getLength() != 2) {
1176
error(errConfig, -1,
1177
"Bad 'nameToUnicode' config file command ({0:t}:{1:d})",
1181
name = (GString *)tokens->get(1);
1182
if (!(f = openFile(name->getCString(), "r"))) {
1183
error(errConfig, -1, "Couldn't open 'nameToUnicode' file '{0:t}'", name);
1187
while (getLine(buf, sizeof(buf), f)) {
1188
tok1 = strtok(buf, " \t\r\n");
1189
tok2 = strtok(NULL, " \t\r\n");
1191
sscanf(tok1, "%x", &u);
1192
nameToUnicode->add(tok2, u);
1194
error(errConfig, -1, "Bad line in 'nameToUnicode' file ({0:t}:{1:d})",
1202
void GlobalParams::parseCIDToUnicode(GList *tokens, GString *fileName,
1204
GString *collection, *name, *old;
1206
if (tokens->getLength() != 3) {
1207
error(errConfig, -1,
1208
"Bad 'cidToUnicode' config file command ({0:t}:{1:d})",
1212
collection = (GString *)tokens->get(1);
1213
name = (GString *)tokens->get(2);
1214
if ((old = (GString *)cidToUnicodes->remove(collection))) {
1217
cidToUnicodes->add(collection->copy(), name->copy());
1220
void GlobalParams::parseUnicodeToUnicode(GList *tokens, GString *fileName,
1222
GString *font, *file, *old;
1224
if (tokens->getLength() != 3) {
1225
error(errConfig, -1,
1226
"Bad 'unicodeToUnicode' config file command ({0:t}:{1:d})",
1230
font = (GString *)tokens->get(1);
1231
file = (GString *)tokens->get(2);
1232
if ((old = (GString *)unicodeToUnicodes->remove(font))) {
1235
unicodeToUnicodes->add(font->copy(), file->copy());
1238
void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
1240
GString *encodingName, *name, *old;
1242
if (tokens->getLength() != 3) {
1243
error(errConfig, -1, "Bad 'unicodeMap' config file command ({0:t}:{1:d})",
1247
encodingName = (GString *)tokens->get(1);
1248
name = (GString *)tokens->get(2);
1249
if ((old = (GString *)unicodeMaps->remove(encodingName))) {
1252
unicodeMaps->add(encodingName->copy(), name->copy());
1255
void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
1256
GString *collection, *dir;
1259
if (tokens->getLength() != 3) {
1260
error(errConfig, -1, "Bad 'cMapDir' config file command ({0:t}:{1:d})",
1264
collection = (GString *)tokens->get(1);
1265
dir = (GString *)tokens->get(2);
1266
if (!(list = (GList *)cMapDirs->lookup(collection))) {
1268
cMapDirs->add(collection->copy(), list);
1270
list->append(dir->copy());
1273
void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
1275
if (tokens->getLength() != 2) {
1276
error(errConfig, -1,
1277
"Bad 'toUnicodeDir' config file command ({0:t}:{1:d})",
1281
toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
1284
void GlobalParams::parseFontFile(GList *tokens, GString *fileName, int line) {
1285
if (tokens->getLength() != 3) {
1286
error(errConfig, -1, "Bad 'fontFile' config file command ({0:t}:{1:d})",
1290
fontFiles->add(((GString *)tokens->get(1))->copy(),
1291
((GString *)tokens->get(2))->copy());
1294
void GlobalParams::parseFontDir(GList *tokens, GString *fileName, int line) {
1295
if (tokens->getLength() != 2) {
1296
error(errConfig, -1, "Bad 'fontDir' config file command ({0:t}:{1:d})",
1300
fontDirs->append(((GString *)tokens->get(1))->copy());
1303
void GlobalParams::parseFontFileCC(GList *tokens, GString *fileName,
1305
if (tokens->getLength() != 3) {
1306
error(errConfig, -1, "Bad 'fontFileCC' config file command ({0:t}:{1:d})",
1310
ccFontFiles->add(((GString *)tokens->get(1))->copy(),
1311
((GString *)tokens->get(2))->copy());
1314
void GlobalParams::parsePSFile(GList *tokens, GString *fileName, int line) {
1315
if (tokens->getLength() != 2) {
1316
error(errConfig, -1, "Bad 'psFile' config file command ({0:t}:{1:d})",
1323
psFile = ((GString *)tokens->get(1))->copy();
1326
void GlobalParams::parsePSPaperSize(GList *tokens, GString *fileName,
1330
if (tokens->getLength() == 2) {
1331
tok = (GString *)tokens->get(1);
1332
if (!setPSPaperSize(tok->getCString())) {
1333
error(errConfig, -1,
1334
"Bad 'psPaperSize' config file command ({0:s}:{1:d})",
1337
} else if (tokens->getLength() == 3) {
1338
tok = (GString *)tokens->get(1);
1339
psPaperWidth = atoi(tok->getCString());
1340
tok = (GString *)tokens->get(2);
1341
psPaperHeight = atoi(tok->getCString());
1342
psImageableLLX = psImageableLLY = 0;
1343
psImageableURX = psPaperWidth;
1344
psImageableURY = psPaperHeight;
1346
error(errConfig, -1, "Bad 'psPaperSize' config file command ({0:t}:{1:d})",
1351
void GlobalParams::parsePSImageableArea(GList *tokens, GString *fileName,
1353
if (tokens->getLength() != 5) {
1354
error(errConfig, -1,
1355
"Bad 'psImageableArea' config file command ({0:t}:{1:d})",
1359
psImageableLLX = atoi(((GString *)tokens->get(1))->getCString());
1360
psImageableLLY = atoi(((GString *)tokens->get(2))->getCString());
1361
psImageableURX = atoi(((GString *)tokens->get(3))->getCString());
1362
psImageableURY = atoi(((GString *)tokens->get(4))->getCString());
1365
void GlobalParams::parsePSLevel(GList *tokens, GString *fileName, int line) {
1368
if (tokens->getLength() != 2) {
1369
error(errConfig, -1, "Bad 'psLevel' config file command ({0:t}:{1:d})",
1373
tok = (GString *)tokens->get(1);
1374
if (!tok->cmp("level1")) {
1376
} else if (!tok->cmp("level1sep")) {
1377
psLevel = psLevel1Sep;
1378
} else if (!tok->cmp("level2")) {
1380
} else if (!tok->cmp("level2sep")) {
1381
psLevel = psLevel2Sep;
1382
} else if (!tok->cmp("level3")) {
1384
} else if (!tok->cmp("level3Sep")) {
1385
psLevel = psLevel3Sep;
1387
error(errConfig, -1, "Bad 'psLevel' config file command ({0:t}:{1:d})",
1392
void GlobalParams::parsePSResidentFont(GList *tokens, GString *fileName,
1394
if (tokens->getLength() != 3) {
1395
error(errConfig, -1, "Bad 'psResidentFont' config file command ({0:t}:{1:d})",
1399
psResidentFonts->add(((GString *)tokens->get(1))->copy(),
1400
((GString *)tokens->get(2))->copy());
1403
void GlobalParams::parsePSResidentFont16(GList *tokens, GString *fileName,
1405
PSFontParam16 *param;
1409
if (tokens->getLength() != 5) {
1410
error(errConfig, -1, "Bad 'psResidentFont16' config file command ({0:t}:{1:d})",
1414
tok = (GString *)tokens->get(2);
1415
if (!tok->cmp("H")) {
1417
} else if (!tok->cmp("V")) {
1420
error(errConfig, -1, "Bad wMode in psResidentFont16 config file command ({1:t}:{2:d})",
1424
param = new PSFontParam16(((GString *)tokens->get(1))->copy(),
1426
((GString *)tokens->get(3))->copy(),
1427
((GString *)tokens->get(4))->copy());
1428
psResidentFonts16->append(param);
1431
void GlobalParams::parsePSResidentFontCC(GList *tokens, GString *fileName,
1433
PSFontParam16 *param;
1437
if (tokens->getLength() != 5) {
1438
error(errConfig, -1, "Bad 'psResidentFontCC' config file command ({0:t}:{1:d})",
1442
tok = (GString *)tokens->get(2);
1443
if (!tok->cmp("H")) {
1445
} else if (!tok->cmp("V")) {
1448
error(errConfig, -1, "Bad wMode in psResidentFontCC config file command ({1:t}:{2:d})",
1452
param = new PSFontParam16(((GString *)tokens->get(1))->copy(),
1454
((GString *)tokens->get(3))->copy(),
1455
((GString *)tokens->get(4))->copy());
1456
psResidentFontsCC->append(param);
1459
void GlobalParams::parseTextEncoding(GList *tokens, GString *fileName,
1461
if (tokens->getLength() != 2) {
1462
error(errConfig, -1,
1463
"Bad 'textEncoding' config file command ({0:s}:{1:d})",
1467
delete textEncoding;
1468
textEncoding = ((GString *)tokens->get(1))->copy();
1471
void GlobalParams::parseTextEOL(GList *tokens, GString *fileName, int line) {
1474
if (tokens->getLength() != 2) {
1475
error(errConfig, -1, "Bad 'textEOL' config file command ({0:t}:{1:d})",
1479
tok = (GString *)tokens->get(1);
1480
if (!tok->cmp("unix")) {
1482
} else if (!tok->cmp("dos")) {
1484
} else if (!tok->cmp("mac")) {
1487
error(errConfig, -1, "Bad 'textEOL' config file command ({0:t}:{1:d})",
1492
void GlobalParams::parseInitialZoom(GList *tokens,
1493
GString *fileName, int line) {
1494
if (tokens->getLength() != 2) {
1495
error(errConfig, -1, "Bad 'initialZoom' config file command ({0:t}:{1:d})",
1500
initialZoom = ((GString *)tokens->get(1))->copy();
1503
void GlobalParams::parseScreenType(GList *tokens, GString *fileName,
1507
if (tokens->getLength() != 2) {
1508
error(errConfig, -1, "Bad 'screenType' config file command ({0:t}:{1:d})",
1512
tok = (GString *)tokens->get(1);
1513
if (!tok->cmp("dispersed")) {
1514
screenType = screenDispersed;
1515
} else if (!tok->cmp("clustered")) {
1516
screenType = screenClustered;
1517
} else if (!tok->cmp("stochasticClustered")) {
1518
screenType = screenStochasticClustered;
1520
error(errConfig, -1, "Bad 'screenType' config file command ({0:t}:{1:d})",
1525
void GlobalParams::parseBind(GList *tokens, GString *fileName, int line) {
1526
KeyBinding *binding;
1528
int code, mods, context, i;
1530
if (tokens->getLength() < 4) {
1531
error(errConfig, -1, "Bad 'bind' config file command ({0:t}:{1:d})",
1535
if (!parseKey((GString *)tokens->get(1), (GString *)tokens->get(2),
1536
&code, &mods, &context,
1537
"bind", tokens, fileName, line)) {
1540
for (i = 0; i < keyBindings->getLength(); ++i) {
1541
binding = (KeyBinding *)keyBindings->get(i);
1542
if (binding->code == code &&
1543
binding->mods == mods &&
1544
binding->context == context) {
1545
delete (KeyBinding *)keyBindings->del(i);
1550
for (i = 3; i < tokens->getLength(); ++i) {
1551
cmds->append(((GString *)tokens->get(i))->copy());
1553
keyBindings->append(new KeyBinding(code, mods, context, cmds));
1556
void GlobalParams::parseUnbind(GList *tokens, GString *fileName, int line) {
1557
KeyBinding *binding;
1558
int code, mods, context, i;
1560
if (tokens->getLength() != 3) {
1561
error(errConfig, -1, "Bad 'unbind' config file command ({0:t}:{1:d})",
1565
if (!parseKey((GString *)tokens->get(1), (GString *)tokens->get(2),
1566
&code, &mods, &context,
1567
"unbind", tokens, fileName, line)) {
1570
for (i = 0; i < keyBindings->getLength(); ++i) {
1571
binding = (KeyBinding *)keyBindings->get(i);
1572
if (binding->code == code &&
1573
binding->mods == mods &&
1574
binding->context == context) {
1575
delete (KeyBinding *)keyBindings->del(i);
1581
GBool GlobalParams::parseKey(GString *modKeyStr, GString *contextStr,
1582
int *code, int *mods, int *context,
1583
const char *cmdName,
1584
GList *tokens, GString *fileName, int line) {
1588
*mods = xpdfKeyModNone;
1589
p0 = modKeyStr->getCString();
1591
if (!strncmp(p0, "shift-", 6)) {
1592
*mods |= xpdfKeyModShift;
1594
} else if (!strncmp(p0, "ctrl-", 5)) {
1595
*mods |= xpdfKeyModCtrl;
1597
} else if (!strncmp(p0, "alt-", 4)) {
1598
*mods |= xpdfKeyModAlt;
1605
if (!strcmp(p0, "space")) {
1607
} else if (!strcmp(p0, "tab")) {
1608
*code = xpdfKeyCodeTab;
1609
} else if (!strcmp(p0, "return")) {
1610
*code = xpdfKeyCodeReturn;
1611
} else if (!strcmp(p0, "enter")) {
1612
*code = xpdfKeyCodeEnter;
1613
} else if (!strcmp(p0, "backspace")) {
1614
*code = xpdfKeyCodeBackspace;
1615
} else if (!strcmp(p0, "insert")) {
1616
*code = xpdfKeyCodeInsert;
1617
} else if (!strcmp(p0, "delete")) {
1618
*code = xpdfKeyCodeDelete;
1619
} else if (!strcmp(p0, "home")) {
1620
*code = xpdfKeyCodeHome;
1621
} else if (!strcmp(p0, "end")) {
1622
*code = xpdfKeyCodeEnd;
1623
} else if (!strcmp(p0, "pgup")) {
1624
*code = xpdfKeyCodePgUp;
1625
} else if (!strcmp(p0, "pgdn")) {
1626
*code = xpdfKeyCodePgDn;
1627
} else if (!strcmp(p0, "left")) {
1628
*code = xpdfKeyCodeLeft;
1629
} else if (!strcmp(p0, "right")) {
1630
*code = xpdfKeyCodeRight;
1631
} else if (!strcmp(p0, "up")) {
1632
*code = xpdfKeyCodeUp;
1633
} else if (!strcmp(p0, "down")) {
1634
*code = xpdfKeyCodeDown;
1635
} else if (p0[0] == 'f' && p0[1] >= '1' && p0[1] <= '9' && !p0[2]) {
1636
*code = xpdfKeyCodeF1 + (p0[1] - '1');
1637
} else if (p0[0] == 'f' &&
1638
((p0[1] >= '1' && p0[1] <= '2' && p0[2] >= '0' && p0[2] <= '9') ||
1639
(p0[1] == '3' && p0[2] >= '0' && p0[2] <= '5')) &&
1641
*code = xpdfKeyCodeF1 + 10 * (p0[1] - '0') + (p0[2] - '0') - 1;
1642
} else if (!strncmp(p0, "mousePress", 10) &&
1643
p0[10] >= '0' && p0[10] <= '9' &&
1644
(!p0[11] || (p0[11] >= '0' && p0[11] <= '9' && !p0[12])) &&
1645
(btn = atoi(p0 + 10)) >= 1 && btn <= 32) {
1646
*code = xpdfKeyCodeMousePress1 + btn - 1;
1647
} else if (!strncmp(p0, "mouseRelease", 12) &&
1648
p0[12] >= '0' && p0[12] <= '9' &&
1649
(!p0[13] || (p0[13] >= '0' && p0[13] <= '9' && !p0[14])) &&
1650
(btn = atoi(p0 + 12)) >= 1 && btn <= 32) {
1651
*code = xpdfKeyCodeMouseRelease1 + btn - 1;
1652
} else if (*p0 >= 0x20 && *p0 <= 0x7e && !p0[1]) {
1655
error(errConfig, -1,
1656
"Bad key/modifier in '{0:s}' config file command ({1:t}:{2:d})",
1657
cmdName, fileName, line);
1661
p0 = contextStr->getCString();
1662
if (!strcmp(p0, "any")) {
1663
*context = xpdfKeyContextAny;
1665
*context = xpdfKeyContextAny;
1667
if (!strncmp(p0, "fullScreen", 10)) {
1668
*context |= xpdfKeyContextFullScreen;
1670
} else if (!strncmp(p0, "window", 6)) {
1671
*context |= xpdfKeyContextWindow;
1673
} else if (!strncmp(p0, "continuous", 10)) {
1674
*context |= xpdfKeyContextContinuous;
1676
} else if (!strncmp(p0, "singlePage", 10)) {
1677
*context |= xpdfKeyContextSinglePage;
1679
} else if (!strncmp(p0, "overLink", 8)) {
1680
*context |= xpdfKeyContextOverLink;
1682
} else if (!strncmp(p0, "offLink", 7)) {
1683
*context |= xpdfKeyContextOffLink;
1685
} else if (!strncmp(p0, "outline", 7)) {
1686
*context |= xpdfKeyContextOutline;
1688
} else if (!strncmp(p0, "mainWin", 7)) {
1689
*context |= xpdfKeyContextMainWin;
1691
} else if (!strncmp(p0, "scrLockOn", 9)) {
1692
*context |= xpdfKeyContextScrLockOn;
1694
} else if (!strncmp(p0, "scrLockOff", 10)) {
1695
*context |= xpdfKeyContextScrLockOff;
1698
error(errConfig, -1,
1699
"Bad context in '{0:s}' config file command ({1:t}:{2:d})",
1700
cmdName, fileName, line);
1707
error(errConfig, -1,
1708
"Bad context in '{0:s}' config file command ({1:t}:{2:d})",
1709
cmdName, fileName, line);
1719
void GlobalParams::parseCommand(const char *cmdName, GString **val,
1720
GList *tokens, GString *fileName, int line) {
1721
if (tokens->getLength() != 2) {
1722
error(errConfig, -1, "Bad '{0:s}' config file command ({1:t}:{2:d})",
1723
cmdName, fileName, line);
1729
*val = ((GString *)tokens->get(1))->copy();
1732
void GlobalParams::parseYesNo(const char *cmdName, GBool *flag,
1733
GList *tokens, GString *fileName, int line) {
1736
if (tokens->getLength() != 2) {
1737
error(errConfig, -1, "Bad '{0:s}' config file command ({1:t}:{2:d})",
1738
cmdName, fileName, line);
1741
tok = (GString *)tokens->get(1);
1742
if (!parseYesNo2(tok->getCString(), flag)) {
1743
error(errConfig, -1, "Bad '{0:s}' config file command ({1:t}:{2:d})",
1744
cmdName, fileName, line);
1748
GBool GlobalParams::parseYesNo2(char *token, GBool *flag) {
1749
if (!strcmp(token, "yes")) {
1751
} else if (!strcmp(token, "no")) {
1759
void GlobalParams::parseInteger(const char *cmdName, int *val,
1760
GList *tokens, GString *fileName, int line) {
1764
if (tokens->getLength() != 2) {
1765
error(errConfig, -1, "Bad '{0:s}' config file command ({1:t}:{2:d})",
1766
cmdName, fileName, line);
1769
tok = (GString *)tokens->get(1);
1770
if (tok->getLength() == 0) {
1771
error(errConfig, -1, "Bad '{0:s}' config file command ({1:t}:{2:d})",
1772
cmdName, fileName, line);
1775
if (tok->getChar(0) == '-') {
1780
for (; i < tok->getLength(); ++i) {
1781
if (tok->getChar(i) < '0' || tok->getChar(i) > '9') {
1782
error(errConfig, -1, "Bad '{0:s}' config file command ({1:t}:{2:d})",
1783
cmdName, fileName, line);
1787
*val = atoi(tok->getCString());
1790
void GlobalParams::parseFloat(const char *cmdName, double *val,
1791
GList *tokens, GString *fileName, int line) {
1795
if (tokens->getLength() != 2) {
1796
error(errConfig, -1, "Bad '{0:s}' config file command ({1:t}:{2:d})",
1797
cmdName, fileName, line);
1800
tok = (GString *)tokens->get(1);
1801
if (tok->getLength() == 0) {
1802
error(errConfig, -1, "Bad '{0:s}' config file command ({1:t}:{2:d})",
1803
cmdName, fileName, line);
1806
if (tok->getChar(0) == '-') {
1811
for (; i < tok->getLength(); ++i) {
1812
if (!((tok->getChar(i) >= '0' && tok->getChar(i) <= '9') ||
1813
tok->getChar(i) == '.')) {
1814
error(errConfig, -1, "Bad '{0:s}' config file command ({1:t}:{2:d})",
1815
cmdName, fileName, line);
1819
*val = atof(tok->getCString());
1822
GlobalParams::~GlobalParams() {
1827
freeBuiltinFontTables();
1829
delete macRomanReverseMap;
1832
delete nameToUnicode;
1833
deleteGHash(cidToUnicodes, GString);
1834
deleteGHash(unicodeToUnicodes, GString);
1835
deleteGHash(residentUnicodeMaps, UnicodeMap);
1836
deleteGHash(unicodeMaps, GString);
1837
deleteGList(toUnicodeDirs, GString);
1838
deleteGHash(fontFiles, GString);
1839
deleteGList(fontDirs, GString);
1840
deleteGHash(ccFontFiles, GString);
1845
deleteGHash(psResidentFonts, GString);
1846
deleteGList(psResidentFonts16, PSFontParam16);
1847
deleteGList(psResidentFontsCC, PSFontParam16);
1848
delete textEncoding;
1850
if (launchCommand) {
1851
delete launchCommand;
1857
delete movieCommand;
1859
deleteGList(keyBindings, KeyBinding);
1861
cMapDirs->startIter(&iter);
1862
while (cMapDirs->getNext(&iter, &key, (void **)&list)) {
1863
deleteGList(list, GString);
1867
delete cidToUnicodeCache;
1868
delete unicodeToUnicodeCache;
1869
delete unicodeMapCache;
1872
#ifdef ENABLE_PLUGINS
1873
delete securityHandlers;
1874
deleteGList(plugins, Plugin);
1878
gDestroyMutex(&mutex);
1879
gDestroyMutex(&unicodeMapCacheMutex);
1880
gDestroyMutex(&cMapCacheMutex);
1884
//------------------------------------------------------------------------
1886
void GlobalParams::setBaseDir(char *dir) {
1888
baseDir = new GString(dir);
1891
void GlobalParams::setupBaseFonts(char *dir) {
1896
BOOL (__stdcall *SHGetSpecialFolderPathFunc)(HWND hwndOwner,
1900
char winFontDir[MAX_PATH];
1906
// SHGetSpecialFolderPath isn't available in older versions of
1907
// shell32.dll (Win95 and WinNT4), so do a dynamic load
1908
winFontDir[0] = '\0';
1909
if ((shell32Lib = LoadLibrary("shell32.dll"))) {
1910
if ((SHGetSpecialFolderPathFunc =
1911
(BOOL (__stdcall *)(HWND hwndOwner, LPTSTR lpszPath,
1912
int nFolder, BOOL fCreate))
1913
GetProcAddress(shell32Lib, "SHGetSpecialFolderPathA"))) {
1914
if (!(*SHGetSpecialFolderPathFunc)(NULL, winFontDir,
1915
CSIDL_FONTS, FALSE)) {
1916
winFontDir[0] = '\0';
1921
for (i = 0; displayFontTab[i].name; ++i) {
1922
if (fontFiles->lookup(displayFontTab[i].name)) {
1925
fontName = new GString(displayFontTab[i].name);
1928
fileName = appendToPath(new GString(dir), displayFontTab[i].t1FileName);
1929
if ((f = fopen(fileName->getCString(), "rb"))) {
1937
if (!fileName && winFontDir[0] && displayFontTab[i].ttFileName) {
1938
fileName = appendToPath(new GString(winFontDir),
1939
displayFontTab[i].ttFileName);
1940
if ((f = fopen(fileName->getCString(), "rb"))) {
1947
// SHGetSpecialFolderPath(CSIDL_FONTS) doesn't work on Win 2k Server
1948
// or Win2003 Server, or with older versions of shell32.dll, so check
1949
// the "standard" directories
1950
if (displayFontTab[i].ttFileName) {
1951
for (j = 0; !fileName && displayFontDirs[j]; ++j) {
1952
fileName = appendToPath(new GString(displayFontDirs[j]),
1953
displayFontTab[i].ttFileName);
1954
if ((f = fopen(fileName->getCString(), "rb"))) {
1963
for (j = 0; !fileName && displayFontDirs[j]; ++j) {
1964
fileName = appendToPath(new GString(displayFontDirs[j]),
1965
displayFontTab[i].t1FileName);
1966
if ((f = fopen(fileName->getCString(), "rb"))) {
1975
error(errConfig, -1, "No display font for '{0:s}'",
1976
displayFontTab[i].name);
1980
addFontFile(fontName, fileName);
1984
if (winFontDir[0]) {
1985
sysFonts->scanWindowsFonts(winFontDir);
1990
//------------------------------------------------------------------------
1992
//------------------------------------------------------------------------
1994
CharCode GlobalParams::getMacRomanCharCode(char *charName) {
1995
// no need to lock - macRomanReverseMap is constant
1996
return macRomanReverseMap->lookup(charName);
1999
GString *GlobalParams::getBaseDir() {
2003
s = baseDir->copy();
2008
Unicode GlobalParams::mapNameToUnicode(const char *charName) {
2009
// no need to lock - nameToUnicode is constant
2010
return nameToUnicode->lookup(charName);
2013
UnicodeMap *GlobalParams::getResidentUnicodeMap(GString *encodingName) {
2017
map = (UnicodeMap *)residentUnicodeMaps->lookup(encodingName);
2025
FILE *GlobalParams::getUnicodeMapFile(GString *encodingName) {
2030
if ((fileName = (GString *)unicodeMaps->lookup(encodingName))) {
2031
f = openFile(fileName->getCString(), "r");
2039
FILE *GlobalParams::findCMapFile(GString *collection, GString *cMapName) {
2047
if (!(list = (GList *)cMapDirs->lookup(collection))) {
2051
for (i = 0; i < list->getLength(); ++i) {
2052
dir = (GString *)list->get(i);
2053
fileName = appendToPath(dir->copy(), cMapName->getCString());
2054
f = openFile(fileName->getCString(), "r");
2065
FILE *GlobalParams::findToUnicodeFile(GString *name) {
2066
GString *dir, *fileName;
2071
for (i = 0; i < toUnicodeDirs->getLength(); ++i) {
2072
dir = (GString *)toUnicodeDirs->get(i);
2073
fileName = appendToPath(dir->copy(), name->getCString());
2074
f = openFile(fileName->getCString(), "r");
2085
GString *GlobalParams::findFontFile(GString *fontName, char** throwaway) {
2086
static const char *exts[] = { ".pfa", ".pfb", ".ttf", ".ttc" };
2087
GString *path, *dir;
2097
if ((path = (GString *)fontFiles->lookup(fontName))) {
2098
path = path->copy();
2102
for (i = 0; i < fontDirs->getLength(); ++i) {
2103
dir = (GString *)fontDirs->get(i);
2104
for (j = 0; j < (int)(sizeof(exts) / sizeof(exts[0])); ++j) {
2107
fontNameU = fileNameToUTF8(fontName->getCString());
2108
path = appendToPath(dir->copy(), fontNameU->getCString());
2111
path = appendToPath(dir->copy(), fontName->getCString());
2114
if ((f = openFile(path->getCString(), "rb"))) {
2126
GString *GlobalParams::findSystemFontFile(GString *fontName,
2134
if ((fi = sysFonts->find(fontName))) {
2135
path = fi->path->copy();
2137
*fontNum = fi->fontNum;
2143
GString *GlobalParams::findCCFontFile(GString *collection) {
2147
if ((path = (GString *)ccFontFiles->lookup(collection))) {
2148
path = path->copy();
2154
GString *GlobalParams::getPSFile() {
2158
s = psFile ? psFile->copy() : (GString *)NULL;
2163
int GlobalParams::getPSPaperWidth() {
2172
int GlobalParams::getPSPaperHeight() {
2181
void GlobalParams::getPSImageableArea(int *llx, int *lly, int *urx, int *ury) {
2183
*llx = psImageableLLX;
2184
*lly = psImageableLLY;
2185
*urx = psImageableURX;
2186
*ury = psImageableURY;
2190
GBool GlobalParams::getPSCrop() {
2199
GBool GlobalParams::getPSExpandSmaller() {
2203
f = psExpandSmaller;
2208
GBool GlobalParams::getPSShrinkLarger() {
2217
GBool GlobalParams::getPSCenter() {
2226
GBool GlobalParams::getPSDuplex() {
2235
PSLevel GlobalParams::getPSLevel() {
2244
GString *GlobalParams::getPSResidentFont(GString *fontName) {
2248
psName = (GString *)psResidentFonts->lookup(fontName);
2253
GList *GlobalParams::getPSResidentFonts() {
2259
names = new GList();
2261
psResidentFonts->startIter(&iter);
2262
while (psResidentFonts->getNext(&iter, &name, (void **)&psName)) {
2263
names->append(psName->copy());
2269
PSFontParam16 *GlobalParams::getPSResidentFont16(GString *fontName,
2276
for (i = 0; i < psResidentFonts16->getLength(); ++i) {
2277
p = (PSFontParam16 *)psResidentFonts16->get(i);
2278
if (!(p->name->cmp(fontName)) && p->wMode == wMode) {
2287
PSFontParam16 *GlobalParams::getPSResidentFontCC(GString *collection,
2294
for (i = 0; i < psResidentFontsCC->getLength(); ++i) {
2295
p = (PSFontParam16 *)psResidentFontsCC->get(i);
2296
if (!(p->name->cmp(collection)) && p->wMode == wMode) {
2305
GBool GlobalParams::getPSEmbedType1() {
2314
GBool GlobalParams::getPSEmbedTrueType() {
2318
e = psEmbedTrueType;
2323
GBool GlobalParams::getPSEmbedCIDPostScript() {
2327
e = psEmbedCIDPostScript;
2332
GBool GlobalParams::getPSEmbedCIDTrueType() {
2336
e = psEmbedCIDTrueType;
2341
GBool GlobalParams::getPSFontPassthrough() {
2345
e = psFontPassthrough;
2350
GBool GlobalParams::getPSPreload() {
2354
preload = psPreload;
2359
GBool GlobalParams::getPSOPI() {
2368
GBool GlobalParams::getPSASCIIHex() {
2377
GBool GlobalParams::getPSUncompressPreloadedImages() {
2381
ah = psUncompressPreloadedImages;
2386
double GlobalParams::getPSRasterResolution() {
2390
res = psRasterResolution;
2395
GBool GlobalParams::getPSRasterMono() {
2399
mono = psRasterMono;
2404
GBool GlobalParams::getPSAlwaysRasterize() {
2408
rast = psAlwaysRasterize;
2413
GString *GlobalParams::getTextEncodingName() {
2417
s = textEncoding->copy();
2422
EndOfLineKind GlobalParams::getTextEOL() {
2431
GBool GlobalParams::getTextPageBreaks() {
2435
pageBreaks = textPageBreaks;
2440
GBool GlobalParams::getTextKeepTinyChars() {
2444
tiny = textKeepTinyChars;
2449
GString *GlobalParams::getInitialZoom() {
2453
s = initialZoom->copy();
2458
GBool GlobalParams::getContinuousView() {
2467
GBool GlobalParams::getEnableT1lib() {
2476
GBool GlobalParams::getEnableFreeType() {
2485
GBool GlobalParams::getDisableFreeTypeHinting() {
2489
f = disableFreeTypeHinting;
2495
GBool GlobalParams::getAntialias() {
2504
GBool GlobalParams::getVectorAntialias() {
2508
f = vectorAntialias;
2513
GBool GlobalParams::getAntialiasPrinting() {
2517
f = antialiasPrinting;
2522
GBool GlobalParams::getStrokeAdjust() {
2531
ScreenType GlobalParams::getScreenType() {
2540
int GlobalParams::getScreenSize() {
2549
int GlobalParams::getScreenDotRadius() {
2553
r = screenDotRadius;
2558
double GlobalParams::getScreenGamma() {
2562
gamma = screenGamma;
2567
double GlobalParams::getScreenBlackThreshold() {
2571
thresh = screenBlackThreshold;
2576
double GlobalParams::getScreenWhiteThreshold() {
2580
thresh = screenWhiteThreshold;
2585
double GlobalParams::getMinLineWidth() {
2594
GBool GlobalParams::getDrawAnnotations() {
2598
draw = drawAnnotations;
2603
GBool GlobalParams::getMapNumericCharNames() {
2607
map = mapNumericCharNames;
2612
GBool GlobalParams::getMapUnknownCharNames() {
2616
map = mapUnknownCharNames;
2621
GList *GlobalParams::getKeyBinding(int code, int mods, int context) {
2622
KeyBinding *binding;
2629
// for ASCII chars, ignore the shift modifier
2630
modMask = code <= 0xff ? ~xpdfKeyModShift : ~0;
2631
for (i = 0; i < keyBindings->getLength(); ++i) {
2632
binding = (KeyBinding *)keyBindings->get(i);
2633
if (binding->code == code &&
2634
(binding->mods & modMask) == (mods & modMask) &&
2635
(~binding->context | context) == ~0) {
2637
for (j = 0; j < binding->cmds->getLength(); ++j) {
2638
cmds->append(((GString *)binding->cmds->get(j))->copy());
2647
GBool GlobalParams::getPrintCommands() {
2656
GBool GlobalParams::getErrQuiet() {
2657
// no locking -- this function may get called from inside a locked
2662
CharCodeToUnicode *GlobalParams::getCIDToUnicode(GString *collection) {
2664
CharCodeToUnicode *ctu;
2667
if (!(ctu = cidToUnicodeCache->getCharCodeToUnicode(collection))) {
2668
if ((fileName = (GString *)cidToUnicodes->lookup(collection)) &&
2669
(ctu = CharCodeToUnicode::parseCIDToUnicode(fileName, collection))) {
2670
cidToUnicodeCache->add(ctu);
2677
CharCodeToUnicode *GlobalParams::getUnicodeToUnicode(GString *fontName) {
2678
CharCodeToUnicode *ctu;
2680
GString *fontPattern, *fileName;
2684
unicodeToUnicodes->startIter(&iter);
2685
while (unicodeToUnicodes->getNext(&iter, &fontPattern, (void **)&fileName)) {
2686
if (strstr(fontName->getCString(), fontPattern->getCString())) {
2687
unicodeToUnicodes->killIter(&iter);
2693
if (!(ctu = unicodeToUnicodeCache->getCharCodeToUnicode(fileName))) {
2694
if ((ctu = CharCodeToUnicode::parseUnicodeToUnicode(fileName))) {
2695
unicodeToUnicodeCache->add(ctu);
2705
UnicodeMap *GlobalParams::getUnicodeMap(GString *encodingName) {
2706
return getUnicodeMap2(encodingName);
2709
UnicodeMap *GlobalParams::getUnicodeMap2(GString *encodingName) {
2712
if (!(map = getResidentUnicodeMap(encodingName))) {
2713
lockUnicodeMapCache;
2714
map = unicodeMapCache->getUnicodeMap(encodingName);
2715
unlockUnicodeMapCache;
2720
CMap *GlobalParams::getCMap(GString *collection, GString *cMapName, Stream *stream) {
2724
cMap = cMapCache->getCMap(collection, cMapName, stream);
2729
UnicodeMap *GlobalParams::getTextEncoding() {
2730
return getUnicodeMap2(textEncoding);
2733
//------------------------------------------------------------------------
2734
// functions to set parameters
2735
//------------------------------------------------------------------------
2737
void GlobalParams::addFontFile(GString *fontName, GString *path) {
2739
fontFiles->add(fontName, path);
2743
void GlobalParams::setPSFile(char *file) {
2748
psFile = new GString(file);
2752
GBool GlobalParams::setPSPaperSize(char *size) {
2754
if (!strcmp(size, "match")) {
2755
psPaperWidth = psPaperHeight = -1;
2756
} else if (!strcmp(size, "letter")) {
2758
psPaperHeight = 792;
2759
} else if (!strcmp(size, "legal")) {
2761
psPaperHeight = 1008;
2762
} else if (!strcmp(size, "A4")) {
2764
psPaperHeight = 842;
2765
} else if (!strcmp(size, "A3")) {
2767
psPaperHeight = 1190;
2772
psImageableLLX = psImageableLLY = 0;
2773
psImageableURX = psPaperWidth;
2774
psImageableURY = psPaperHeight;
2779
void GlobalParams::setPSPaperWidth(int width) {
2781
psPaperWidth = width;
2783
psImageableURX = psPaperWidth;
2787
void GlobalParams::setPSPaperHeight(int height) {
2789
psPaperHeight = height;
2791
psImageableURY = psPaperHeight;
2795
void GlobalParams::setPSImageableArea(int llx, int lly, int urx, int ury) {
2797
psImageableLLX = llx;
2798
psImageableLLY = lly;
2799
psImageableURX = urx;
2800
psImageableURY = ury;
2804
void GlobalParams::setPSCrop(GBool crop) {
2810
void GlobalParams::setPSExpandSmaller(GBool expand) {
2812
psExpandSmaller = expand;
2816
void GlobalParams::setPSShrinkLarger(GBool shrink) {
2818
psShrinkLarger = shrink;
2822
void GlobalParams::setPSCenter(GBool center) {
2828
void GlobalParams::setPSDuplex(GBool duplex) {
2834
void GlobalParams::setPSLevel(PSLevel level) {
2840
void GlobalParams::setPSEmbedType1(GBool embed) {
2842
psEmbedType1 = embed;
2846
void GlobalParams::setPSEmbedTrueType(GBool embed) {
2848
psEmbedTrueType = embed;
2852
void GlobalParams::setPSEmbedCIDPostScript(GBool embed) {
2854
psEmbedCIDPostScript = embed;
2858
void GlobalParams::setPSEmbedCIDTrueType(GBool embed) {
2860
psEmbedCIDTrueType = embed;
2864
void GlobalParams::setPSFontPassthrough(GBool passthrough) {
2866
psFontPassthrough = passthrough;
2870
void GlobalParams::setPSPreload(GBool preload) {
2872
psPreload = preload;
2876
void GlobalParams::setPSOPI(GBool opi) {
2882
void GlobalParams::setPSASCIIHex(GBool hex) {
2888
void GlobalParams::setTextEncoding(char *encodingName) {
2890
delete textEncoding;
2891
textEncoding = new GString(encodingName);
2895
GBool GlobalParams::setTextEOL(char *s) {
2897
if (!strcmp(s, "unix")) {
2899
} else if (!strcmp(s, "dos")) {
2901
} else if (!strcmp(s, "mac")) {
2911
void GlobalParams::setTextPageBreaks(GBool pageBreaks) {
2913
textPageBreaks = pageBreaks;
2917
void GlobalParams::setTextKeepTinyChars(GBool keep) {
2919
textKeepTinyChars = keep;
2923
void GlobalParams::setInitialZoom(char *s) {
2926
initialZoom = new GString(s);
2930
void GlobalParams::setContinuousView(GBool cont) {
2932
continuousView = cont;
2936
GBool GlobalParams::setEnableT1lib(char *s) {
2940
ok = parseYesNo2(s, &enableT1lib);
2945
GBool GlobalParams::setEnableFreeType(char *s) {
2949
ok = parseYesNo2(s, &enableFreeType);
2955
GBool GlobalParams::setAntialias(char *s) {
2959
ok = parseYesNo2(s, &antialias);
2964
GBool GlobalParams::setVectorAntialias(char *s) {
2968
ok = parseYesNo2(s, &vectorAntialias);
2973
void GlobalParams::setScreenType(ScreenType t) {
2979
void GlobalParams::setScreenSize(int size) {
2985
void GlobalParams::setScreenDotRadius(int r) {
2987
screenDotRadius = r;
2991
void GlobalParams::setScreenGamma(double gamma) {
2993
screenGamma = gamma;
2997
void GlobalParams::setScreenBlackThreshold(double thresh) {
2999
screenBlackThreshold = thresh;
3003
void GlobalParams::setScreenWhiteThreshold(double thresh) {
3005
screenWhiteThreshold = thresh;
3009
void GlobalParams::setMapNumericCharNames(GBool map) {
3011
mapNumericCharNames = map;
3015
void GlobalParams::setMapUnknownCharNames(GBool map) {
3017
mapUnknownCharNames = map;
3021
void GlobalParams::setPrintCommands(GBool printCommandsA) {
3023
printCommands = printCommandsA;
3027
void GlobalParams::setErrQuiet(GBool errQuietA) {
3029
errQuiet = errQuietA;
3033
void GlobalParams::addSecurityHandler(XpdfSecurityHandler *handler) {
3034
#ifdef ENABLE_PLUGINS
3036
securityHandlers->append(handler);
3041
XpdfSecurityHandler *GlobalParams::getSecurityHandler(char *name) {
3042
#ifdef ENABLE_PLUGINS
3043
XpdfSecurityHandler *hdlr;
3047
for (i = 0; i < securityHandlers->getLength(); ++i) {
3048
hdlr = (XpdfSecurityHandler *)securityHandlers->get(i);
3049
if (!strcasecmp(hdlr->name, name)) {
3056
if (!loadPlugin("security", name)) {
3061
for (i = 0; i < securityHandlers->getLength(); ++i) {
3062
hdlr = (XpdfSecurityHandler *)securityHandlers->get(i);
3063
if (!strcmp(hdlr->name, name)) {
3074
#ifdef ENABLE_PLUGINS
3075
//------------------------------------------------------------------------
3077
//------------------------------------------------------------------------
3079
GBool GlobalParams::loadPlugin(char *type, char *name) {
3082
if (!(plugin = Plugin::load(type, name))) {
3086
plugins->append(plugin);
3091
#endif // ENABLE_PLUGINS