author | sandman <sandman> | 2002-05-23 23:51:52 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-05-23 23:51:52 (UTC) |
commit | 2f3bb7b07f833273d966d41813e68bfe8b9d8d76 (patch) (unidiff) | |
tree | 00beb1bd9e7f4ba79e22334a0d258269b28f4564 /noncore/unsupported/qpdf/xpdf/GlobalParams.cc | |
parent | 6e82b45dd416ceeba78765717b700e853c96a137 (diff) | |
download | opie-2f3bb7b07f833273d966d41813e68bfe8b9d8d76.zip opie-2f3bb7b07f833273d966d41813e68bfe8b9d8d76.tar.gz opie-2f3bb7b07f833273d966d41813e68bfe8b9d8d76.tar.bz2 |
Port to xpdf 1.01
Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/GlobalParams.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/xpdf/GlobalParams.cc | 381 |
1 files changed, 265 insertions, 116 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/GlobalParams.cc b/noncore/unsupported/qpdf/xpdf/GlobalParams.cc index 8be58a3..0bc908e 100644 --- a/noncore/unsupported/qpdf/xpdf/GlobalParams.cc +++ b/noncore/unsupported/qpdf/xpdf/GlobalParams.cc | |||
@@ -2,7 +2,7 @@ | |||
2 | // | 2 | // |
3 | // GlobalParams.cc | 3 | // GlobalParams.cc |
4 | // | 4 | // |
5 | // Copyright 2001 Derek B. Noonburg | 5 | // Copyright 2001-2002 Glyph & Cog, LLC |
6 | // | 6 | // |
7 | //======================================================================== | 7 | //======================================================================== |
8 | 8 | ||
@@ -96,14 +96,20 @@ DisplayFontParam::~DisplayFontParam() { | |||
96 | // PSFontParam | 96 | // PSFontParam |
97 | //------------------------------------------------------------------------ | 97 | //------------------------------------------------------------------------ |
98 | 98 | ||
99 | PSFontParam::PSFontParam(GString *pdfFontNameA, GString *psFontNameA) { | 99 | PSFontParam::PSFontParam(GString *pdfFontNameA, int wModeA, |
100 | GString *psFontNameA, GString *encodingA) { | ||
100 | pdfFontName = pdfFontNameA; | 101 | pdfFontName = pdfFontNameA; |
102 | wMode = wModeA; | ||
101 | psFontName = psFontNameA; | 103 | psFontName = psFontNameA; |
104 | encoding = encodingA; | ||
102 | } | 105 | } |
103 | 106 | ||
104 | PSFontParam::~PSFontParam() { | 107 | PSFontParam::~PSFontParam() { |
105 | delete pdfFontName; | 108 | delete pdfFontName; |
106 | delete psFontName; | 109 | delete psFontName; |
110 | if (encoding) { | ||
111 | delete encoding; | ||
112 | } | ||
107 | } | 113 | } |
108 | 114 | ||
109 | //------------------------------------------------------------------------ | 115 | //------------------------------------------------------------------------ |
@@ -115,17 +121,14 @@ GlobalParams::GlobalParams(char *cfgFileName) { | |||
115 | DisplayFontParam *dfp; | 121 | DisplayFontParam *dfp; |
116 | GString *fileName; | 122 | GString *fileName; |
117 | FILE *f; | 123 | FILE *f; |
118 | char buf[512]; | ||
119 | int line; | ||
120 | GList *tokens; | ||
121 | GString *cmd; | ||
122 | char *p1, *p2; | ||
123 | int i; | 124 | int i; |
124 | 125 | ||
125 | initBuiltinFontTables(); | 126 | initBuiltinFontTables(); |
126 | 127 | ||
128 | // scan the encoding in reverse because we want the lowest-numbered | ||
129 | // index for each char name ('space' is encoded twice) | ||
127 | macRomanReverseMap = new NameToCharCode(); | 130 | macRomanReverseMap = new NameToCharCode(); |
128 | for (i = 0; i < 256; ++i) { | 131 | for (i = 255; i >= 0; --i) { |
129 | if (macRomanEncoding[i]) { | 132 | if (macRomanEncoding[i]) { |
130 | macRomanReverseMap->add(macRomanEncoding[i], (CharCode)i); | 133 | macRomanReverseMap->add(macRomanEncoding[i], (CharCode)i); |
131 | } | 134 | } |
@@ -139,6 +142,7 @@ GlobalParams::GlobalParams(char *cfgFileName) { | |||
139 | toUnicodeDirs = new GList(); | 142 | toUnicodeDirs = new GList(); |
140 | displayFonts = new GHash(); | 143 | displayFonts = new GHash(); |
141 | displayCIDFonts = new GHash(); | 144 | displayCIDFonts = new GHash(); |
145 | displayNamedCIDFonts = new GHash(); | ||
142 | #if HAVE_PAPER_H | 146 | #if HAVE_PAPER_H |
143 | const struct paper *paperType; | 147 | const struct paper *paperType; |
144 | paperinit(); | 148 | paperinit(); |
@@ -154,9 +158,14 @@ GlobalParams::GlobalParams(char *cfgFileName) { | |||
154 | psLevel = psLevel2; | 158 | psLevel = psLevel2; |
155 | psFile = NULL; | 159 | psFile = NULL; |
156 | psFonts = new GHash(); | 160 | psFonts = new GHash(); |
161 | psNamedFonts16 = new GList(); | ||
162 | psFonts16 = new GList(); | ||
157 | psEmbedType1 = gTrue; | 163 | psEmbedType1 = gTrue; |
158 | psEmbedTrueType = gTrue; | 164 | psEmbedTrueType = gTrue; |
165 | psEmbedCIDPostScript = gTrue; | ||
166 | psEmbedCIDTrueType = gTrue; | ||
159 | psOPI = gFalse; | 167 | psOPI = gFalse; |
168 | psASCIIHex = gFalse; | ||
160 | textEncoding = new GString("Latin1"); | 169 | textEncoding = new GString("Latin1"); |
161 | #if defined(WIN32) | 170 | #if defined(WIN32) |
162 | textEOL = eolDOS; | 171 | textEOL = eolDOS; |
@@ -166,6 +175,7 @@ GlobalParams::GlobalParams(char *cfgFileName) { | |||
166 | textEOL = eolUnix; | 175 | textEOL = eolUnix; |
167 | #endif | 176 | #endif |
168 | fontDirs = new GList(); | 177 | fontDirs = new GList(); |
178 | initialZoom = new GString("1"); | ||
169 | t1libControl = fontRastAALow; | 179 | t1libControl = fontRastAALow; |
170 | freetypeControl = fontRastAALow; | 180 | freetypeControl = fontRastAALow; |
171 | urlCommand = NULL; | 181 | urlCommand = NULL; |
@@ -193,6 +203,8 @@ GlobalParams::GlobalParams(char *cfgFileName) { | |||
193 | residentUnicodeMaps->add(map->getEncodingName(), map); | 203 | residentUnicodeMaps->add(map->getEncodingName(), map); |
194 | map = new UnicodeMap("UTF-8", &mapUTF8); | 204 | map = new UnicodeMap("UTF-8", &mapUTF8); |
195 | residentUnicodeMaps->add(map->getEncodingName(), map); | 205 | residentUnicodeMaps->add(map->getEncodingName(), map); |
206 | map = new UnicodeMap("UCS-2", &mapUCS2); | ||
207 | residentUnicodeMaps->add(map->getEncodingName(), map); | ||
196 | 208 | ||
197 | // default displayFonts table | 209 | // default displayFonts table |
198 | for (i = 0; displayFontTab[i].name; ++i) { | 210 | for (i = 0; displayFontTab[i].name; ++i) { |
@@ -219,6 +231,7 @@ GlobalParams::GlobalParams(char *cfgFileName) { | |||
219 | } | 231 | } |
220 | if (!f) { | 232 | if (!f) { |
221 | #if defined(WIN32) && !defined(__CYGWIN32__) | 233 | #if defined(WIN32) && !defined(__CYGWIN32__) |
234 | char buf[512]; | ||
222 | i = GetModuleFileName(NULL, buf, sizeof(buf)); | 235 | i = GetModuleFileName(NULL, buf, sizeof(buf)); |
223 | if (i <= 0 || i >= sizeof(buf)) { | 236 | if (i <= 0 || i >= sizeof(buf)) { |
224 | // error or path too long for buffer - just use the current dir | 237 | // error or path too long for buffer - just use the current dir |
@@ -234,98 +247,141 @@ GlobalParams::GlobalParams(char *cfgFileName) { | |||
234 | } | 247 | } |
235 | } | 248 | } |
236 | if (f) { | 249 | if (f) { |
237 | line = 1; | 250 | parseFile(fileName, f); |
238 | while (fgets(buf, sizeof(buf) - 1, f)) { | 251 | delete fileName; |
239 | 252 | } | |
240 | // break the line into tokens | 253 | } |
241 | tokens = new GList(); | 254 | |
242 | p1 = buf; | 255 | void GlobalParams::parseFile(GString *fileName, FILE *f) { |
243 | while (*p1) { | 256 | int line; |
244 | for (; *p1 && isspace(*p1); ++p1) ; | 257 | GList *tokens; |
245 | if (!*p1) { | 258 | GString *cmd, *incFile; |
246 | break; | 259 | char *p1, *p2; |
247 | } | 260 | char buf[512]; |
248 | if (*p1 == '"' || *p1 == '\'') { | 261 | FILE *f2; |
249 | for (p2 = p1 + 1; *p2 && *p2 != *p1; ++p2) ; | 262 | |
250 | ++p1; | 263 | line = 1; |
251 | } else { | 264 | while (fgets(buf, sizeof(buf) - 1, f)) { |
252 | for (p2 = p1 + 1; *p2 && !isspace(*p2); ++p2) ; | 265 | |
253 | } | 266 | // break the line into tokens |
254 | tokens->append(new GString(p1, p2 - p1)); | 267 | tokens = new GList(); |
255 | p1 = p2 + 1; | 268 | p1 = buf; |
269 | while (*p1) { | ||
270 | for (; *p1 && isspace(*p1); ++p1) ; | ||
271 | if (!*p1) { | ||
272 | break; | ||
273 | } | ||
274 | if (*p1 == '"' || *p1 == '\'') { | ||
275 | for (p2 = p1 + 1; *p2 && *p2 != *p1; ++p2) ; | ||
276 | ++p1; | ||
277 | } else { | ||
278 | for (p2 = p1 + 1; *p2 && !isspace(*p2); ++p2) ; | ||
256 | } | 279 | } |
280 | tokens->append(new GString(p1, p2 - p1)); | ||
281 | p1 = p2 + 1; | ||
282 | } | ||
257 | 283 | ||
258 | if (tokens->getLength() > 0 && | 284 | if (tokens->getLength() > 0 && |
259 | ((GString *)tokens->get(0))->getChar(0) != '#') { | 285 | ((GString *)tokens->get(0))->getChar(0) != '#') { |
260 | cmd = (GString *)tokens->get(0); | 286 | cmd = (GString *)tokens->get(0); |
261 | if (!cmd->cmp("nameToUnicode")) { | 287 | if (!cmd->cmp("include")) { |
262 | parseNameToUnicode(tokens, fileName, line); | 288 | if (tokens->getLength() == 2) { |
263 | } else if (!cmd->cmp("cidToUnicode")) { | 289 | incFile = (GString *)tokens->get(1); |
264 | parseCIDToUnicode(tokens, fileName, line); | 290 | if ((f2 = fopen(incFile->getCString(), "r"))) { |
265 | } else if (!cmd->cmp("unicodeMap")) { | 291 | parseFile(incFile, f2); |
266 | parseUnicodeMap(tokens, fileName, line); | 292 | fclose(f2); |
267 | } else if (!cmd->cmp("cMapDir")) { | 293 | } else { |
268 | parseCMapDir(tokens, fileName, line); | 294 | error(-1, "Couldn't find included config file: '%s' (%s:%d)", |
269 | } else if (!cmd->cmp("toUnicodeDir")) { | 295 | incFile->getCString(), fileName->getCString(), line); |
270 | parseToUnicodeDir(tokens, fileName, line); | 296 | } |
271 | } else if (!cmd->cmp("displayFontX")) { | ||
272 | parseDisplayFont(tokens, gFalse, displayFontX, fileName, line); | ||
273 | } else if (!cmd->cmp("displayFontT1")) { | ||
274 | parseDisplayFont(tokens, gFalse, displayFontT1, fileName, line); | ||
275 | } else if (!cmd->cmp("displayFontTT")) { | ||
276 | parseDisplayFont(tokens, gFalse, displayFontTT, fileName, line); | ||
277 | } else if (!cmd->cmp("displayCIDFontX")) { | ||
278 | parseDisplayFont(tokens, gTrue, displayFontX, fileName, line); | ||
279 | } else if (!cmd->cmp("psFile")) { | ||
280 | parsePSFile(tokens, fileName, line); | ||
281 | } else if (!cmd->cmp("psFont")) { | ||
282 | parsePSFont(tokens, fileName, line); | ||
283 | } else if (!cmd->cmp("psPaperSize")) { | ||
284 | parsePSPaperSize(tokens, fileName, line); | ||
285 | } else if (!cmd->cmp("psDuplex")) { | ||
286 | parseYesNo("psDuplex", &psDuplex, tokens, fileName, line); | ||
287 | } else if (!cmd->cmp("psLevel")) { | ||
288 | parsePSLevel(tokens, fileName, line); | ||
289 | } else if (!cmd->cmp("psEmbedType1")) { | ||
290 | parseYesNo("psEmbedType1", &psEmbedType1, tokens, fileName, line); | ||
291 | } else if (!cmd->cmp("psEmbedTrueType")) { | ||
292 | parseYesNo("psEmbedTrueType", &psEmbedTrueType, | ||
293 | tokens, fileName, line); | ||
294 | } else if (!cmd->cmp("psOPI")) { | ||
295 | parseYesNo("psOPI", &psOPI, tokens, fileName, line); | ||
296 | } else if (!cmd->cmp("textEncoding")) { | ||
297 | parseTextEncoding(tokens, fileName, line); | ||
298 | } else if (!cmd->cmp("textEOL")) { | ||
299 | parseTextEOL(tokens, fileName, line); | ||
300 | } else if (!cmd->cmp("fontDir")) { | ||
301 | parseFontDir(tokens, fileName, line); | ||
302 | } else if (!cmd->cmp("t1libControl")) { | ||
303 | parseFontRastControl("t1libControl", &t1libControl, | ||
304 | tokens, fileName, line); | ||
305 | } else if (!cmd->cmp("freetypeControl")) { | ||
306 | parseFontRastControl("freetypeControl", &freetypeControl, | ||
307 | tokens, fileName, line); | ||
308 | } else if (!cmd->cmp("urlCommand")) { | ||
309 | parseURLCommand(tokens, fileName, line); | ||
310 | } else if (!cmd->cmp("mapNumericCharNames")) { | ||
311 | parseYesNo("mapNumericCharNames", &mapNumericCharNames, | ||
312 | tokens, fileName, line); | ||
313 | } else if (!cmd->cmp("errQuiet")) { | ||
314 | parseYesNo("errQuiet", &errQuiet, tokens, fileName, line); | ||
315 | } else if (!cmd->cmp("fontpath") || !cmd->cmp("fontmap")) { | ||
316 | error(-1, "Unknown config file command"); | ||
317 | error(-1, "-- the config file format has changed since Xpdf 0.9x"); | ||
318 | } else { | 297 | } else { |
319 | error(-1, "Unknown config file command '%s' (%s:%d)", | 298 | error(-1, "Bad 'include' config file command (%s:%d)", |
320 | cmd->getCString(), fileName->getCString(), line); | 299 | fileName->getCString(), line); |
321 | } | 300 | } |
301 | } else if (!cmd->cmp("nameToUnicode")) { | ||
302 | parseNameToUnicode(tokens, fileName, line); | ||
303 | } else if (!cmd->cmp("cidToUnicode")) { | ||
304 | parseCIDToUnicode(tokens, fileName, line); | ||
305 | } else if (!cmd->cmp("unicodeMap")) { | ||
306 | parseUnicodeMap(tokens, fileName, line); | ||
307 | } else if (!cmd->cmp("cMapDir")) { | ||
308 | parseCMapDir(tokens, fileName, line); | ||
309 | } else if (!cmd->cmp("toUnicodeDir")) { | ||
310 | parseToUnicodeDir(tokens, fileName, line); | ||
311 | } else if (!cmd->cmp("displayFontX")) { | ||
312 | parseDisplayFont(tokens, displayFonts, displayFontX, fileName, line); | ||
313 | } else if (!cmd->cmp("displayFontT1")) { | ||
314 | parseDisplayFont(tokens, displayFonts, displayFontT1, fileName, line); | ||
315 | } else if (!cmd->cmp("displayFontTT")) { | ||
316 | parseDisplayFont(tokens, displayFonts, displayFontTT, fileName, line); | ||
317 | } else if (!cmd->cmp("displayCIDFontX")) { | ||
318 | parseDisplayFont(tokens, displayCIDFonts, | ||
319 | displayFontX, fileName, line); | ||
320 | } else if (!cmd->cmp("displayNamedCIDFontX")) { | ||
321 | parseDisplayFont(tokens, displayNamedCIDFonts, | ||
322 | displayFontX, fileName, line); | ||
323 | } else if (!cmd->cmp("psFile")) { | ||
324 | parsePSFile(tokens, fileName, line); | ||
325 | } else if (!cmd->cmp("psFont")) { | ||
326 | parsePSFont(tokens, fileName, line); | ||
327 | } else if (!cmd->cmp("psNamedFont16")) { | ||
328 | parsePSFont16("psNamedFont16", psNamedFonts16, | ||
329 | tokens, fileName, line); | ||
330 | } else if (!cmd->cmp("psFont16")) { | ||
331 | parsePSFont16("psFont16", psFonts16, tokens, fileName, line); | ||
332 | } else if (!cmd->cmp("psPaperSize")) { | ||
333 | parsePSPaperSize(tokens, fileName, line); | ||
334 | } else if (!cmd->cmp("psDuplex")) { | ||
335 | parseYesNo("psDuplex", &psDuplex, tokens, fileName, line); | ||
336 | } else if (!cmd->cmp("psLevel")) { | ||
337 | parsePSLevel(tokens, fileName, line); | ||
338 | } else if (!cmd->cmp("psEmbedType1Fonts")) { | ||
339 | parseYesNo("psEmbedType1", &psEmbedType1, tokens, fileName, line); | ||
340 | } else if (!cmd->cmp("psEmbedTrueTypeFonts")) { | ||
341 | parseYesNo("psEmbedTrueType", &psEmbedTrueType, | ||
342 | tokens, fileName, line); | ||
343 | } else if (!cmd->cmp("psEmbedCIDPostScriptFonts")) { | ||
344 | parseYesNo("psEmbedCIDPostScript", &psEmbedCIDPostScript, | ||
345 | tokens, fileName, line); | ||
346 | } else if (!cmd->cmp("psEmbedCIDTrueTypeFonts")) { | ||
347 | parseYesNo("psEmbedCIDTrueType", &psEmbedCIDTrueType, | ||
348 | tokens, fileName, line); | ||
349 | } else if (!cmd->cmp("psOPI")) { | ||
350 | parseYesNo("psOPI", &psOPI, tokens, fileName, line); | ||
351 | } else if (!cmd->cmp("psASCIIHex")) { | ||
352 | parseYesNo("psASCIIHex", &psASCIIHex, tokens, fileName, line); | ||
353 | } else if (!cmd->cmp("textEncoding")) { | ||
354 | parseTextEncoding(tokens, fileName, line); | ||
355 | } else if (!cmd->cmp("textEOL")) { | ||
356 | parseTextEOL(tokens, fileName, line); | ||
357 | } else if (!cmd->cmp("fontDir")) { | ||
358 | parseFontDir(tokens, fileName, line); | ||
359 | } else if (!cmd->cmp("initialZoom")) { | ||
360 | parseInitialZoom(tokens, fileName, line); | ||
361 | } else if (!cmd->cmp("t1libControl")) { | ||
362 | parseFontRastControl("t1libControl", &t1libControl, | ||
363 | tokens, fileName, line); | ||
364 | } else if (!cmd->cmp("freetypeControl")) { | ||
365 | parseFontRastControl("freetypeControl", &freetypeControl, | ||
366 | tokens, fileName, line); | ||
367 | } else if (!cmd->cmp("urlCommand")) { | ||
368 | parseURLCommand(tokens, fileName, line); | ||
369 | } else if (!cmd->cmp("mapNumericCharNames")) { | ||
370 | parseYesNo("mapNumericCharNames", &mapNumericCharNames, | ||
371 | tokens, fileName, line); | ||
372 | } else if (!cmd->cmp("errQuiet")) { | ||
373 | parseYesNo("errQuiet", &errQuiet, tokens, fileName, line); | ||
374 | } else if (!cmd->cmp("fontpath") || !cmd->cmp("fontmap")) { | ||
375 | error(-1, "Unknown config file command"); | ||
376 | error(-1, "-- the config file format has changed since Xpdf 0.9x"); | ||
377 | } else { | ||
378 | error(-1, "Unknown config file command '%s' (%s:%d)", | ||
379 | cmd->getCString(), fileName->getCString(), line); | ||
322 | } | 380 | } |
323 | |||
324 | deleteGList(tokens, GString); | ||
325 | ++line; | ||
326 | } | 381 | } |
327 | 382 | ||
328 | delete fileName; | 383 | deleteGList(tokens, GString); |
384 | ++line; | ||
329 | } | 385 | } |
330 | } | 386 | } |
331 | 387 | ||
@@ -426,7 +482,7 @@ void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName, | |||
426 | toUnicodeDirs->append(((GString *)tokens->get(1))->copy()); | 482 | toUnicodeDirs->append(((GString *)tokens->get(1))->copy()); |
427 | } | 483 | } |
428 | 484 | ||
429 | void GlobalParams::parseDisplayFont(GList *tokens, GBool isCID, | 485 | void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash, |
430 | DisplayFontParamKind kind, | 486 | DisplayFontParamKind kind, |
431 | GString *fileName, int line) { | 487 | GString *fileName, int line) { |
432 | DisplayFontParam *param, *old; | 488 | DisplayFontParam *param, *old; |
@@ -458,23 +514,16 @@ void GlobalParams::parseDisplayFont(GList *tokens, GBool isCID, | |||
458 | break; | 514 | break; |
459 | } | 515 | } |
460 | 516 | ||
461 | if (isCID) { | 517 | if ((old = (DisplayFontParam *)fontHash->remove(param->name))) { |
462 | if ((old = (DisplayFontParam *)displayCIDFonts->remove(param->name))) { | 518 | delete old; |
463 | delete old; | ||
464 | } | ||
465 | displayCIDFonts->add(param->name, param); | ||
466 | } else { | ||
467 | if ((old = (DisplayFontParam *)displayFonts->remove(param->name))) { | ||
468 | delete old; | ||
469 | } | ||
470 | displayFonts->add(param->name, param); | ||
471 | } | 519 | } |
520 | fontHash->add(param->name, param); | ||
472 | return; | 521 | return; |
473 | 522 | ||
474 | err2: | 523 | err2: |
475 | delete param; | 524 | delete param; |
476 | err1: | 525 | err1: |
477 | error(-1, "Bad 'displayFont...' config file command (%s:%d)", | 526 | error(-1, "Bad 'display*Font*' config file command (%s:%d)", |
478 | fileName->getCString(), line); | 527 | fileName->getCString(), line); |
479 | } | 528 | } |
480 | 529 | ||
@@ -516,6 +565,10 @@ void GlobalParams::parsePSLevel(GList *tokens, GString *fileName, int line) { | |||
516 | psLevel = psLevel2; | 565 | psLevel = psLevel2; |
517 | } else if (!tok->cmp("level2sep")) { | 566 | } else if (!tok->cmp("level2sep")) { |
518 | psLevel = psLevel2Sep; | 567 | psLevel = psLevel2Sep; |
568 | } else if (!tok->cmp("level3")) { | ||
569 | psLevel = psLevel3; | ||
570 | } else if (!tok->cmp("level3Sep")) { | ||
571 | psLevel = psLevel3Sep; | ||
519 | } else { | 572 | } else { |
520 | error(-1, "Bad 'psLevel' config file command (%s:%d)", | 573 | error(-1, "Bad 'psLevel' config file command (%s:%d)", |
521 | fileName->getCString(), line); | 574 | fileName->getCString(), line); |
@@ -542,11 +595,39 @@ void GlobalParams::parsePSFont(GList *tokens, GString *fileName, int line) { | |||
542 | fileName->getCString(), line); | 595 | fileName->getCString(), line); |
543 | return; | 596 | return; |
544 | } | 597 | } |
545 | param = new PSFontParam(((GString *)tokens->get(1))->copy(), | 598 | param = new PSFontParam(((GString *)tokens->get(1))->copy(), 0, |
546 | ((GString *)tokens->get(2))->copy()); | 599 | ((GString *)tokens->get(2))->copy(), NULL); |
547 | psFonts->add(param->pdfFontName, param); | 600 | psFonts->add(param->pdfFontName, param); |
548 | } | 601 | } |
549 | 602 | ||
603 | void GlobalParams::parsePSFont16(char *cmdName, GList *fontList, | ||
604 | GList *tokens, GString *fileName, int line) { | ||
605 | PSFontParam *param; | ||
606 | int wMode; | ||
607 | GString *tok; | ||
608 | |||
609 | if (tokens->getLength() != 5) { | ||
610 | error(-1, "Bad '%s' config file command (%s:%d)", | ||
611 | cmdName, fileName->getCString(), line); | ||
612 | return; | ||
613 | } | ||
614 | tok = (GString *)tokens->get(2); | ||
615 | if (!tok->cmp("H")) { | ||
616 | wMode = 0; | ||
617 | } else if (!tok->cmp("V")) { | ||
618 | wMode = 1; | ||
619 | } else { | ||
620 | error(-1, "Bad '%s' config file command (%s:%d)", | ||
621 | cmdName, fileName->getCString(), line); | ||
622 | return; | ||
623 | } | ||
624 | param = new PSFontParam(((GString *)tokens->get(1))->copy(), | ||
625 | wMode, | ||
626 | ((GString *)tokens->get(3))->copy(), | ||
627 | ((GString *)tokens->get(4))->copy()); | ||
628 | fontList->append(param); | ||
629 | } | ||
630 | |||
550 | void GlobalParams::parseTextEncoding(GList *tokens, GString *fileName, | 631 | void GlobalParams::parseTextEncoding(GList *tokens, GString *fileName, |
551 | int line) { | 632 | int line) { |
552 | if (tokens->getLength() != 2) { | 633 | if (tokens->getLength() != 2) { |
@@ -588,17 +669,15 @@ void GlobalParams::parseFontDir(GList *tokens, GString *fileName, int line) { | |||
588 | fontDirs->append(((GString *)tokens->get(1))->copy()); | 669 | fontDirs->append(((GString *)tokens->get(1))->copy()); |
589 | } | 670 | } |
590 | 671 | ||
591 | void GlobalParams::parseURLCommand(GList *tokens, GString *fileName, | 672 | void GlobalParams::parseInitialZoom(GList *tokens, |
592 | int line) { | 673 | GString *fileName, int line) { |
593 | if (tokens->getLength() != 2) { | 674 | if (tokens->getLength() != 2) { |
594 | error(-1, "Bad 'urlCommand' config file command (%s:%d)", | 675 | error(-1, "Bad 'initialZoom' config file command (%s:%d)", |
595 | fileName->getCString(), line); | 676 | fileName->getCString(), line); |
596 | return; | 677 | return; |
597 | } | 678 | } |
598 | if (urlCommand) { | 679 | delete initialZoom; |
599 | delete urlCommand; | 680 | initialZoom = ((GString *)tokens->get(1))->copy(); |
600 | } | ||
601 | urlCommand = ((GString *)tokens->get(1))->copy(); | ||
602 | } | 681 | } |
603 | 682 | ||
604 | void GlobalParams::parseFontRastControl(char *cmdName, FontRastControl *val, | 683 | void GlobalParams::parseFontRastControl(char *cmdName, FontRastControl *val, |
@@ -618,6 +697,19 @@ void GlobalParams::parseFontRastControl(char *cmdName, FontRastControl *val, | |||
618 | } | 697 | } |
619 | } | 698 | } |
620 | 699 | ||
700 | void GlobalParams::parseURLCommand(GList *tokens, GString *fileName, | ||
701 | int line) { | ||
702 | if (tokens->getLength() != 2) { | ||
703 | error(-1, "Bad 'urlCommand' config file command (%s:%d)", | ||
704 | fileName->getCString(), line); | ||
705 | return; | ||
706 | } | ||
707 | if (urlCommand) { | ||
708 | delete urlCommand; | ||
709 | } | ||
710 | urlCommand = ((GString *)tokens->get(1))->copy(); | ||
711 | } | ||
712 | |||
621 | void GlobalParams::parseYesNo(char *cmdName, GBool *flag, | 713 | void GlobalParams::parseYesNo(char *cmdName, GBool *flag, |
622 | GList *tokens, GString *fileName, int line) { | 714 | GList *tokens, GString *fileName, int line) { |
623 | GString *tok; | 715 | GString *tok; |
@@ -654,12 +746,16 @@ GlobalParams::~GlobalParams() { | |||
654 | deleteGList(toUnicodeDirs, GString); | 746 | deleteGList(toUnicodeDirs, GString); |
655 | deleteGHash(displayFonts, DisplayFontParam); | 747 | deleteGHash(displayFonts, DisplayFontParam); |
656 | deleteGHash(displayCIDFonts, DisplayFontParam); | 748 | deleteGHash(displayCIDFonts, DisplayFontParam); |
749 | deleteGHash(displayNamedCIDFonts, DisplayFontParam); | ||
657 | if (psFile) { | 750 | if (psFile) { |
658 | delete psFile; | 751 | delete psFile; |
659 | } | 752 | } |
660 | deleteGHash(psFonts, PSFontParam); | 753 | deleteGHash(psFonts, PSFontParam); |
754 | deleteGList(psNamedFonts16, PSFontParam); | ||
755 | deleteGList(psFonts16, PSFontParam); | ||
661 | delete textEncoding; | 756 | delete textEncoding; |
662 | deleteGList(fontDirs, GString); | 757 | deleteGList(fontDirs, GString); |
758 | delete initialZoom; | ||
663 | if (urlCommand) { | 759 | if (urlCommand) { |
664 | delete urlCommand; | 760 | delete urlCommand; |
665 | } | 761 | } |
@@ -752,14 +848,50 @@ DisplayFontParam *GlobalParams::getDisplayFont(GString *fontName) { | |||
752 | return (DisplayFontParam *)displayFonts->lookup(fontName); | 848 | return (DisplayFontParam *)displayFonts->lookup(fontName); |
753 | } | 849 | } |
754 | 850 | ||
755 | DisplayFontParam *GlobalParams::getDisplayCIDFont(GString *collection) { | 851 | DisplayFontParam *GlobalParams::getDisplayCIDFont(GString *fontName, |
756 | return (DisplayFontParam *)displayCIDFonts->lookup(collection); | 852 | GString *collection) { |
853 | DisplayFontParam *dfp; | ||
854 | |||
855 | if (!fontName || | ||
856 | !(dfp = (DisplayFontParam *)displayNamedCIDFonts->lookup(fontName))) { | ||
857 | dfp = (DisplayFontParam *)displayCIDFonts->lookup(collection); | ||
858 | } | ||
859 | return dfp; | ||
757 | } | 860 | } |
758 | 861 | ||
759 | PSFontParam *GlobalParams::getPSFont(GString *fontName) { | 862 | PSFontParam *GlobalParams::getPSFont(GString *fontName) { |
760 | return (PSFontParam *)psFonts->lookup(fontName); | 863 | return (PSFontParam *)psFonts->lookup(fontName); |
761 | } | 864 | } |
762 | 865 | ||
866 | PSFontParam *GlobalParams::getPSFont16(GString *fontName, | ||
867 | GString *collection, int wMode) { | ||
868 | PSFontParam *p; | ||
869 | int i; | ||
870 | |||
871 | p = NULL; | ||
872 | if (fontName) { | ||
873 | for (i = 0; i < psNamedFonts16->getLength(); ++i) { | ||
874 | p = (PSFontParam *)psNamedFonts16->get(i); | ||
875 | if (!p->pdfFontName->cmp(fontName) && | ||
876 | p->wMode == wMode) { | ||
877 | break; | ||
878 | } | ||
879 | p = NULL; | ||
880 | } | ||
881 | } | ||
882 | if (!p && collection) { | ||
883 | for (i = 0; i < psFonts16->getLength(); ++i) { | ||
884 | p = (PSFontParam *)psFonts16->get(i); | ||
885 | if (!p->pdfFontName->cmp(collection) && | ||
886 | p->wMode == wMode) { | ||
887 | break; | ||
888 | } | ||
889 | p = NULL; | ||
890 | } | ||
891 | } | ||
892 | return p; | ||
893 | } | ||
894 | |||
763 | GString *GlobalParams::findFontFile(GString *fontName, | 895 | GString *GlobalParams::findFontFile(GString *fontName, |
764 | char *ext1, char *ext2) { | 896 | char *ext1, char *ext2) { |
765 | GString *dir, *fileName; | 897 | GString *dir, *fileName; |
@@ -866,10 +998,22 @@ void GlobalParams::setPSEmbedTrueType(GBool embed) { | |||
866 | psEmbedTrueType = embed; | 998 | psEmbedTrueType = embed; |
867 | } | 999 | } |
868 | 1000 | ||
1001 | void GlobalParams::setPSEmbedCIDPostScript(GBool embed) { | ||
1002 | psEmbedCIDPostScript = embed; | ||
1003 | } | ||
1004 | |||
1005 | void GlobalParams::setPSEmbedCIDTrueType(GBool embed) { | ||
1006 | psEmbedCIDTrueType = embed; | ||
1007 | } | ||
1008 | |||
869 | void GlobalParams::setPSOPI(GBool opi) { | 1009 | void GlobalParams::setPSOPI(GBool opi) { |
870 | psOPI = opi; | 1010 | psOPI = opi; |
871 | } | 1011 | } |
872 | 1012 | ||
1013 | void GlobalParams::setPSASCIIHex(GBool hex) { | ||
1014 | psASCIIHex = hex; | ||
1015 | } | ||
1016 | |||
873 | void GlobalParams::setTextEncoding(char *encodingName) { | 1017 | void GlobalParams::setTextEncoding(char *encodingName) { |
874 | delete textEncoding; | 1018 | delete textEncoding; |
875 | textEncoding = new GString(encodingName); | 1019 | textEncoding = new GString(encodingName); |
@@ -888,6 +1032,11 @@ GBool GlobalParams::setTextEOL(char *s) { | |||
888 | return gTrue; | 1032 | return gTrue; |
889 | } | 1033 | } |
890 | 1034 | ||
1035 | void GlobalParams::setInitialZoom(char *s) { | ||
1036 | delete initialZoom; | ||
1037 | initialZoom = new GString(s); | ||
1038 | } | ||
1039 | |||
891 | GBool GlobalParams::setT1libControl(char *s) { | 1040 | GBool GlobalParams::setT1libControl(char *s) { |
892 | return setFontRastControl(&t1libControl, s); | 1041 | return setFontRastControl(&t1libControl, s); |
893 | } | 1042 | } |