1
//========================================================================
5
// Copyright 2001-2002 Glyph & Cog, LLC
7
//========================================================================
11
#ifdef USE_GCC_PRAGMAS
12
#pragma implementation
26
#include "nametocharcode.h"
27
#include "charcodetounicode.h"
28
#include "unicodemap.h"
30
#include "builtinfonttables.h"
31
#include "fontencodingtables.h"
32
#include "globalparams.h"
35
# define globalParamsLock gLockMutex(&mutex)
36
# define globalParamsUnlock gUnlockMutex(&mutex)
38
# define globalParamsLock
39
# define globalParamsUnlock
42
#include "nametounicodetable.h"
43
#include "unicodemaptables.h"
44
#include "displayfonttable.h"
47
//------------------------------------------------------------------------
49
GlobalParams *globalParams = NULL;
51
//------------------------------------------------------------------------
53
//------------------------------------------------------------------------
55
DisplayFontParam::DisplayFontParam(GString *nameA,
56
DisplayFontParamKind kindA) {
73
DisplayFontParam::DisplayFontParam(char *nameA, char *xlfdA, char *encodingA) {
74
name = new GString(nameA);
76
x.xlfd = new GString(xlfdA);
77
x.encoding = new GString(encodingA);
80
DisplayFontParam::~DisplayFontParam() {
104
//------------------------------------------------------------------------
106
//------------------------------------------------------------------------
108
PSFontParam::PSFontParam(GString *pdfFontNameA, int wModeA,
109
GString *psFontNameA, GString *encodingA) {
110
pdfFontName = pdfFontNameA;
112
psFontName = psFontNameA;
113
encoding = encodingA;
116
PSFontParam::~PSFontParam() {
124
//------------------------------------------------------------------------
126
//------------------------------------------------------------------------
128
GlobalParams::GlobalParams(char *cfgFileName) {
130
DisplayFontParam *dfp;
139
initBuiltinFontTables();
141
// scan the encoding in reverse because we want the lowest-numbered
142
// index for each char name ('space' is encoded twice)
143
macRomanReverseMap = new NameToCharCode();
144
for (i = 255; i >= 0; --i) {
145
if (macRomanEncoding[i]) {
146
macRomanReverseMap->add(macRomanEncoding[i], (CharCode)i);
150
nameToUnicode = new NameToCharCode();
151
cidToUnicodes = new GHash(gTrue);
152
residentUnicodeMaps = new GHash();
153
unicodeMaps = new GHash(gTrue);
154
cMapDirs = new GHash(gTrue);
155
toUnicodeDirs = new GList();
156
displayFonts = new GHash();
157
displayCIDFonts = new GHash();
158
displayNamedCIDFonts = new GHash();
161
const struct paper *paperType;
163
if ((paperName = systempapername())) {
164
paperType = paperinfo(paperName);
165
psPaperWidth = (int)paperpswidth(paperType);
166
psPaperHeight = (int)paperpsheight(paperType);
168
error(-1, "No paper information available - using defaults");
169
psPaperWidth = defPaperWidth;
170
psPaperHeight = defPaperHeight;
174
psPaperWidth = defPaperWidth;
175
psPaperHeight = defPaperHeight;
180
psFonts = new GHash();
181
psNamedFonts16 = new GList();
182
psFonts16 = new GList();
183
psEmbedType1 = gTrue;
184
psEmbedTrueType = gTrue;
185
psEmbedCIDPostScript = gTrue;
186
psEmbedCIDTrueType = gTrue;
189
textEncoding = new GString("Latin1");
197
textKeepTinyChars = gFalse;
198
fontDirs = new GList();
199
initialZoom = new GString("1");
200
t1libControl = fontRastAALow;
201
freetypeControl = fontRastAALow;
204
mapNumericCharNames = gTrue;
205
printCommands = gFalse;
208
cidToUnicodeCache = new CIDToUnicodeCache();
209
unicodeMapCache = new UnicodeMapCache();
210
cMapCache = new CMapCache();
212
// set up the initial nameToUnicode table
213
for (i = 0; nameToUnicodeTab[i].name; ++i) {
214
nameToUnicode->add(nameToUnicodeTab[i].name, nameToUnicodeTab[i].u);
217
// set up the residentUnicodeMaps table
218
map = new UnicodeMap("Latin1", gFalse,
219
latin1UnicodeMapRanges, latin1UnicodeMapLen);
220
residentUnicodeMaps->add(map->getEncodingName(), map);
221
map = new UnicodeMap("ASCII7", gFalse,
222
ascii7UnicodeMapRanges, ascii7UnicodeMapLen);
223
residentUnicodeMaps->add(map->getEncodingName(), map);
224
map = new UnicodeMap("Symbol", gFalse,
225
symbolUnicodeMapRanges, symbolUnicodeMapLen);
226
residentUnicodeMaps->add(map->getEncodingName(), map);
227
map = new UnicodeMap("ZapfDingbats", gFalse, zapfDingbatsUnicodeMapRanges,
228
zapfDingbatsUnicodeMapLen);
229
residentUnicodeMaps->add(map->getEncodingName(), map);
230
map = new UnicodeMap("UTF-8", gTrue, &mapUTF8);
231
residentUnicodeMaps->add(map->getEncodingName(), map);
232
map = new UnicodeMap("UCS-2", gTrue, &mapUCS2);
233
residentUnicodeMaps->add(map->getEncodingName(), map);
235
// default displayFonts table
236
for (i = 0; displayFontTab[i].name; ++i) {
237
dfp = new DisplayFontParam(displayFontTab[i].name,
238
displayFontTab[i].xlfd,
239
displayFontTab[i].encoding);
240
displayFonts->add(dfp->name, dfp);
243
// look for a user config file, then a system-wide config file
247
if (cfgFileName && cfgFileName[0]) {
248
fileName = new GString(cfgFileName);
249
if (!(f = ocfopen(fileName->getCString(), "r"))) {
254
fileName = appendToPath(getHomeDir(), xpdfUserConfigFile);
255
if (!(f = ocfopen(fileName->getCString(), "r"))) {
260
#if defined(WIN32) && !defined(__CYGWIN32__)
262
i = GetModuleFileName(NULL, buf, sizeof(buf));
263
if (i <= 0 || i >= sizeof(buf)) {
264
// error or path too long for buffer - just use the current dir
267
fileName = grabPath(buf);
268
appendToPath(fileName, xpdfSysConfigFile);
270
fileName = new GString(xpdfSysConfigFile);
272
if (!(f = ocfopen(fileName->getCString(), "r"))) {
277
parseFile(fileName, f);
284
void GlobalParams::parseFile(GString *fileName, OCFILE *f) {
287
GString *cmd, *incFile;
293
while (getLine(buf, sizeof(buf) - 1, f)) {
295
// break the line into tokens
296
tokens = new GList();
299
for (; *p1 && isspace(*p1); ++p1) ;
303
if (*p1 == '"' || *p1 == '\'') {
304
for (p2 = p1 + 1; *p2 && *p2 != *p1; ++p2) ;
307
for (p2 = p1 + 1; *p2 && !isspace(*p2); ++p2) ;
309
tokens->append(new GString(p1, p2 - p1));
310
p1 = *p2 ? p2 + 1 : p2;
313
if (tokens->getLength() > 0 &&
314
((GString *)tokens->get(0))->getChar(0) != '#') {
315
cmd = (GString *)tokens->get(0);
316
if (!cmd->cmp("include")) {
317
if (tokens->getLength() == 2) {
318
incFile = (GString *)tokens->get(1);
319
if ((f2 = ocfopen(incFile->getCString(), "r"))) {
320
parseFile(incFile, f2);
323
error(-1, "Couldn't find included config file: '%s' (%s:%d)",
324
incFile->getCString(), fileName->getCString(), line);
327
error(-1, "Bad 'include' config file command (%s:%d)",
328
fileName->getCString(), line);
330
} else if (!cmd->cmp("nameToUnicode")) {
331
parseNameToUnicode(tokens, fileName, line);
332
} else if (!cmd->cmp("cidToUnicode")) {
333
parseCIDToUnicode(tokens, fileName, line);
334
} else if (!cmd->cmp("unicodeMap")) {
335
parseUnicodeMap(tokens, fileName, line);
336
} else if (!cmd->cmp("cMapDir")) {
337
parseCMapDir(tokens, fileName, line);
338
} else if (!cmd->cmp("toUnicodeDir")) {
339
parseToUnicodeDir(tokens, fileName, line);
340
} else if (!cmd->cmp("displayFontX")) {
341
parseDisplayFont(tokens, displayFonts, displayFontX, fileName, line);
342
} else if (!cmd->cmp("displayFontT1")) {
343
parseDisplayFont(tokens, displayFonts, displayFontT1, fileName, line);
344
} else if (!cmd->cmp("displayFontTT")) {
345
parseDisplayFont(tokens, displayFonts, displayFontTT, fileName, line);
346
} else if (!cmd->cmp("displayNamedCIDFontX")) {
347
parseDisplayFont(tokens, displayNamedCIDFonts,
348
displayFontX, fileName, line);
349
} else if (!cmd->cmp("displayCIDFontX")) {
350
parseDisplayFont(tokens, displayCIDFonts,
351
displayFontX, fileName, line);
352
} else if (!cmd->cmp("displayNamedCIDFontT1")) {
353
parseDisplayFont(tokens, displayNamedCIDFonts,
354
displayFontT1, fileName, line);
355
} else if (!cmd->cmp("displayCIDFontT1")) {
356
parseDisplayFont(tokens, displayCIDFonts,
357
displayFontT1, fileName, line);
358
} else if (!cmd->cmp("psFile")) {
359
parsePSFile(tokens, fileName, line);
360
} else if (!cmd->cmp("psFont")) {
361
parsePSFont(tokens, fileName, line);
362
} else if (!cmd->cmp("psNamedFont16")) {
363
parsePSFont16("psNamedFont16", psNamedFonts16,
364
tokens, fileName, line);
365
} else if (!cmd->cmp("psFont16")) {
366
parsePSFont16("psFont16", psFonts16, tokens, fileName, line);
367
} else if (!cmd->cmp("psPaperSize")) {
368
parsePSPaperSize(tokens, fileName, line);
369
} else if (!cmd->cmp("psDuplex")) {
370
parseYesNo("psDuplex", &psDuplex, tokens, fileName, line);
371
} else if (!cmd->cmp("psLevel")) {
372
parsePSLevel(tokens, fileName, line);
373
} else if (!cmd->cmp("psEmbedType1Fonts")) {
374
parseYesNo("psEmbedType1", &psEmbedType1, tokens, fileName, line);
375
} else if (!cmd->cmp("psEmbedTrueTypeFonts")) {
376
parseYesNo("psEmbedTrueType", &psEmbedTrueType,
377
tokens, fileName, line);
378
} else if (!cmd->cmp("psEmbedCIDPostScriptFonts")) {
379
parseYesNo("psEmbedCIDPostScript", &psEmbedCIDPostScript,
380
tokens, fileName, line);
381
} else if (!cmd->cmp("psEmbedCIDTrueTypeFonts")) {
382
parseYesNo("psEmbedCIDTrueType", &psEmbedCIDTrueType,
383
tokens, fileName, line);
384
} else if (!cmd->cmp("psOPI")) {
385
parseYesNo("psOPI", &psOPI, tokens, fileName, line);
386
} else if (!cmd->cmp("psASCIIHex")) {
387
parseYesNo("psASCIIHex", &psASCIIHex, tokens, fileName, line);
388
} else if (!cmd->cmp("textEncoding")) {
389
parseTextEncoding(tokens, fileName, line);
390
} else if (!cmd->cmp("textEOL")) {
391
parseTextEOL(tokens, fileName, line);
392
} else if (!cmd->cmp("textKeepTinyChars")) {
393
parseYesNo("textKeepTinyChars", &textKeepTinyChars,
394
tokens, fileName, line);
395
} else if (!cmd->cmp("fontDir")) {
396
parseFontDir(tokens, fileName, line);
397
} else if (!cmd->cmp("initialZoom")) {
398
parseInitialZoom(tokens, fileName, line);
399
} else if (!cmd->cmp("t1libControl")) {
400
parseFontRastControl("t1libControl", &t1libControl,
401
tokens, fileName, line);
402
} else if (!cmd->cmp("freetypeControl")) {
403
parseFontRastControl("freetypeControl", &freetypeControl,
404
tokens, fileName, line);
405
} else if (!cmd->cmp("urlCommand")) {
406
parseCommand("urlCommand", &urlCommand, tokens, fileName, line);
407
} else if (!cmd->cmp("movieCommand")) {
408
parseCommand("movieCommand", &movieCommand, tokens, fileName, line);
409
} else if (!cmd->cmp("mapNumericCharNames")) {
410
parseYesNo("mapNumericCharNames", &mapNumericCharNames,
411
tokens, fileName, line);
412
} else if (!cmd->cmp("printCommands")) {
413
parseYesNo("printCommands", &printCommands, tokens, fileName, line);
414
} else if (!cmd->cmp("errQuiet")) {
415
parseYesNo("errQuiet", &errQuiet, tokens, fileName, line);
416
} else if (!cmd->cmp("fontpath") || !cmd->cmp("fontmap")) {
417
error(-1, "Unknown config file command");
418
error(-1, "-- the config file format has changed since Xpdf 0.9x");
420
error(-1, "Unknown config file command '%s' (%s:%d)",
421
cmd->getCString(), fileName->getCString(), line);
425
deleteGList(tokens, GString);
430
void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
439
if (tokens->getLength() != 2) {
440
error(-1, "Bad 'nameToUnicode' config file command (%s:%d)",
441
fileName->getCString(), line);
444
name = (GString *)tokens->get(1);
445
if (!(f = ocfopen(name->getCString(), "r"))) {
446
error(-1, "Couldn't open 'nameToUnicode' file '%s'",
451
while (getLine(buf, sizeof(buf), f)) {
452
tok1 = strtok(buf, " \t\r\n");
453
tok2 = strtok(NULL, " \t\r\n");
455
sscanf(tok1, "%x", &u);
456
nameToUnicode->add(tok2, u);
458
error(-1, "Bad line in 'nameToUnicode' file (%s:%d)", name, line2);
465
void GlobalParams::parseCIDToUnicode(GList *tokens, GString *fileName,
467
GString *collection, *name, *old;
469
if (tokens->getLength() != 3) {
470
error(-1, "Bad 'cidToUnicode' config file command (%s:%d)",
471
fileName->getCString(), line);
474
collection = (GString *)tokens->get(1);
475
name = (GString *)tokens->get(2);
476
if ((old = (GString *)cidToUnicodes->remove(collection))) {
479
cidToUnicodes->add(collection->copy(), name->copy());
482
void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
484
GString *encodingName, *name, *old;
486
if (tokens->getLength() != 3) {
487
error(-1, "Bad 'unicodeMap' config file command (%s:%d)",
488
fileName->getCString(), line);
491
encodingName = (GString *)tokens->get(1);
492
name = (GString *)tokens->get(2);
493
if ((old = (GString *)unicodeMaps->remove(encodingName))) {
496
unicodeMaps->add(encodingName->copy(), name->copy());
499
void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
500
GString *collection, *dir;
503
if (tokens->getLength() != 3) {
504
error(-1, "Bad 'cMapDir' config file command (%s:%d)",
505
fileName->getCString(), line);
508
collection = (GString *)tokens->get(1);
509
dir = (GString *)tokens->get(2);
510
if (!(list = (GList *)cMapDirs->lookup(collection))) {
512
cMapDirs->add(collection->copy(), list);
514
list->append(dir->copy());
517
void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
519
if (tokens->getLength() != 2) {
520
error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
521
fileName->getCString(), line);
524
toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
527
void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
528
DisplayFontParamKind kind,
529
GString *fileName, int line) {
530
DisplayFontParam *param, *old;
532
if (tokens->getLength() < 2) {
535
param = new DisplayFontParam(((GString *)tokens->get(1))->copy(), kind);
539
if (tokens->getLength() != 4) {
542
param->x.xlfd = ((GString *)tokens->get(2))->copy();
543
param->x.encoding = ((GString *)tokens->get(3))->copy();
546
if (tokens->getLength() != 3) {
549
param->t1.fileName = ((GString *)tokens->get(2))->copy();
552
if (tokens->getLength() != 3) {
555
param->tt.fileName = ((GString *)tokens->get(2))->copy();
559
if ((old = (DisplayFontParam *)fontHash->remove(param->name))) {
562
fontHash->add(param->name, param);
568
error(-1, "Bad 'display*Font*' config file command (%s:%d)",
569
fileName->getCString(), line);
572
void GlobalParams::parsePSPaperSize(GList *tokens, GString *fileName,
576
if (tokens->getLength() == 2) {
577
tok = (GString *)tokens->get(1);
578
if (!setPSPaperSize(tok->getCString())) {
579
error(-1, "Bad 'psPaperSize' config file command (%s:%d)",
580
fileName->getCString(), line);
582
} else if (tokens->getLength() == 3) {
583
tok = (GString *)tokens->get(1);
584
psPaperWidth = atoi(tok->getCString());
585
tok = (GString *)tokens->get(2);
586
psPaperHeight = atoi(tok->getCString());
588
error(-1, "Bad 'psPaperSize' config file command (%s:%d)",
589
fileName->getCString(), line);
593
void GlobalParams::parsePSLevel(GList *tokens, GString *fileName, int line) {
596
if (tokens->getLength() != 2) {
597
error(-1, "Bad 'psLevel' config file command (%s:%d)",
598
fileName->getCString(), line);
601
tok = (GString *)tokens->get(1);
602
if (!tok->cmp("level1")) {
604
} else if (!tok->cmp("level1sep")) {
605
psLevel = psLevel1Sep;
606
} else if (!tok->cmp("level2")) {
608
} else if (!tok->cmp("level2sep")) {
609
psLevel = psLevel2Sep;
610
} else if (!tok->cmp("level3")) {
612
} else if (!tok->cmp("level3Sep")) {
613
psLevel = psLevel3Sep;
615
error(-1, "Bad 'psLevel' config file command (%s:%d)",
616
fileName->getCString(), line);
620
void GlobalParams::parsePSFile(GList *tokens, GString *fileName, int line) {
621
if (tokens->getLength() != 2) {
622
error(-1, "Bad 'psFile' config file command (%s:%d)",
623
fileName->getCString(), line);
629
psFile = ((GString *)tokens->get(1))->copy();
632
void GlobalParams::parsePSFont(GList *tokens, GString *fileName, int line) {
635
if (tokens->getLength() != 3) {
636
error(-1, "Bad 'psFont' config file command (%s:%d)",
637
fileName->getCString(), line);
640
param = new PSFontParam(((GString *)tokens->get(1))->copy(), 0,
641
((GString *)tokens->get(2))->copy(), NULL);
642
psFonts->add(param->pdfFontName, param);
645
void GlobalParams::parsePSFont16(char *cmdName, GList *fontList,
646
GList *tokens, GString *fileName, int line) {
651
if (tokens->getLength() != 5) {
652
error(-1, "Bad '%s' config file command (%s:%d)",
653
cmdName, fileName->getCString(), line);
656
tok = (GString *)tokens->get(2);
657
if (!tok->cmp("H")) {
659
} else if (!tok->cmp("V")) {
662
error(-1, "Bad '%s' config file command (%s:%d)",
663
cmdName, fileName->getCString(), line);
666
param = new PSFontParam(((GString *)tokens->get(1))->copy(),
668
((GString *)tokens->get(3))->copy(),
669
((GString *)tokens->get(4))->copy());
670
fontList->append(param);
673
void GlobalParams::parseTextEncoding(GList *tokens, GString *fileName,
675
if (tokens->getLength() != 2) {
676
error(-1, "Bad 'textEncoding' config file command (%s:%d)",
677
fileName->getCString(), line);
681
textEncoding = ((GString *)tokens->get(1))->copy();
684
void GlobalParams::parseTextEOL(GList *tokens, GString *fileName, int line) {
687
if (tokens->getLength() != 2) {
688
error(-1, "Bad 'textEOL' config file command (%s:%d)",
689
fileName->getCString(), line);
692
tok = (GString *)tokens->get(1);
693
if (!tok->cmp("unix")) {
695
} else if (!tok->cmp("dos")) {
697
} else if (!tok->cmp("mac")) {
700
error(-1, "Bad 'textEOL' config file command (%s:%d)",
701
fileName->getCString(), line);
705
void GlobalParams::parseFontDir(GList *tokens, GString *fileName, int line) {
706
if (tokens->getLength() != 2) {
707
error(-1, "Bad 'fontDir' config file command (%s:%d)",
708
fileName->getCString(), line);
711
fontDirs->append(((GString *)tokens->get(1))->copy());
714
void GlobalParams::parseInitialZoom(GList *tokens,
715
GString *fileName, int line) {
716
if (tokens->getLength() != 2) {
717
error(-1, "Bad 'initialZoom' config file command (%s:%d)",
718
fileName->getCString(), line);
722
initialZoom = ((GString *)tokens->get(1))->copy();
725
void GlobalParams::parseFontRastControl(char *cmdName, FontRastControl *val,
726
GList *tokens, GString *fileName,
730
if (tokens->getLength() != 2) {
731
error(-1, "Bad '%s' config file command (%s:%d)",
732
cmdName, fileName->getCString(), line);
735
tok = (GString *)tokens->get(1);
736
if (!setFontRastControl(val, tok->getCString())) {
737
error(-1, "Bad '%s' config file command (%s:%d)",
738
cmdName, fileName->getCString(), line);
742
void GlobalParams::parseCommand(char *cmdName, GString **val,
743
GList *tokens, GString *fileName, int line) {
744
if (tokens->getLength() != 2) {
745
error(-1, "Bad '%s' config file command (%s:%d)",
746
cmdName, fileName->getCString(), line);
752
*val = ((GString *)tokens->get(1))->copy();
755
void GlobalParams::parseYesNo(char *cmdName, GBool *flag,
756
GList *tokens, GString *fileName, int line) {
759
if (tokens->getLength() != 2) {
760
error(-1, "Bad '%s' config file command (%s:%d)",
761
cmdName, fileName->getCString(), line);
764
tok = (GString *)tokens->get(1);
765
if (!tok->cmp("yes")) {
767
} else if (!tok->cmp("no")) {
770
error(-1, "Bad '%s' config file command (%s:%d)",
771
cmdName, fileName->getCString(), line);
775
GlobalParams::~GlobalParams() {
780
freeBuiltinFontTables();
782
delete macRomanReverseMap;
784
delete nameToUnicode;
785
deleteGHash(cidToUnicodes, GString);
786
deleteGHash(residentUnicodeMaps, UnicodeMap);
787
deleteGHash(unicodeMaps, GString);
788
deleteGList(toUnicodeDirs, GString);
789
deleteGHash(displayFonts, DisplayFontParam);
790
deleteGHash(displayCIDFonts, DisplayFontParam);
791
deleteGHash(displayNamedCIDFonts, DisplayFontParam);
795
deleteGHash(psFonts, PSFontParam);
796
deleteGList(psNamedFonts16, PSFontParam);
797
deleteGList(psFonts16, PSFontParam);
799
deleteGList(fontDirs, GString);
808
cMapDirs->startIter(&iter);
809
while (cMapDirs->getNext(&iter, &key, (void **)&list)) {
810
deleteGList(list, GString);
814
delete cidToUnicodeCache;
815
delete unicodeMapCache;
819
gDestroyMutex(&mutex);
823
//------------------------------------------------------------------------
825
//------------------------------------------------------------------------
827
CharCode GlobalParams::getMacRomanCharCode(char *charName) {
828
return macRomanReverseMap->lookup(charName);
831
Unicode GlobalParams::mapNameToUnicode(char *charName) {
832
return nameToUnicode->lookup(charName);
835
OCFILE *GlobalParams::getCIDToUnicodeFile(GString *collection) {
838
if (!(fileName = (GString *)cidToUnicodes->lookup(collection))) {
841
return ocfopen(fileName->getCString(), "r");
844
UnicodeMap *GlobalParams::getResidentUnicodeMap(GString *encodingName) {
845
return (UnicodeMap *)residentUnicodeMaps->lookup(encodingName);
848
OCFILE *GlobalParams::getUnicodeMapFile(GString *encodingName) {
851
if (!(fileName = (GString *)unicodeMaps->lookup(encodingName))) {
854
return ocfopen(fileName->getCString(), "r");
857
OCFILE *GlobalParams::findCMapFile(GString *collection, GString *cMapName) {
865
if (!(list = (GList *)cMapDirs->lookup(collection))) {
868
for (i = 0; i < list->getLength(); ++i) {
869
dir = (GString *)list->get(i);
870
fileName = appendToPath(dir->copy(), cMapName->getCString());
871
f = ocfopen(fileName->getCString(), "r");
881
OCFILE *GlobalParams::findToUnicodeFile(GString *name) {
883
GString *dir, *fileName;
887
for (i = 0; i < toUnicodeDirs->getLength(); ++i) {
888
dir = (GString *)toUnicodeDirs->get(i);
889
fileName = appendToPath(dir->copy(), name->getCString());
890
f = ocfopen(fileName->getCString(), "r");
900
DisplayFontParam *GlobalParams::getDisplayFont(GString *fontName) {
901
DisplayFontParam *dfp;
904
dfp = (DisplayFontParam *)displayFonts->lookup(fontName);
909
DisplayFontParam *GlobalParams::getDisplayCIDFont(GString *fontName,
910
GString *collection) {
911
DisplayFontParam *dfp;
914
!(dfp = (DisplayFontParam *)displayNamedCIDFonts->lookup(fontName))) {
915
dfp = (DisplayFontParam *)displayCIDFonts->lookup(collection);
920
GString *GlobalParams::getPSFile() {
924
s = psFile ? psFile->copy() : (GString *)NULL;
929
int GlobalParams::getPSPaperWidth() {
938
int GlobalParams::getPSPaperHeight() {
947
GBool GlobalParams::getPSDuplex() {
956
PSLevel GlobalParams::getPSLevel() {
965
PSFontParam *GlobalParams::getPSFont(GString *fontName) {
966
return (PSFontParam *)psFonts->lookup(fontName);
969
PSFontParam *GlobalParams::getPSFont16(GString *fontName,
970
GString *collection, int wMode) {
976
for (i = 0; i < psNamedFonts16->getLength(); ++i) {
977
p = (PSFontParam *)psNamedFonts16->get(i);
978
if (!p->pdfFontName->cmp(fontName) &&
985
if (!p && collection) {
986
for (i = 0; i < psFonts16->getLength(); ++i) {
987
p = (PSFontParam *)psFonts16->get(i);
988
if (!p->pdfFontName->cmp(collection) &&
998
GBool GlobalParams::getPSEmbedType1() {
1007
GBool GlobalParams::getPSEmbedTrueType() {
1011
e = psEmbedTrueType;
1016
GBool GlobalParams::getPSEmbedCIDPostScript() {
1020
e = psEmbedCIDPostScript;
1025
GBool GlobalParams::getPSEmbedCIDTrueType() {
1029
e = psEmbedCIDTrueType;
1034
GBool GlobalParams::getPSOPI() {
1043
GBool GlobalParams::getPSASCIIHex() {
1052
EndOfLineKind GlobalParams::getTextEOL() {
1061
GBool GlobalParams::getTextKeepTinyChars() {
1065
tiny = textKeepTinyChars;
1070
GString *GlobalParams::findFontFile(GString *fontName,
1071
char *ext1, char *ext2) {
1073
GString *dir, *fileName;
1077
for (i = 0; i < fontDirs->getLength(); ++i) {
1078
dir = (GString *)fontDirs->get(i);
1080
fileName = appendToPath(dir->copy(), fontName->getCString());
1081
fileName->append(ext1);
1082
if ((f = ocfopen(fileName->getCString(), "r"))) {
1089
fileName = appendToPath(dir->copy(), fontName->getCString());
1090
fileName->append(ext2);
1091
if ((f = ocfopen(fileName->getCString(), "r"))) {
1102
GString *GlobalParams::getInitialZoom() {
1106
s = initialZoom->copy();
1111
FontRastControl GlobalParams::getT1libControl() {
1120
FontRastControl GlobalParams::getFreeTypeControl() {
1124
c = freetypeControl;
1129
GBool GlobalParams::getMapNumericCharNames() {
1133
map = mapNumericCharNames;
1138
GBool GlobalParams::getPrintCommands() {
1147
GBool GlobalParams::getErrQuiet() {
1156
CharCodeToUnicode *GlobalParams::getCIDToUnicode(GString *collection) {
1157
CharCodeToUnicode *ctu;
1160
ctu = cidToUnicodeCache->getCIDToUnicode(collection);
1165
UnicodeMap *GlobalParams::getUnicodeMap(GString *encodingName) {
1169
map = getUnicodeMap2(encodingName);
1174
UnicodeMap *GlobalParams::getUnicodeMap2(GString *encodingName) {
1177
if ((map = getResidentUnicodeMap(encodingName))) {
1180
map = unicodeMapCache->getUnicodeMap(encodingName);
1185
CMap *GlobalParams::getCMap(GString *collection, GString *cMapName) {
1189
cMap = cMapCache->getCMap(collection, cMapName);
1194
UnicodeMap *GlobalParams::getTextEncoding() {
1198
map = getUnicodeMap2(textEncoding);
1203
//------------------------------------------------------------------------
1204
// functions to set parameters
1205
//------------------------------------------------------------------------
1207
void GlobalParams::addDisplayFont(DisplayFontParam *param) {
1208
DisplayFontParam *old;
1211
if ((old = (DisplayFontParam *)displayFonts->remove(param->name))) {
1214
displayFonts->add(param->name, param);
1218
void GlobalParams::setPSFile(char *file) {
1223
psFile = new GString(file);
1227
GBool GlobalParams::setPSPaperSize(char *size) {
1229
if (!strcmp(size, "letter")) {
1231
psPaperHeight = 792;
1232
} else if (!strcmp(size, "legal")) {
1234
psPaperHeight = 1008;
1235
} else if (!strcmp(size, "A4")) {
1237
psPaperHeight = 842;
1238
} else if (!strcmp(size, "A3")) {
1240
psPaperHeight = 1190;
1249
void GlobalParams::setPSPaperWidth(int width) {
1251
psPaperWidth = width;
1255
void GlobalParams::setPSPaperHeight(int height) {
1257
psPaperHeight = height;
1261
void GlobalParams::setPSDuplex(GBool duplex) {
1267
void GlobalParams::setPSLevel(PSLevel level) {
1273
void GlobalParams::setPSEmbedType1(GBool embed) {
1275
psEmbedType1 = embed;
1279
void GlobalParams::setPSEmbedTrueType(GBool embed) {
1281
psEmbedTrueType = embed;
1285
void GlobalParams::setPSEmbedCIDPostScript(GBool embed) {
1287
psEmbedCIDPostScript = embed;
1291
void GlobalParams::setPSEmbedCIDTrueType(GBool embed) {
1293
psEmbedCIDTrueType = embed;
1297
void GlobalParams::setPSOPI(GBool opi) {
1303
void GlobalParams::setPSASCIIHex(GBool hex) {
1309
void GlobalParams::setTextEncoding(char *encodingName) {
1311
delete textEncoding;
1312
textEncoding = new GString(encodingName);
1316
GBool GlobalParams::setTextEOL(char *s) {
1318
if (!strcmp(s, "unix")) {
1320
} else if (!strcmp(s, "dos")) {
1322
} else if (!strcmp(s, "mac")) {
1332
void GlobalParams::setTextKeepTinyChars(GBool keep) {
1334
textKeepTinyChars = keep;
1338
void GlobalParams::setInitialZoom(char *s) {
1341
initialZoom = new GString(s);
1345
GBool GlobalParams::setT1libControl(char *s) {
1349
ok = setFontRastControl(&t1libControl, s);
1354
GBool GlobalParams::setFreeTypeControl(char *s) {
1358
ok = setFontRastControl(&freetypeControl, s);
1363
GBool GlobalParams::setFontRastControl(FontRastControl *val, char *s) {
1364
if (!strcmp(s, "none")) {
1365
*val = fontRastNone;
1366
} else if (!strcmp(s, "plain")) {
1367
*val = fontRastPlain;
1368
} else if (!strcmp(s, "low")) {
1369
*val = fontRastAALow;
1370
} else if (!strcmp(s, "high")) {
1371
*val = fontRastAAHigh;
1378
void GlobalParams::setMapNumericCharNames(GBool map) {
1380
mapNumericCharNames = map;
1384
void GlobalParams::setPrintCommands(GBool printCommandsA) {
1386
printCommands = printCommandsA;
1390
void GlobalParams::setErrQuiet(GBool errQuietA) {
1392
errQuiet = errQuietA;