26#include "NameToCharCode.h"
27#include "CharCodeToUnicode.h"
28#include "UnicodeMap.h"
30#include "BuiltinFontTables.h"
31#include "FontEncodingTables.h"
32#include "GlobalParams.h"
34#include "NameToUnicodeTable.h"
35#include "UnicodeMapTables.h"
36#include "DisplayFontTable.h"
41GlobalParams *globalParams = NULL;
47DisplayFontParam::DisplayFontParam(GString *nameA,
48 DisplayFontParamKind kindA) {
65DisplayFontParam::DisplayFontParam(
const char *nameA,
const char *xlfdA,
66 const char *encodingA) {
67 name =
new GString(nameA);
69 x.xlfd =
new GString(xlfdA);
70 x.encoding =
new GString(encodingA);
73DisplayFontParam::~DisplayFontParam() {
101PSFontParam::PSFontParam(GString *pdfFontNameA,
int wModeA,
102 GString *psFontNameA, GString *encodingA) {
103 pdfFontName = pdfFontNameA;
105 psFontName = psFontNameA;
106 encoding = encodingA;
109PSFontParam::~PSFontParam() {
121GlobalParams::GlobalParams(
const char *cfgFileName) {
123 DisplayFontParam *dfp;
128 initBuiltinFontTables();
132 macRomanReverseMap =
new NameToCharCode();
133 for (i = 255; i >= 0; --i) {
134 if (macRomanEncoding[i]) {
135 macRomanReverseMap->add(macRomanEncoding[i], (CharCode)i);
139 nameToUnicode =
new NameToCharCode();
140 cidToUnicodes =
new GHash(gTrue);
141 residentUnicodeMaps =
new GHash();
142 unicodeMaps =
new GHash(gTrue);
143 cMapDirs =
new GHash(gTrue);
144 toUnicodeDirs =
new GList();
145 displayFonts =
new GHash();
146 displayCIDFonts =
new GHash();
147 displayNamedCIDFonts =
new GHash();
149 const char *paperName;
150 const struct paper *paperType;
152 if ((paperName = systempapername())) {
153 paperType = paperinfo(paperName);
154 psPaperWidth = (int)paperpswidth(paperType);
155 psPaperHeight = (int)paperpsheight(paperType);
157 error(-1,
"No paper information available - using defaults");
158 psPaperWidth = defPaperWidth;
159 psPaperHeight = defPaperHeight;
163 psPaperWidth = defPaperWidth;
164 psPaperHeight = defPaperHeight;
169 psFonts =
new GHash();
170 psNamedFonts16 =
new GList();
171 psFonts16 =
new GList();
172 psEmbedType1 = gTrue;
173 psEmbedTrueType = gTrue;
174 psEmbedCIDPostScript = gTrue;
175 psEmbedCIDTrueType = gTrue;
178 textEncoding =
new GString(
"Latin1");
186 textKeepTinyChars = gFalse;
187 fontDirs =
new GList();
188 initialZoom =
new GString(
"1");
189 t1libControl = fontRastAALow;
190 freetypeControl = fontRastAALow;
193 mapNumericCharNames = gTrue;
194 printCommands = gFalse;
197 cidToUnicodeCache =
new CIDToUnicodeCache();
198 unicodeMapCache =
new UnicodeMapCache();
199 cMapCache =
new CMapCache();
202 for (i = 0; nameToUnicodeTab[i].name; ++i) {
203 nameToUnicode->add(nameToUnicodeTab[i].name, nameToUnicodeTab[i].u);
207 map =
new UnicodeMap(
"Latin1", gFalse,
208 latin1UnicodeMapRanges, latin1UnicodeMapLen);
209 residentUnicodeMaps->add(map->getEncodingName(), map);
210 map =
new UnicodeMap(
"ASCII7", gFalse,
211 ascii7UnicodeMapRanges, ascii7UnicodeMapLen);
212 residentUnicodeMaps->add(map->getEncodingName(), map);
213 map =
new UnicodeMap(
"Symbol", gFalse,
214 symbolUnicodeMapRanges, symbolUnicodeMapLen);
215 residentUnicodeMaps->add(map->getEncodingName(), map);
216 map =
new UnicodeMap(
"ZapfDingbats", gFalse, zapfDingbatsUnicodeMapRanges,
217 zapfDingbatsUnicodeMapLen);
218 residentUnicodeMaps->add(map->getEncodingName(), map);
219 map =
new UnicodeMap(
"UTF-8", gTrue, &mapUTF8);
220 residentUnicodeMaps->add(map->getEncodingName(), map);
221 map =
new UnicodeMap(
"UCS-2", gTrue, &mapUCS2);
222 residentUnicodeMaps->add(map->getEncodingName(), map);
225 for (i = 0; displayFontTab[i].name; ++i) {
226 dfp =
new DisplayFontParam(displayFontTab[i].name,
227 displayFontTab[i].xlfd,
228 displayFontTab[i].encoding);
229 displayFonts->add(dfp->name, dfp);
235 if (cfgFileName && cfgFileName[0]) {
236 fileName =
new GString(cfgFileName);
237 if (!(f = fopen(fileName->getCString(),
"r"))) {
242 fileName = appendToPath(getHomeDir(), xpdfUserConfigFile);
243 if (!(f = fopen(fileName->getCString(),
"r"))) {
248#if defined(WIN32) && !defined(__CYGWIN32__)
250 i = GetModuleFileName(NULL, buf,
sizeof(buf));
251 if (i <= 0 || i >=
sizeof(buf)) {
255 fileName = grabPath(buf);
256 appendToPath(fileName, xpdfSysConfigFile);
258 fileName =
new GString(xpdfSysConfigFile);
260 if (!(f = fopen(fileName->getCString(),
"r"))) {
265 parseFile(fileName, f);
271void GlobalParams::parseFile(GString *fileName, FILE *f) {
274 GString *cmd, *incFile;
280 while (fgets(buf,
sizeof(buf) - 1, f)) {
283 tokens =
new GList();
286 for (; *p1 && isspace(*p1); ++p1) ;
290 if (*p1 ==
'"' || *p1 ==
'\'') {
291 for (p2 = p1 + 1; *p2 && *p2 != *p1; ++p2) ;
294 for (p2 = p1 + 1; *p2 && !isspace(*p2); ++p2) ;
296 tokens->append(
new GString(p1, p2 - p1));
300 if (tokens->getLength() > 0 &&
301 ((GString *)tokens->get(0))->getChar(0) !=
'#') {
302 cmd = (GString *)tokens->get(0);
303 if (!cmd->cmp(
"include")) {
304 if (tokens->getLength() == 2) {
305 incFile = (GString *)tokens->get(1);
306 if ((f2 = fopen(incFile->getCString(),
"r"))) {
307 parseFile(incFile, f2);
310 error(-1,
"Couldn't find included config file: '%s' (%s:%d)",
311 incFile->getCString(), fileName->getCString(), line);
314 error(-1,
"Bad 'include' config file command (%s:%d)",
315 fileName->getCString(), line);
317 }
else if (!cmd->cmp(
"nameToUnicode")) {
318 parseNameToUnicode(tokens, fileName, line);
319 }
else if (!cmd->cmp(
"cidToUnicode")) {
320 parseCIDToUnicode(tokens, fileName, line);
321 }
else if (!cmd->cmp(
"unicodeMap")) {
322 parseUnicodeMap(tokens, fileName, line);
323 }
else if (!cmd->cmp(
"cMapDir")) {
324 parseCMapDir(tokens, fileName, line);
325 }
else if (!cmd->cmp(
"toUnicodeDir")) {
326 parseToUnicodeDir(tokens, fileName, line);
327 }
else if (!cmd->cmp(
"displayFontX")) {
328 parseDisplayFont(tokens, displayFonts, displayFontX, fileName, line);
329 }
else if (!cmd->cmp(
"displayFontT1")) {
330 parseDisplayFont(tokens, displayFonts, displayFontT1, fileName, line);
331 }
else if (!cmd->cmp(
"displayFontTT")) {
332 parseDisplayFont(tokens, displayFonts, displayFontTT, fileName, line);
333 }
else if (!cmd->cmp(
"displayCIDFontX")) {
334 parseDisplayFont(tokens, displayCIDFonts,
335 displayFontX, fileName, line);
336 }
else if (!cmd->cmp(
"displayNamedCIDFontX")) {
337 parseDisplayFont(tokens, displayNamedCIDFonts,
338 displayFontX, fileName, line);
339 }
else if (!cmd->cmp(
"psFile")) {
340 parsePSFile(tokens, fileName, line);
341 }
else if (!cmd->cmp(
"psFont")) {
342 parsePSFont(tokens, fileName, line);
343 }
else if (!cmd->cmp(
"psNamedFont16")) {
344 parsePSFont16(
"psNamedFont16", psNamedFonts16,
345 tokens, fileName, line);
346 }
else if (!cmd->cmp(
"psFont16")) {
347 parsePSFont16(
"psFont16", psFonts16, tokens, fileName, line);
348 }
else if (!cmd->cmp(
"psPaperSize")) {
349 parsePSPaperSize(tokens, fileName, line);
350 }
else if (!cmd->cmp(
"psDuplex")) {
351 parseYesNo(
"psDuplex", &psDuplex, tokens, fileName, line);
352 }
else if (!cmd->cmp(
"psLevel")) {
353 parsePSLevel(tokens, fileName, line);
354 }
else if (!cmd->cmp(
"psEmbedType1Fonts")) {
355 parseYesNo(
"psEmbedType1", &psEmbedType1, tokens, fileName, line);
356 }
else if (!cmd->cmp(
"psEmbedTrueTypeFonts")) {
357 parseYesNo(
"psEmbedTrueType", &psEmbedTrueType,
358 tokens, fileName, line);
359 }
else if (!cmd->cmp(
"psEmbedCIDPostScriptFonts")) {
360 parseYesNo(
"psEmbedCIDPostScript", &psEmbedCIDPostScript,
361 tokens, fileName, line);
362 }
else if (!cmd->cmp(
"psEmbedCIDTrueTypeFonts")) {
363 parseYesNo(
"psEmbedCIDTrueType", &psEmbedCIDTrueType,
364 tokens, fileName, line);
365 }
else if (!cmd->cmp(
"psOPI")) {
366 parseYesNo(
"psOPI", &psOPI, tokens, fileName, line);
367 }
else if (!cmd->cmp(
"psASCIIHex")) {
368 parseYesNo(
"psASCIIHex", &psASCIIHex, tokens, fileName, line);
369 }
else if (!cmd->cmp(
"textEncoding")) {
370 parseTextEncoding(tokens, fileName, line);
371 }
else if (!cmd->cmp(
"textEOL")) {
372 parseTextEOL(tokens, fileName, line);
373 }
else if (!cmd->cmp(
"textKeepTinyChars")) {
374 parseYesNo(
"textKeepTinyChars", &textKeepTinyChars,
375 tokens, fileName, line);
376 }
else if (!cmd->cmp(
"fontDir")) {
377 parseFontDir(tokens, fileName, line);
378 }
else if (!cmd->cmp(
"initialZoom")) {
379 parseInitialZoom(tokens, fileName, line);
380 }
else if (!cmd->cmp(
"t1libControl")) {
381 parseFontRastControl(
"t1libControl", &t1libControl,
382 tokens, fileName, line);
383 }
else if (!cmd->cmp(
"freetypeControl")) {
384 parseFontRastControl(
"freetypeControl", &freetypeControl,
385 tokens, fileName, line);
386 }
else if (!cmd->cmp(
"urlCommand")) {
387 parseCommand(
"urlCommand", &urlCommand, tokens, fileName, line);
388 }
else if (!cmd->cmp(
"movieCommand")) {
389 parseCommand(
"movieCommand", &movieCommand, tokens, fileName, line);
390 }
else if (!cmd->cmp(
"mapNumericCharNames")) {
391 parseYesNo(
"mapNumericCharNames", &mapNumericCharNames,
392 tokens, fileName, line);
393 }
else if (!cmd->cmp(
"printCommands")) {
394 parseYesNo(
"printCommands", &printCommands, tokens, fileName, line);
395 }
else if (!cmd->cmp(
"errQuiet")) {
396 parseYesNo(
"errQuiet", &errQuiet, tokens, fileName, line);
397 }
else if (!cmd->cmp(
"fontpath") || !cmd->cmp(
"fontmap")) {
398 error(-1,
"Unknown config file command");
399 error(-1,
"-- the config file format has changed since Xpdf 0.9x");
401 error(-1,
"Unknown config file command '%s' (%s:%d)",
402 cmd->getCString(), fileName->getCString(), line);
406 deleteGList(tokens, GString);
411void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
420 if (tokens->getLength() != 2) {
421 error(-1,
"Bad 'nameToUnicode' config file command (%s:%d)",
422 fileName->getCString(), line);
425 name = (GString *)tokens->get(1);
426 if (!(f = fopen(name->getCString(),
"r"))) {
427 error(-1,
"Couldn't open 'nameToUnicode' file '%s'",
432 while (fgets(buf,
sizeof(buf), f)) {
433 tok1 = strtok(buf,
" \t\r\n");
434 tok2 = strtok(NULL,
" \t\r\n");
436 sscanf(tok1,
"%x", &u);
437 nameToUnicode->add(tok2, u);
439 error(-1,
"Bad line in 'nameToUnicode' file (%s:%d)", name, line2);
446void GlobalParams::parseCIDToUnicode(GList *tokens, GString *fileName,
448 GString *collection, *name, *old;
450 if (tokens->getLength() != 3) {
451 error(-1,
"Bad 'cidToUnicode' config file command (%s:%d)",
452 fileName->getCString(), line);
455 collection = (GString *)tokens->get(1);
456 name = (GString *)tokens->get(2);
457 if ((old = (GString *)cidToUnicodes->remove(collection))) {
460 cidToUnicodes->add(collection->copy(), name->copy());
463void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
465 GString *encodingName, *name, *old;
467 if (tokens->getLength() != 3) {
468 error(-1,
"Bad 'unicodeMap' config file command (%s:%d)",
469 fileName->getCString(), line);
472 encodingName = (GString *)tokens->get(1);
473 name = (GString *)tokens->get(2);
474 if ((old = (GString *)unicodeMaps->remove(encodingName))) {
477 unicodeMaps->add(encodingName->copy(), name->copy());
480void GlobalParams::parseCMapDir(GList *tokens, GString *fileName,
int line) {
481 GString *collection, *dir;
484 if (tokens->getLength() != 3) {
485 error(-1,
"Bad 'cMapDir' config file command (%s:%d)",
486 fileName->getCString(), line);
489 collection = (GString *)tokens->get(1);
490 dir = (GString *)tokens->get(2);
491 if (!(list = (GList *)cMapDirs->lookup(collection))) {
493 cMapDirs->add(collection->copy(), list);
495 list->append(dir->copy());
498void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
500 if (tokens->getLength() != 2) {
501 error(-1,
"Bad 'toUnicodeDir' config file command (%s:%d)",
502 fileName->getCString(), line);
505 toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
508void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
509 DisplayFontParamKind kind,
510 GString *fileName,
int line) {
511 DisplayFontParam *param, *old;
513 if (tokens->getLength() < 2) {
516 param =
new DisplayFontParam(((GString *)tokens->get(1))->copy(), kind);
520 if (tokens->getLength() != 4) {
523 param->x.xlfd = ((GString *)tokens->get(2))->copy();
524 param->x.encoding = ((GString *)tokens->get(3))->copy();
527 if (tokens->getLength() != 3) {
530 param->t1.fileName = ((GString *)tokens->get(2))->copy();
533 if (tokens->getLength() != 3) {
536 param->tt.fileName = ((GString *)tokens->get(2))->copy();
540 if ((old = (DisplayFontParam *)fontHash->remove(param->name))) {
543 fontHash->add(param->name, param);
549 error(-1,
"Bad 'display*Font*' config file command (%s:%d)",
550 fileName->getCString(), line);
553void GlobalParams::parsePSPaperSize(GList *tokens, GString *fileName,
557 if (tokens->getLength() == 2) {
558 tok = (GString *)tokens->get(1);
559 if (!setPSPaperSize(tok->getCString())) {
560 error(-1,
"Bad 'psPaperSize' config file command (%s:%d)",
561 fileName->getCString(), line);
563 }
else if (tokens->getLength() == 3) {
564 tok = (GString *)tokens->get(1);
565 psPaperWidth = atoi(tok->getCString());
566 tok = (GString *)tokens->get(2);
567 psPaperHeight = atoi(tok->getCString());
569 error(-1,
"Bad 'psPaperSize' config file command (%s:%d)",
570 fileName->getCString(), line);
574void GlobalParams::parsePSLevel(GList *tokens, GString *fileName,
int line) {
577 if (tokens->getLength() != 2) {
578 error(-1,
"Bad 'psLevel' config file command (%s:%d)",
579 fileName->getCString(), line);
582 tok = (GString *)tokens->get(1);
583 if (!tok->cmp(
"level1")) {
585 }
else if (!tok->cmp(
"level1sep")) {
586 psLevel = psLevel1Sep;
587 }
else if (!tok->cmp(
"level2")) {
589 }
else if (!tok->cmp(
"level2sep")) {
590 psLevel = psLevel2Sep;
591 }
else if (!tok->cmp(
"level3")) {
593 }
else if (!tok->cmp(
"level3Sep")) {
594 psLevel = psLevel3Sep;
596 error(-1,
"Bad 'psLevel' config file command (%s:%d)",
597 fileName->getCString(), line);
601void GlobalParams::parsePSFile(GList *tokens, GString *fileName,
int line) {
602 if (tokens->getLength() != 2) {
603 error(-1,
"Bad 'psFile' config file command (%s:%d)",
604 fileName->getCString(), line);
610 psFile = ((GString *)tokens->get(1))->copy();
613void GlobalParams::parsePSFont(GList *tokens, GString *fileName,
int line) {
616 if (tokens->getLength() != 3) {
617 error(-1,
"Bad 'psFont' config file command (%s:%d)",
618 fileName->getCString(), line);
621 param =
new PSFontParam(((GString *)tokens->get(1))->copy(), 0,
622 ((GString *)tokens->get(2))->copy(), NULL);
623 psFonts->add(param->pdfFontName, param);
626void GlobalParams::parsePSFont16(
const char *cmdName, GList *fontList,
627 GList *tokens, GString *fileName,
int line) {
632 if (tokens->getLength() != 5) {
633 error(-1,
"Bad '%s' config file command (%s:%d)",
634 cmdName, fileName->getCString(), line);
637 tok = (GString *)tokens->get(2);
638 if (!tok->cmp(
"H")) {
640 }
else if (!tok->cmp(
"V")) {
643 error(-1,
"Bad '%s' config file command (%s:%d)",
644 cmdName, fileName->getCString(), line);
647 param =
new PSFontParam(((GString *)tokens->get(1))->copy(),
649 ((GString *)tokens->get(3))->copy(),
650 ((GString *)tokens->get(4))->copy());
651 fontList->append(param);
654void GlobalParams::parseTextEncoding(GList *tokens, GString *fileName,
656 if (tokens->getLength() != 2) {
657 error(-1,
"Bad 'textEncoding' config file command (%s:%d)",
658 fileName->getCString(), line);
662 textEncoding = ((GString *)tokens->get(1))->copy();
665void GlobalParams::parseTextEOL(GList *tokens, GString *fileName,
int line) {
668 if (tokens->getLength() != 2) {
669 error(-1,
"Bad 'textEOL' config file command (%s:%d)",
670 fileName->getCString(), line);
673 tok = (GString *)tokens->get(1);
674 if (!tok->cmp(
"unix")) {
676 }
else if (!tok->cmp(
"dos")) {
678 }
else if (!tok->cmp(
"mac")) {
681 error(-1,
"Bad 'textEOL' config file command (%s:%d)",
682 fileName->getCString(), line);
686void GlobalParams::parseFontDir(GList *tokens, GString *fileName,
int line) {
687 if (tokens->getLength() != 2) {
688 error(-1,
"Bad 'fontDir' config file command (%s:%d)",
689 fileName->getCString(), line);
692 fontDirs->append(((GString *)tokens->get(1))->copy());
695void GlobalParams::parseInitialZoom(GList *tokens,
696 GString *fileName,
int line) {
697 if (tokens->getLength() != 2) {
698 error(-1,
"Bad 'initialZoom' config file command (%s:%d)",
699 fileName->getCString(), line);
703 initialZoom = ((GString *)tokens->get(1))->copy();
706void GlobalParams::parseFontRastControl(
const char *cmdName, FontRastControl *val,
707 GList *tokens, GString *fileName,
711 if (tokens->getLength() != 2) {
712 error(-1,
"Bad '%s' config file command (%s:%d)",
713 cmdName, fileName->getCString(), line);
716 tok = (GString *)tokens->get(1);
717 if (!setFontRastControl(val, tok->getCString())) {
718 error(-1,
"Bad '%s' config file command (%s:%d)",
719 cmdName, fileName->getCString(), line);
723void GlobalParams::parseCommand(
const char *cmdName, GString **val,
724 GList *tokens, GString *fileName,
int line) {
725 if (tokens->getLength() != 2) {
726 error(-1,
"Bad '%s' config file command (%s:%d)",
727 cmdName, fileName->getCString(), line);
733 *val = ((GString *)tokens->get(1))->copy();
736void GlobalParams::parseYesNo(
const char *cmdName, GBool *flag,
737 GList *tokens, GString *fileName,
int line) {
740 if (tokens->getLength() != 2) {
741 error(-1,
"Bad '%s' config file command (%s:%d)",
742 cmdName, fileName->getCString(), line);
745 tok = (GString *)tokens->get(1);
746 if (!tok->cmp(
"yes")) {
748 }
else if (!tok->cmp(
"no")) {
751 error(-1,
"Bad '%s' config file command (%s:%d)",
752 cmdName, fileName->getCString(), line);
756GlobalParams::~GlobalParams() {
761 freeBuiltinFontTables();
763 delete macRomanReverseMap;
765 delete nameToUnicode;
766 deleteGHash(cidToUnicodes, GString);
767 deleteGHash(residentUnicodeMaps, UnicodeMap);
768 deleteGHash(unicodeMaps, GString);
769 deleteGList(toUnicodeDirs, GString);
770 deleteGHash(displayFonts, DisplayFontParam);
771 deleteGHash(displayCIDFonts, DisplayFontParam);
772 deleteGHash(displayNamedCIDFonts, DisplayFontParam);
776 deleteGHash(psFonts, PSFontParam);
777 deleteGList(psNamedFonts16, PSFontParam);
778 deleteGList(psFonts16, PSFontParam);
780 deleteGList(fontDirs, GString);
789 cMapDirs->startIter(&iter);
790 while (cMapDirs->getNext(&iter, &key, (
void **)&list)) {
791 deleteGList(list, GString);
795 delete cidToUnicodeCache;
796 delete unicodeMapCache;
804CharCode GlobalParams::getMacRomanCharCode(
const char *charName) {
805 return macRomanReverseMap->lookup(charName);
808Unicode GlobalParams::mapNameToUnicode(
const char *charName) {
809 return nameToUnicode->lookup(charName);
812FILE *GlobalParams::getCIDToUnicodeFile(
const GString *collection) {
815 if (!(fileName = (GString *)cidToUnicodes->lookup(collection))) {
818 return fopen(fileName->getCString(),
"r");
821UnicodeMap *GlobalParams::getResidentUnicodeMap(
const GString *encodingName) {
822 return (UnicodeMap *)residentUnicodeMaps->lookup(encodingName);
825FILE *GlobalParams::getUnicodeMapFile(
const GString *encodingName) {
828 if (!(fileName = (GString *)unicodeMaps->lookup(encodingName))) {
831 return fopen(fileName->getCString(),
"r");
834FILE *GlobalParams::findCMapFile(
const GString *collection,
const GString *cMapName) {
841 if (!(list = (GList *)cMapDirs->lookup(collection))) {
844 for (i = 0; i < list->getLength(); ++i) {
845 dir = (GString *)list->get(i);
846 fileName = appendToPath(dir->copy(), cMapName->getCString());
847 f = fopen(fileName->getCString(),
"r");
856FILE *GlobalParams::findToUnicodeFile(
const GString *name) {
857 GString *dir, *fileName;
861 for (i = 0; i < toUnicodeDirs->getLength(); ++i) {
862 dir = (GString *)toUnicodeDirs->get(i);
863 fileName = appendToPath(dir->copy(), name->getCString());
864 f = fopen(fileName->getCString(),
"r");
873DisplayFontParam *GlobalParams::getDisplayFont(
const GString *fontName) {
874 return (DisplayFontParam *)displayFonts->lookup(fontName);
877DisplayFontParam *GlobalParams::getDisplayCIDFont(
const GString *fontName,
878 const GString *collection) {
879 DisplayFontParam *dfp;
882 !(dfp = (DisplayFontParam *)displayNamedCIDFonts->lookup(fontName))) {
883 dfp = (DisplayFontParam *)displayCIDFonts->lookup(collection);
888PSFontParam *GlobalParams::getPSFont(GString *fontName) {
889 return (PSFontParam *)psFonts->lookup(fontName);
892PSFontParam *GlobalParams::getPSFont16(GString *fontName,
893 GString *collection,
int wMode) {
899 for (i = 0; i < psNamedFonts16->getLength(); ++i) {
900 p = (PSFontParam *)psNamedFonts16->get(i);
901 if (!p->pdfFontName->cmp(fontName) &&
908 if (!p && collection) {
909 for (i = 0; i < psFonts16->getLength(); ++i) {
910 p = (PSFontParam *)psFonts16->get(i);
911 if (!p->pdfFontName->cmp(collection) &&
921GString *GlobalParams::findFontFile(
const GString *fontName,
922 const char *ext1,
const char *ext2) {
923 GString *dir, *fileName;
927 for (i = 0; i < fontDirs->getLength(); ++i) {
928 dir = (GString *)fontDirs->get(i);
930 fileName = appendToPath(dir->copy(), fontName->getCString());
931 fileName->append(ext1);
932 if ((f = fopen(fileName->getCString(),
"r"))) {
939 fileName = appendToPath(dir->copy(), fontName->getCString());
940 fileName->append(ext2);
941 if ((f = fopen(fileName->getCString(),
"r"))) {
951CharCodeToUnicode *GlobalParams::getCIDToUnicode(GString *collection) {
952 return cidToUnicodeCache->getCIDToUnicode(collection);
955UnicodeMap *GlobalParams::getUnicodeMap(GString *encodingName) {
958 if ((map = getResidentUnicodeMap(encodingName))) {
962 return unicodeMapCache->getUnicodeMap(encodingName);
965CMap *GlobalParams::getCMap(GString *collection, GString *cMapName) {
966 return cMapCache->getCMap(collection, cMapName);
969UnicodeMap *GlobalParams::getTextEncoding() {
970 return getUnicodeMap(textEncoding);
977void GlobalParams::addDisplayFont(DisplayFontParam *param) {
978 DisplayFontParam *old;
980 if ((old = (DisplayFontParam *)displayFonts->remove(param->name))) {
983 displayFonts->add(param->name, param);
986void GlobalParams::setPSFile(
char *file) {
990 psFile =
new GString(file);
993GBool GlobalParams::setPSPaperSize(
char *size) {
994 if (!strcmp(size,
"letter")) {
997 }
else if (!strcmp(size,
"legal")) {
999 psPaperHeight = 1008;
1000 }
else if (!strcmp(size,
"A4")) {
1002 psPaperHeight = 842;
1003 }
else if (!strcmp(size,
"A3")) {
1005 psPaperHeight = 1190;
1012void GlobalParams::setPSPaperWidth(
int width) {
1013 psPaperWidth = width;
1016void GlobalParams::setPSPaperHeight(
int height) {
1017 psPaperHeight = height;
1020void GlobalParams::setPSDuplex(GBool duplex) {
1024void GlobalParams::setPSLevel(PSLevel level) {
1028void GlobalParams::setPSEmbedType1(GBool embed) {
1029 psEmbedType1 = embed;
1032void GlobalParams::setPSEmbedTrueType(GBool embed) {
1033 psEmbedTrueType = embed;
1036void GlobalParams::setPSEmbedCIDPostScript(GBool embed) {
1037 psEmbedCIDPostScript = embed;
1040void GlobalParams::setPSEmbedCIDTrueType(GBool embed) {
1041 psEmbedCIDTrueType = embed;
1044void GlobalParams::setPSOPI(GBool opi) {
1048void GlobalParams::setPSASCIIHex(GBool hex) {
1052void GlobalParams::setTextEncoding(
char *encodingName) {
1053 delete textEncoding;
1054 textEncoding =
new GString(encodingName);
1057GBool GlobalParams::setTextEOL(
char *s) {
1058 if (!strcmp(s,
"unix")) {
1060 }
else if (!strcmp(s,
"dos")) {
1062 }
else if (!strcmp(s,
"mac")) {
1070void GlobalParams::setTextKeepTinyChars(GBool keep) {
1071 textKeepTinyChars = keep;
1074void GlobalParams::setInitialZoom(
char *s) {
1076 initialZoom =
new GString(s);
1079GBool GlobalParams::setT1libControl(
char *s) {
1080 return setFontRastControl(&t1libControl, s);
1083GBool GlobalParams::setFreeTypeControl(
char *s) {
1084 return setFontRastControl(&freetypeControl, s);
1087GBool GlobalParams::setFontRastControl(FontRastControl *val,
const char *s) {
1088 if (!strcmp(s,
"none")) {
1089 *val = fontRastNone;
1090 }
else if (!strcmp(s,
"plain")) {
1091 *val = fontRastPlain;
1092 }
else if (!strcmp(s,
"low")) {
1093 *val = fontRastAALow;
1094 }
else if (!strcmp(s,
"high")) {
1095 *val = fontRastAAHigh;
1102void GlobalParams::setMapNumericCharNames(GBool map) {
1103 mapNumericCharNames = map;
1106void GlobalParams::setPrintCommands(GBool printCommandsA) {
1107 printCommands = printCommandsA;
1110void GlobalParams::setErrQuiet(GBool errQuietA) {
1111 errQuiet = errQuietA;