Gentoo Archives: gentoo-commits

From: "Peter Alfredsen (loki_val)" <loki_val@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo commit in src/patchsets/xpdf/3.02: 00_all_xpdf-poppler-i18n.patch 05_all_xpdf-poppler-search-non-ascii.patch 10_all_xpdf-poppler-cut-and-paste-default-output-encoding.patch 15_all_xpdf-poppler-crash-in-japanese-locale.patch 20_all_xpdf-poppler-add-and-subtract-key-binding.patch 25_all_xpdf-poppler-poppler-0.10.0.patch 30_all_xpdf-poppler-cxx-flags.patch 35_all_xpdf-poppler-xpdfrc.5-reference.patch 40_all_xpdf-poppler-autohinting-as-option.patch 45_all_xpdf-poppler-private-textpage-destructor.patch 50_all_xpdf-poppler-getCMap-arguments.patch
Date: Mon, 24 Aug 2009 07:51:28
Message-Id: E1MfUKk-0006mC-2t@stork.gentoo.org
1 loki_val 09/08/24 07:51:18
2
3 Added: 00_all_xpdf-poppler-i18n.patch
4 05_all_xpdf-poppler-search-non-ascii.patch
5 10_all_xpdf-poppler-cut-and-paste-default-output-encoding.patch
6 15_all_xpdf-poppler-crash-in-japanese-locale.patch
7 20_all_xpdf-poppler-add-and-subtract-key-binding.patch
8 25_all_xpdf-poppler-poppler-0.10.0.patch
9 30_all_xpdf-poppler-cxx-flags.patch
10 35_all_xpdf-poppler-xpdfrc.5-reference.patch
11 40_all_xpdf-poppler-autohinting-as-option.patch
12 45_all_xpdf-poppler-private-textpage-destructor.patch
13 50_all_xpdf-poppler-getCMap-arguments.patch
14 Log:
15 Initial patchset, blatantly copied from momonga and opensuse, who in turn had copied parts from us.
16
17 Revision Changes Path
18 1.1 src/patchsets/xpdf/3.02/00_all_xpdf-poppler-i18n.patch
19
20 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/00_all_xpdf-poppler-i18n.patch?rev=1.1&view=markup
21 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/00_all_xpdf-poppler-i18n.patch?rev=1.1&content-type=text/plain
22
23 Index: 00_all_xpdf-poppler-i18n.patch
24 ===================================================================
25 --- BUILD/xpdf-3.02-poppler/XPDFApp.cc
26 +++ BUILD/xpdf-3.02-poppler/XPDFApp.cc
27 @@ -12,6 +12,7 @@
28 #pragma implementation
29 #endif
30
31 +#include <locale.h>
32 #include "GooString.h"
33 #include "GooList.h"
34 #include "Error.h"
35 @@ -35,9 +36,25 @@
36 //------------------------------------------------------------------------
37
38 static String fallbackResources[] = {
39 +#if 0
40 "*.zoomComboBox*fontList: -*-helvetica-medium-r-normal--12-*-*-*-*-*-iso8859-1",
41 "*XmTextField.fontList: -*-courier-medium-r-normal--12-*-*-*-*-*-iso8859-1",
42 "*.fontList: -*-helvetica-medium-r-normal--12-*-*-*-*-*-iso8859-1",
43 +#else
44 + "*renderTable:",
45 + "*renderTable.fontType: FONT_IS_FONTSET",
46 + "*renderTable.fontName: "
47 + " -efont-biwidth-medium-r-normal--14-*-*-*-*-*-*-*, "
48 + " -gnu-unifont-medium-r-normal--16-*-*-*-p-*-*-*, "
49 + " -adobe-helvetica-medium-r-normal-*-14-*-*-*-p-*-iso10646-1, "
50 + " -adobe-helvetica-medium-r-normal-*-14-*-*-*-p-*-iso8859-*, "
51 + " -cronyx-helvetica-medium-r-normal-*-14-*-*-*-p-*-koi8-r, "
52 + " -*-lucida-medium-r-normal-*-14-*-*-*-p-*-iso8859-*, "
53 + " -*-*-medium-r-normal-*-14-*-*-*-p-*-*-*, "
54 + " -*-*-medium-r-normal-*-16-*-*-*-p-*-*-*, "
55 + " -*-*-*-*-*-*-14-*-*-*-*-*-*-*, "
56 + " -*-*-*-*-*-*-16-*-*-*-*-*-*-*,*",
57 +#endif
58 "*XmTextField.translations: #override\\n"
59 " Ctrl<Key>a:beginning-of-line()\\n"
60 " Ctrl<Key>b:backward-character()\\n"
61 @@ -64,8 +81,13 @@
62 {"-bg", "*Background", XrmoptionSepArg, NULL},
63 {"-geometry", ".geometry", XrmoptionSepArg, NULL},
64 {"-g", ".geometry", XrmoptionSepArg, NULL},
65 +#if 0
66 {"-font", "*.fontList", XrmoptionSepArg, NULL},
67 {"-fn", "*.fontList", XrmoptionSepArg, NULL},
68 +#else
69 + {"-font", "*.renderTable.fontName", XrmoptionSepArg, NULL},
70 + {"-fn", "*.renderTable.fontName", XrmoptionSepArg, NULL},
71 +#endif
72 {"-title", ".title", XrmoptionSepArg, NULL},
73 {"-cmap", ".installCmap", XrmoptionNoArg, (XPointer)"on"},
74 {"-rgb", ".rgbCubeSize", XrmoptionSepArg, NULL},
75 @@ -125,9 +147,12 @@
76 #endif
77
78 XPDFApp::XPDFApp(int *argc, char *argv[]) {
79 + XtSetLanguageProc(NULL, NULL, NULL);
80 + setlocale(LC_NUMERIC,"POSIX");
81 appShell = XtAppInitialize(&appContext, xpdfAppName, xOpts, nXOpts,
82 argc, argv, fallbackResources, NULL, 0);
83 display = XtDisplay(appShell);
84 +
85 screenNum = XScreenNumberOfScreen(XtScreen(appShell));
86 #if XmVERSION > 1
87 XtVaSetValues(XmGetXmDisplay(XtDisplay(appShell)),
88 --- BUILD/xpdf-3.02-poppler/XPDFViewer.cc
89 +++ BUILD/xpdf-3.02-poppler/XPDFViewer.cc
90 @@ -359,9 +359,9 @@
91
92 XPDFViewer::~XPDFViewer() {
93 delete core;
94 - XmFontListFree(aboutBigFont);
95 - XmFontListFree(aboutVersionFont);
96 - XmFontListFree(aboutFixedFont);
97 + XmRenderTableFree(aboutBigFont);
98 + XmRenderTableFree(aboutVersionFont);
99 + XmRenderTableFree(aboutFixedFont);
100 closeWindow();
101 #ifndef DISABLE_OUTLINE
102 if (outlineLabels) {
103 @@ -2789,38 +2789,38 @@
104
105 //----- fonts
106 aboutBigFont =
107 - createFontList("-*-times-bold-i-normal--20-*-*-*-*-*-iso8859-1");
108 + createRenderTable("aboutBigFont", "-efont-biwidth-medium-i-normal--24-*-*-*-p-*-iso10646-1,-*-times-bold-i-normal--18-*-*-*-*-*-iso10646-1,-*-times-bold-i-normal--18-*-*-*-*-*-iso8859-*,-*-*-medium-i-normal--24-*-*-*-c-*-*-*,-*-*-medium-r-normal--24-*-*-*-c-*-*-*");
109 aboutVersionFont =
110 - createFontList("-*-times-medium-r-normal--16-*-*-*-*-*-iso8859-1");
111 + createRenderTable("aboutVersionFont", "-efont-biwidth-medium-r-normal--14-*-*-*-p-*-iso10646-1,-*-times-medium-r-normal--14-*-*-*-*-*-iso10646-1,-*-times-medium-r-normal--14-*-*-*-*-*-iso8859-*,-*-*-medium-r-normal--14-*-*-*-c-*-*-*,-*-*-medium-r-normal--16-*-*-*-c-*-*-*");
112 aboutFixedFont =
113 - createFontList("-*-courier-medium-r-normal--12-*-*-*-*-*-iso8859-1");
114 + createRenderTable("aboutFixedFont", "-efont-biwidth-medium-r-normal--12-*-*-*-p-*-iso10646-1,-*-courier-medium-r-normal--12-*-*-*-*-*-iso10646-1,-*-courier-medium-r-normal--12-*-*-*-*-*-iso8859-1,-*-*-medium-r-normal--12-*-*-*-c-*-*-*,-*-*-medium-r-normal--16-*-*-*-c-*-*-*");
115
116 //----- heading
117 n = 0;
118 s = XmStringCreateLocalized("Xpdf");
119 XtSetArg(args[n], XmNlabelString, s); ++n;
120 - XtSetArg(args[n], XmNfontList, aboutBigFont); ++n;
121 + XtSetArg(args[n], XmNrenderTable, aboutBigFont); ++n;
122 label = XmCreateLabel(col, "h0", args, n);
123 XmStringFree(s);
124 XtManageChild(label);
125 n = 0;
126 s = XmStringCreateLocalized("Version " xpdfVersion);
127 XtSetArg(args[n], XmNlabelString, s); ++n;
128 - XtSetArg(args[n], XmNfontList, aboutVersionFont); ++n;
129 + XtSetArg(args[n], XmNrenderTable, aboutVersionFont); ++n;
130 label = XmCreateLabel(col, "h1", args, n);
131 XmStringFree(s);
132 XtManageChild(label);
133 n = 0;
134 s = XmStringCreateLocalized(xpdfCopyright);
135 XtSetArg(args[n], XmNlabelString, s); ++n;
136 - XtSetArg(args[n], XmNfontList, aboutVersionFont); ++n;
137 + XtSetArg(args[n], XmNrenderTable, aboutVersionFont); ++n;
138 label = XmCreateLabel(col, "h2", args, n);
139 XmStringFree(s);
140 XtManageChild(label);
141 n = 0;
142 s = XmStringCreateLocalized(" ");
143 XtSetArg(args[n], XmNlabelString, s); ++n;
144 - XtSetArg(args[n], XmNfontList, aboutVersionFont); ++n;
145 + XtSetArg(args[n], XmNrenderTable, aboutVersionFont); ++n;
146 label = XmCreateLabel(col, "h3", args, n);
147 XmStringFree(s);
148 XtManageChild(label);
149 @@ -2831,7 +2831,7 @@
150 n = 0;
151 s = XmStringCreateLocalized(" ");
152 XtSetArg(args[n], XmNlabelString, s); ++n;
153 - XtSetArg(args[n], XmNfontList, aboutVersionFont); ++n;
154 + XtSetArg(args[n], XmNrenderTable, aboutVersionFont); ++n;
155 label = XmCreateLabel(col, "h4", args, n);
156 XmStringFree(s);
157 XtManageChild(label);
158 @@ -2842,7 +2842,7 @@
159 n = 0;
160 s = XmStringCreateLocalized(aboutWinText[i]);
161 XtSetArg(args[n], XmNlabelString, s); ++n;
162 - XtSetArg(args[n], XmNfontList, aboutFixedFont); ++n;
163 + XtSetArg(args[n], XmNrenderTable, aboutFixedFont); ++n;
164 sprintf(buf, "t%d", i);
165 label = XmCreateLabel(col, buf, args, n);
166 XtManageChild(label);
167 @@ -3452,38 +3452,20 @@
168 // Motif support
169 //------------------------------------------------------------------------
170
171 -XmFontList XPDFViewer::createFontList(char *xlfd) {
172 - XmFontList fontList;
173 -
174 -#if XmVersion <= 1001
175 -
176 - XFontStruct *font;
177 - String params;
178 - Cardinal nParams;
179 -
180 - font = XLoadQueryFont(display, xlfd);
181 - if (font) {
182 - fontList = XmFontListCreate(font, XmSTRING_DEFAULT_CHARSET);
183 - } else {
184 - params = (String)xlfd;
185 - nParams = 1;
186 - XtAppWarningMsg(app->getAppContext(),
187 - "noSuchFont", "CvtStringToXmFontList",
188 - "XtToolkitError", "No such font: %s",
189 - &params, &nParams);
190 - fontList = NULL;
191 - }
192 -
193 -#else
194 -
195 - XmFontListEntry entry;
196 -
197 - entry = XmFontListEntryLoad(display, xlfd,
198 - XmFONT_IS_FONT, XmFONTLIST_DEFAULT_TAG);
199 - fontList = XmFontListAppendEntry(NULL, entry);
200 - XmFontListEntryFree(&entry);
201 +XmRenderTable XPDFViewer::createRenderTable(char *tag, char *xlfd) {
202 + XmRenderTable rendertable;
203 + XmRendition rendition;
204 + Arg args[10];
205 + int n;
206 +
207 + n = 0;
208 + XtSetArg (args[n], XmNfontName, xlfd); n++;
209 + XtSetArg (args[n], XmNfontType, XmFONT_IS_FONTSET); n++;
210 + rendition = XmRenditionCreate (win, tag, args, n);
211 +
212 + rendertable = XmRenderTableAddRenditions (NULL, &rendition, 1, XmMERGE_NEW);
213
214 -#endif
215 + XmRenditionFree (rendition);
216
217 - return fontList;
218 + return rendertable;
219 }
220 --- BUILD/xpdf-3.02-poppler/XPDFViewer.h
221 +++ BUILD/xpdf-3.02-poppler/XPDFViewer.h
222 @@ -283,7 +283,7 @@
223 XtPointer callData);
224
225 //----- Motif support
226 - XmFontList createFontList(char *xlfd);
227 + XmRenderTable createRenderTable(char *tag, char *xlfd);
228
229 static XPDFViewerCmd cmdTab[];
230
231 @@ -328,7 +328,7 @@
232 Widget popupMenu;
233
234 Widget aboutDialog;
235 - XmFontList aboutBigFont, aboutVersionFont, aboutFixedFont;
236 + XmRenderTable aboutBigFont, aboutVersionFont, aboutFixedFont;
237
238 Widget openDialog;
239 GBool openInNewWindow;
240
241
242
243 1.1 src/patchsets/xpdf/3.02/05_all_xpdf-poppler-search-non-ascii.patch
244
245 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/05_all_xpdf-poppler-search-non-ascii.patch?rev=1.1&view=markup
246 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/05_all_xpdf-poppler-search-non-ascii.patch?rev=1.1&content-type=text/plain
247
248 Index: 05_all_xpdf-poppler-search-non-ascii.patch
249 ===================================================================
250 --- BUILD/xpdf-3.02-poppler/PDFCore.cc
251 +++ BUILD/xpdf-3.02-poppler/PDFCore.cc
252 @@ -13,6 +13,10 @@
253 #endif
254
255 #include <math.h>
256 +#include <locale.h>
257 +#include <langinfo.h>
258 +#include <iconv.h>
259 +#include <endian.h>
260 #include "GooString.h"
261 #include "GooList.h"
262 #include "GlobalParams.h"
263 @@ -1602,15 +1606,33 @@
264 Unicode *u;
265 int len, i;
266 GBool ret;
267 + iconv_t cd;
268 + char *inptr, *outptr;
269 + size_t insize, outsize;
270 + size_t nchars;
271
272 // convert to Unicode
273 len = strlen(s);
274 u = (Unicode *)gmallocn(len, sizeof(Unicode));
275 - for (i = 0; i < len; ++i) {
276 - u[i] = (Unicode)(s[i] & 0xff);
277 +
278 + nchars = len;
279 + if (len > 0) {
280 +#if __BYTE_ORDER == __LITTLE_ENDIAN
281 + cd = iconv_open ("UCS-4LE",nl_langinfo (CODESET));
282 +#else
283 + cd = iconv_open ("UCS-4BE",nl_langinfo (CODESET));
284 +#endif
285 + inptr = s;
286 + outptr = (char *) u;
287 + insize = len;
288 + outsize = (len * sizeof(Unicode));
289 + memset (u, 0, (len * sizeof(Unicode)));
290 + iconv (cd, &inptr, &insize, &outptr, &outsize);
291 + nchars = len-outsize/4;
292 + iconv_close (cd);
293 }
294
295 - ret = findU(u, len, caseSensitive, next, backward, onePageOnly);
296 + ret = findU(u, nchars, caseSensitive, next, backward, onePageOnly);
297
298 gfree(u);
299 return ret;
300
301
302
303 1.1 src/patchsets/xpdf/3.02/10_all_xpdf-poppler-cut-and-paste-default-output-encoding.patch
304
305 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/10_all_xpdf-poppler-cut-and-paste-default-output-encoding.patch?rev=1.1&view=markup
306 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/10_all_xpdf-poppler-cut-and-paste-default-output-encoding.patch?rev=1.1&content-type=text/plain
307
308 Index: 10_all_xpdf-poppler-cut-and-paste-default-output-encoding.patch
309 ===================================================================
310 --- BUILD/xpdf-3.02-poppler/GlobalParams.cc
311 +++ BUILD/xpdf-3.02-poppler/GlobalParams.cc
312 @@ -39,6 +39,8 @@
313 #include "CMap.h"
314 #include "BuiltinFontTables.h"
315 #include "FontEncodingTables.h"
316 +#include <langinfo.h>
317 +#include <locale.h>
318 #ifdef ENABLE_PLUGINS
319 # include "XpdfPluginAPI.h"
320 #endif
321 @@ -687,7 +689,12 @@
322 psPreload = gFalse;
323 psOPI = gFalse;
324 psASCIIHex = gFalse;
325 - textEncoding = new GooString("UTF-8");
326 + setlocale(LC_ALL,"");
327 + setlocale(LC_NUMERIC,"POSIX");
328 + if (strcmp("UTF-8",nl_langinfo(CODESET)))
329 + textEncoding = new GooString("Latin1");
330 + else
331 + textEncoding = new GooString("UTF-8");
332 #if defined(WIN32)
333 textEOL = eolDOS;
334 #elif defined(MACOS)
335 --- BUILD/xpdf-3.02-poppler/XPDFCore.cc
336 +++ BUILD/xpdf-3.02-poppler/XPDFCore.cc
337 @@ -427,13 +427,17 @@
338 XtPointer *value, unsigned long *length,
339 int *format) {
340 Atom *array;
341 + static Atom utf8str = XInternAtom(currentSelectionOwner->display, "UTF8_STRING", False);
342
343 // send back a list of supported conversion targets
344 if (*target == targetsAtom) {
345 if (!(array = (Atom *)XtMalloc(sizeof(Atom)))) {
346 return False;
347 }
348 - array[0] = XA_STRING;
349 + if (strcmp("UTF-8",globalParams->getTextEncodingName()->getCString()))
350 + array[0] = XA_STRING;
351 + else
352 + array[0] = utf8str;
353 *value = (XtPointer)array;
354 *type = XA_ATOM;
355 *format = 32;
356 @@ -441,11 +445,11 @@
357 return True;
358
359 // send the selected text
360 - } else if (*target == XA_STRING) {
361 + } else if (*target == XA_STRING || *target == utf8str) {
362 //~ for multithreading: need a mutex here
363 *value = XtNewString(currentSelection->getCString());
364 *length = currentSelection->getLength();
365 - *type = XA_STRING;
366 + *type = *target;
367 *format = 8; // 8-bit elements
368 return True;
369 }
370 --- BUILD/xpdf-3.02-poppler/XPDFViewer.cc
371 +++ BUILD/xpdf-3.02-poppler/XPDFViewer.cc
372 @@ -2658,7 +2658,10 @@
373 // create the new labels
374 items = core->getDoc()->getOutline()->getItems();
375 if (items && items->getLength() > 0) {
376 - enc = new GooString("Latin1");
377 + if (strcmp("UTF-8",globalParams->getTextEncodingName()->getCString()))
378 + enc = new GooString("Latin1");
379 + else
380 + enc = new GooString("UTF-8");
381 uMap = globalParams->getUnicodeMap(enc);
382 delete enc;
383 setupOutlineItems(items, NULL, uMap);
384 --- BUILD/xpdf-3.02-poppler/xpdf.1
385 +++ BUILD/xpdf-3.02-poppler/xpdf.1
386 @@ -151,7 +151,8 @@
387 .I encoding\-name
388 must be defined with the unicodeMap command (see
389 .BR xpdfrc (5)).
390 -This defaults to "Latin1" (which is a built-in encoding).
391 +This defaults to "UTF-8" in UTF-8 locales, to "Latin1" in all other
392 +locales ("UTF-8" and "Latin1" are built-in encodings).
393 .RB "[config file: " textEncoding ]
394 .TP
395 .BI \-eol " unix | dos | mac"
396
397
398
399 1.1 src/patchsets/xpdf/3.02/15_all_xpdf-poppler-crash-in-japanese-locale.patch
400
401 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/15_all_xpdf-poppler-crash-in-japanese-locale.patch?rev=1.1&view=markup
402 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/15_all_xpdf-poppler-crash-in-japanese-locale.patch?rev=1.1&content-type=text/plain
403
404 Index: 15_all_xpdf-poppler-crash-in-japanese-locale.patch
405 ===================================================================
406 --- xpdf-3.01/xpdf/XPDFViewer.cc
407 +++ xpdf-3.01/xpdf/XPDFViewer.cc
408 @@ -1252,8 +1252,8 @@
409 }
410
411 void XPDFViewer::closeWindow() {
412 - XtPopdown(win);
413 - XtDestroyWidget(win);
414 +// XtPopdown(win);
415 +// XtDestroyWidget(win);
416 }
417
418 int XPDFViewer::getZoomIdx() {
419
420
421
422 1.1 src/patchsets/xpdf/3.02/20_all_xpdf-poppler-add-and-subtract-key-binding.patch
423
424 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/20_all_xpdf-poppler-add-and-subtract-key-binding.patch?rev=1.1&view=markup
425 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/20_all_xpdf-poppler-add-and-subtract-key-binding.patch?rev=1.1&content-type=text/plain
426
427 Index: 20_all_xpdf-poppler-add-and-subtract-key-binding.patch
428 ===================================================================
429 --- xpdf/GlobalParams.cc
430 +++ xpdf/GlobalParams.cc
431 @@ -897,8 +897,12 @@
432 xpdfKeyContextAny, "zoomPercent(125)"));
433 keyBindings->append(new KeyBinding('+', xpdfKeyModNone,
434 xpdfKeyContextAny, "zoomIn"));
435 + keyBindings->append(new KeyBinding(xpdfKeyCodeAdd, xpdfKeyModNone,
436 + xpdfKeyContextAny, "zoomIn"));
437 keyBindings->append(new KeyBinding('-', xpdfKeyModNone,
438 xpdfKeyContextAny, "zoomOut"));
439 + keyBindings->append(new KeyBinding(xpdfKeyCodeSubtract, xpdfKeyModNone,
440 + xpdfKeyContextAny, "zoomOut"));
441 keyBindings->append(new KeyBinding('z', xpdfKeyModNone,
442 xpdfKeyContextAny, "zoomFitPage"));
443 keyBindings->append(new KeyBinding('w', xpdfKeyModNone,
444 --- xpdf/GlobalParams.h
445 +++ xpdf/GlobalParams.h
446 @@ -158,6 +158,8 @@
447 #define xpdfKeyCodeDown 0x100d
448 #define xpdfKeyCodeF1 0x1100
449 #define xpdfKeyCodeF35 0x1122
450 +#define xpdfKeyCodeAdd 0x1200
451 +#define xpdfKeyCodeSubtract 0x1201
452 #define xpdfKeyCodeMousePress1 0x2001
453 #define xpdfKeyCodeMousePress2 0x2002
454 #define xpdfKeyCodeMousePress3 0x2003
455 --- xpdf/XPDFViewer.cc
456 +++ xpdf/XPDFViewer.cc
457 @@ -110,6 +110,12 @@
458 #ifndef XK_KP_Delete
459 #define XK_KP_Delete 0xFF9F
460 #endif
461 +#ifndef XK_KP_Add
462 +#define XK_KP_Add 0xFFAB
463 +#endif
464 +#ifndef XK_KP_Subtract
465 +#define XK_KP_Subtract 0xFFAD
466 +#endif
467
468 //------------------------------------------------------------------------
469 // GUI includes
470 @@ -576,6 +582,10 @@
471 keyCode = xpdfKeyCodeDown;
472 } else if (key >= XK_F1 && key <= XK_F35) {
473 keyCode = xpdfKeyCodeF1 + (key - XK_F1);
474 + } else if (key == XK_KP_Add) {
475 + keyCode = xpdfKeyCodeAdd;
476 + } else if (key == XK_KP_Subtract) {
477 + keyCode = xpdfKeyCodeSubtract;
478 } else {
479 return;
480 }
481
482
483
484 1.1 src/patchsets/xpdf/3.02/25_all_xpdf-poppler-poppler-0.10.0.patch
485
486 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/25_all_xpdf-poppler-poppler-0.10.0.patch?rev=1.1&view=markup
487 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/25_all_xpdf-poppler-poppler-0.10.0.patch?rev=1.1&content-type=text/plain
488
489 Index: 25_all_xpdf-poppler-poppler-0.10.0.patch
490 ===================================================================
491 diff -pur --exclude='*~' xpdf-3.02-poppler.orig/config.h xpdf-3.02-poppler/config.h
492 --- xpdf-3.02-poppler.orig/config.h 2008-10-14 20:00:41.000000000 +0200
493 +++ xpdf-3.02-poppler/config.h 2008-10-14 21:08:15.000000000 +0200
494 @@ -28,6 +28,7 @@
495 #define supportedPDFVersionNum 1.7
496
497 // copyright notice
498 +#undef xpdfCopyright
499 #define xpdfCopyright "Copyright 1996-2007 Glyph & Cog, LLC"
500
501 // Windows resource file stuff
502 diff -pur --exclude='*~' xpdf-3.02-poppler.orig/XPDFCore.cc xpdf-3.02-poppler/XPDFCore.cc
503 --- xpdf-3.02-poppler.orig/XPDFCore.cc 2008-10-14 20:00:41.000000000 +0200
504 +++ xpdf-3.02-poppler/XPDFCore.cc 2008-10-14 21:13:48.000000000 +0200
505 @@ -22,6 +22,7 @@
506 #include "GlobalParams.h"
507 #include "PDFDoc.h"
508 #include "Link.h"
509 +#include "FileSpec.h"
510 #include "ErrorCodes.h"
511 #include "GfxState.h"
512 #include "CoreOutputDev.h"
513 @@ -465,7 +466,7 @@ void XPDFCore::doAction(LinkAction *acti
514 GooString *fileName, *fileName2;
515 GooString *cmd;
516 GooString *actionName;
517 - Object movieAnnot, obj1, obj2;
518 + Object movieAnnot, obj1, obj2, obj3;
519 GooString *msg;
520 int i;
521
522 @@ -631,7 +632,9 @@ void XPDFCore::doAction(LinkAction *acti
523 if (movieAnnot.isDict()) {
524 if (movieAnnot.dictLookup("Movie", &obj1)->isDict()) {
525 if (obj1.dictLookup("F", &obj2)) {
526 - if ((fileName = LinkAction::getFileSpecName(&obj2))) {
527 + if (getFileSpecNameForPlatform(&obj2, &obj3)) {
528 + fileName = obj3.getString()->copy();
529 + obj3.free();
530 if (!isAbsolutePath(fileName->getCString())) {
531 fileName2 = appendToPath(
532 grabPath(doc->getFileName()->getCString()),
533
534
535
536 1.1 src/patchsets/xpdf/3.02/30_all_xpdf-poppler-cxx-flags.patch
537
538 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/30_all_xpdf-poppler-cxx-flags.patch?rev=1.1&view=markup
539 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/30_all_xpdf-poppler-cxx-flags.patch?rev=1.1&content-type=text/plain
540
541 Index: 30_all_xpdf-poppler-cxx-flags.patch
542 ===================================================================
543 --- xpdf-3.02-poppler/Makefile
544 +++ xpdf-3.02-poppler/Makefile
545 @@ -2,5 +2,5 @@
546 xpdf: CoreOutputDev.o GlobalParams.o ImageOutputDev.o PDFCore.o XPDFApp.o XPDFCore.o XPDFTree.o XPDFViewer.o parseargs.o xpdf.o
547 - $(CXX) -o xpdf $(LIBS) *.o
548 + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o xpdf *.o $(LIBS)
549
550 clean:
551 rm -f *.o xpdf
552
553
554
555 1.1 src/patchsets/xpdf/3.02/35_all_xpdf-poppler-xpdfrc.5-reference.patch
556
557 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/35_all_xpdf-poppler-xpdfrc.5-reference.patch?rev=1.1&view=markup
558 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/35_all_xpdf-poppler-xpdfrc.5-reference.patch?rev=1.1&content-type=text/plain
559
560 Index: 35_all_xpdf-poppler-xpdfrc.5-reference.patch
561 ===================================================================
562 --- xpdf.1
563 +++ xpdf.1
564 @@ -42,9 +42,7 @@
565 Xpdf reads a configuration file at startup. It first tries to find
566 the user's private config file, ~/.xpdfrc. If that doesn't exist, it
567 looks for a system-wide config file, typically /usr/local/etc/xpdfrc
568 -(but this location can be changed when xpdf is built). See the
569 -.BR xpdfrc (5)
570 -man page for details.
571 +(but this location can be changed when xpdf is built).
572 .SH OPTIONS
573 Many of the following options can be set with configuration file
574 commands or X resources. These are listed in square brackets with the
575 @@ -149,8 +147,7 @@
576 .BI \-enc " encoding-name"
577 Sets the encoding to use for text output. The
578 .I encoding\-name
579 -must be defined with the unicodeMap command (see
580 -.BR xpdfrc (5)).
581 +must be defined with the unicodeMap command.
582 This defaults to "UTF-8" in UTF-8 locales, to "Latin1" in all other
583 locales ("UTF-8" and "Latin1" are built-in encodings).
584 .RB "[config file: " textEncoding ]
585 @@ -467,8 +464,7 @@
586 .RE
587 .SH COMMANDS
588 Xpdf's key and mouse bindings are user-configurable, using the bind and
589 -unbind options in the config file (see
590 -.BR xpdfrc (5)).
591 +unbind options in the config file.
592 The bind command allows you to bind a key or mouse button to a
593 sequence of one or more commands.
594 .SS Available Commands
595 @@ -859,6 +855,5 @@
596 .BR pdffonts (1),
597 .BR pdftoppm (1),
598 .BR pdfimages (1),
599 -.BR xpdfrc (5)
600 .br
601 .B http://www.foolabs.com/xpdf/
602
603
604
605 1.1 src/patchsets/xpdf/3.02/40_all_xpdf-poppler-autohinting-as-option.patch
606
607 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/40_all_xpdf-poppler-autohinting-as-option.patch?rev=1.1&view=markup
608 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/40_all_xpdf-poppler-autohinting-as-option.patch?rev=1.1&content-type=text/plain
609
610 Index: 40_all_xpdf-poppler-autohinting-as-option.patch
611 ===================================================================
612 --- GlobalParamsGUI.cc
613 +++ GlobalParamsGUI.cc
614 @@ -0,0 +1,3230 @@
615 +//========================================================================
616 +//
617 +// GlobalParamsGUI.cc
618 +//
619 +// Copyright 2001-2003 Glyph & Cog, LLC
620 +//
621 +//========================================================================
622 +
623 +#include "config.h"
624 +
625 +#ifdef USE_GCC_PRAGMAS
626 +#pragma implementation
627 +#endif
628 +
629 +#include <string.h>
630 +#include <stdio.h>
631 +#include <ctype.h>
632 +#ifdef ENABLE_PLUGINS
633 +# ifndef WIN32
634 +# include <dlfcn.h>
635 +# endif
636 +#endif
637 +#ifdef WIN32
638 +# include <shlobj.h>
639 +#endif
640 +#if HAVE_PAPER_H
641 +#include <paper.h>
642 +#endif
643 +#include <fontconfig/fontconfig.h>
644 +#include "goo/gmem.h"
645 +#include "goo/GooString.h"
646 +#include "goo/GooList.h"
647 +#include "goo/GooHash.h"
648 +#include "goo/gfile.h"
649 +#include "Error.h"
650 +#include "NameToCharCode.h"
651 +#include "CharCodeToUnicode.h"
652 +#include "UnicodeMap.h"
653 +#include "CMap.h"
654 +#include "BuiltinFontTables.h"
655 +#include "FontEncodingTables.h"
656 +#include <langinfo.h>
657 +#include <locale.h>
658 +#ifdef ENABLE_PLUGINS
659 +# include "XpdfPluginAPI.h"
660 +#endif
661 +#include "GlobalParamsGUI.h"
662 +#include "GfxFont.h"
663 +
664 +#ifdef WIN32
665 +# define strcasecmp stricmp
666 +#endif
667 +
668 +#if MULTITHREADED
669 +# define lockGlobalParamsGUI gLockMutex(&mutex)
670 +# define lockUnicodeMapCache gLockMutex(&unicodeMapCacheMutex)
671 +# define lockCMapCache gLockMutex(&cMapCacheMutex)
672 +# define unlockGlobalParamsGUI gUnlockMutex(&mutex)
673 +# define unlockUnicodeMapCache gUnlockMutex(&unicodeMapCacheMutex)
674 +# define unlockCMapCache gUnlockMutex(&cMapCacheMutex)
675 +#else
676 +# define lockGlobalParamsGUI
677 +# define lockUnicodeMapCache
678 +# define lockCMapCache
679 +# define unlockGlobalParamsGUI
680 +# define unlockUnicodeMapCache
681 +# define unlockCMapCache
682 +#endif
683 +
684 +#ifndef FC_WEIGHT_BOOK
685 +#define FC_WEIGHT_BOOK 75
686 +#endif
687 +
688 +#include "NameToUnicodeTable.h"
689 +#include "UnicodeMapTables.h"
690 +#include "UTF8.h"
691 +
692 +#ifdef ENABLE_PLUGINS
693 +# ifdef WIN32
694 +extern XpdfPluginVecTable xpdfPluginVecTable;
695 +# endif
696 +#endif
697 +
698 +//------------------------------------------------------------------------
699 +
700 +#define cidToUnicodeCacheSize 4
701 +#define unicodeToUnicodeCacheSize 4
702 +
703 +//------------------------------------------------------------------------
704 +
705 +static struct {
706 + char *name;
707 + char *t1FileName;
708 + char *ttFileName;
709 +} displayFontTab[] = {
710 + {"Courier", "n022003l.pfb", "cour.ttf"},
711 + {"Courier-Bold", "n022004l.pfb", "courbd.ttf"},
712 + {"Courier-BoldOblique", "n022024l.pfb", "courbi.ttf"},
713 + {"Courier-Oblique", "n022023l.pfb", "couri.ttf"},
714 + {"Helvetica", "n019003l.pfb", "arial.ttf"},
715 + {"Helvetica-Bold", "n019004l.pfb", "arialbd.ttf"},
716 + {"Helvetica-BoldOblique", "n019024l.pfb", "arialbi.ttf"},
717 + {"Helvetica-Oblique", "n019023l.pfb", "ariali.ttf"},
718 + {"Symbol", "s050000l.pfb", NULL},
719 + {"Times-Bold", "n021004l.pfb", "timesbd.ttf"},
720 + {"Times-BoldItalic", "n021024l.pfb", "timesbi.ttf"},
721 + {"Times-Italic", "n021023l.pfb", "timesi.ttf"},
722 + {"Times-Roman", "n021003l.pfb", "times.ttf"},
723 + {"ZapfDingbats", "d050000l.pfb", NULL},
724 + {NULL}
725 +};
726 +
727 +#ifdef WIN32
728 +static char *displayFontDirs[] = {
729 + "c:/windows/fonts",
730 + "c:/winnt/fonts",
731 + NULL
732 +};
733 +#else
734 +static char *displayFontDirs[] = {
735 + "/usr/share/ghostscript/fonts",
736 + "/usr/local/share/ghostscript/fonts",
737 + "/usr/share/fonts/default/Type1",
738 + "/usr/share/fonts/default/ghostscript",
739 + "/usr/share/fonts/type1/gsfonts",
740 + NULL
741 +};
742 +#endif
743 +
744 +//------------------------------------------------------------------------
745 +
746 +GlobalParamsGUI *globalParamsGUI = NULL;
747 +
748 +//------------------------------------------------------------------------
749 +// DisplayFontParam
750 +//------------------------------------------------------------------------
751 +
752 +DisplayFontParam::DisplayFontParam(GooString *nameA,
753 + DisplayFontParamKind kindA) {
754 + name = nameA;
755 + kind = kindA;
756 + switch (kind) {
757 + case displayFontT1:
758 + t1.fileName = NULL;
759 + break;
760 + case displayFontTT:
761 + tt.fileName = NULL;
762 + break;
763 + }
764 +}
765 +
766 +DisplayFontParam::~DisplayFontParam() {
767 + delete name;
768 + switch (kind) {
769 + case displayFontT1:
770 + if (t1.fileName) {
771 + delete t1.fileName;
772 + }
773 + break;
774 + case displayFontTT:
775 + if (tt.fileName) {
776 + delete tt.fileName;
777 + }
778 + break;
779 + }
780 +}
781 +
782 +#ifdef WIN32
783 +
784 +//------------------------------------------------------------------------
785 +// WinFontInfo
786 +//------------------------------------------------------------------------
787 +
788 +class WinFontInfo: public DisplayFontParam {
789 +public:
790 +
791 + GBool bold, italic;
792 +
793 + static WinFontInfo *make(GooString *nameA, GBool boldA, GBool italicA,
794 + HKEY regKey, char *winFontDir);
795 + WinFontInfo(GooString *nameA, GBool boldA, GBool italicA,
796 + GooString *fileNameA);
797 + virtual ~WinFontInfo();
798 + GBool equals(WinFontInfo *fi);
799 +};
800 +
801 +WinFontInfo *WinFontInfo::make(GooString *nameA, GBool boldA, GBool italicA,
802 + HKEY regKey, char *winFontDir) {
803 + GooString *regName;
804 + GooString *fileNameA;
805 + char buf[MAX_PATH];
806 + DWORD n;
807 + char c;
808 + int i;
809 +
810 + //----- find the font file
811 + fileNameA = NULL;
812 + regName = nameA->copy();
813 + if (boldA) {
814 + regName->append(" Bold");
815 + }
816 + if (italicA) {
817 + regName->append(" Italic");
818 + }
819 + regName->append(" (TrueType)");
820 + n = sizeof(buf);
821 + if (RegQueryValueEx(regKey, regName->getCString(), NULL, NULL,
822 + (LPBYTE)buf, &n) == ERROR_SUCCESS) {
823 + fileNameA = new GooString(winFontDir);
824 + fileNameA->append('\\')->append(buf);
825 + }
826 + delete regName;
827 + if (!fileNameA) {
828 + delete nameA;
829 + return NULL;
830 + }
831 +
832 + //----- normalize the font name
833 + i = 0;
834 + while (i < nameA->getLength()) {
835 + c = nameA->getChar(i);
836 + if (c == ' ' || c == ',' || c == '-') {
837 + nameA->del(i);
838 + } else {
839 + ++i;
840 + }
841 + }
842 +
843 + return new WinFontInfo(nameA, boldA, italicA, fileNameA);
844 +}
845 +
846 +WinFontInfo::WinFontInfo(GooString *nameA, GBool boldA, GBool italicA,
847 + GooString *fileNameA):
848 + DisplayFontParam(nameA, displayFontTT)
849 +{
850 + bold = boldA;
851 + italic = italicA;
852 + tt.fileName = fileNameA;
853 +}
854 +
855 +WinFontInfo::~WinFontInfo() {
856 +}
857 +
858 +GBool WinFontInfo::equals(WinFontInfo *fi) {
859 + return !name->cmp(fi->name) && bold == fi->bold && italic == fi->italic;
860 +}
861 +
862 +//------------------------------------------------------------------------
863 +// WinFontList
864 +//------------------------------------------------------------------------
865 +
866 +class WinFontList {
867 +public:
868 +
869 + WinFontList(char *winFontDirA);
870 + ~WinFontList();
871 + WinFontInfo *find(GooString *font);
872 +
873 +private:
874 +
875 + void add(WinFontInfo *fi);
876 + static int CALLBACK enumFunc1(CONST LOGFONT *font,
877 + CONST TEXTMETRIC *metrics,
878 + DWORD type, LPARAM data);
879 + static int CALLBACK enumFunc2(CONST LOGFONT *font,
880 + CONST TEXTMETRIC *metrics,
881 + DWORD type, LPARAM data);
882 +
883 + GooList *fonts; // [WinFontInfo]
884 + HDC dc; // (only used during enumeration)
885 + HKEY regKey; // (only used during enumeration)
886 + char *winFontDir; // (only used during enumeration)
887 +};
888 +
889 +WinFontList::WinFontList(char *winFontDirA) {
890 + OSVERSIONINFO version;
891 + char *path;
892 +
893 + fonts = new GooList();
894 + dc = GetDC(NULL);
895 + winFontDir = winFontDirA;
896 + version.dwOSVersionInfoSize = sizeof(version);
897 + GetVersionEx(&version);
898 + if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
899 + path = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts\\";
900 + } else {
901 + path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Fonts\\";
902 + }
903 + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, path, 0,
904 + KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
905 + &regKey) == ERROR_SUCCESS) {
906 + EnumFonts(dc, NULL, &WinFontList::enumFunc1, (LPARAM)this);
907 + RegCloseKey(regKey);
908 + }
909 + ReleaseDC(NULL, dc);
910 +}
911 +
912 +WinFontList::~WinFontList() {
913 + deleteGooList(fonts, WinFontInfo);
914 +}
915 +
916 +void WinFontList::add(WinFontInfo *fi) {
917 + int i;
918 +
919 + for (i = 0; i < fonts->getLength(); ++i) {
920 + if (((WinFontInfo *)fonts->get(i))->equals(fi)) {
921 + delete fi;
922 + return;
923 + }
924 + }
925 + fonts->append(fi);
926 +}
927 +
928 +WinFontInfo *WinFontList::find(GooString *font) {
929 + GooString *name;
930 + GBool bold, italic;
931 + WinFontInfo *fi;
932 + char c;
933 + int n, i;
934 +
935 + name = font->copy();
936 +
937 + // remove space, comma, dash chars
938 + i = 0;
939 + while (i < name->getLength()) {
940 + c = name->getChar(i);
941 + if (c == ' ' || c == ',' || c == '-') {
942 + name->del(i);
943 + } else {
944 + ++i;
945 + }
946 + }
947 + n = name->getLength();
948 +
949 + // remove trailing "MT" (Foo-MT, Foo-BoldMT, etc.)
950 + if (!strcmp(name->getCString() + n - 2, "MT")) {
951 + name->del(n - 2, 2);
952 + n -= 2;
953 + }
954 +
955 + // look for "Italic"
956 + if (!strcmp(name->getCString() + n - 6, "Italic")) {
957 + name->del(n - 6, 6);
958 + italic = gTrue;
959 + n -= 6;
960 + } else {
961 + italic = gFalse;
962 + }
963 +
964 + // look for "Bold"
965 + if (!strcmp(name->getCString() + n - 4, "Bold")) {
966 + name->del(n - 4, 4);
967 + bold = gTrue;
968 + n -= 4;
969 + } else {
970 + bold = gFalse;
971 + }
972 +
973 + // remove trailing "MT" (FooMT-Bold, etc.)
974 + if (!strcmp(name->getCString() + n - 2, "MT")) {
975 + name->del(n - 2, 2);
976 + n -= 2;
977 + }
978 +
979 + // remove trailing "PS"
980 + if (!strcmp(name->getCString() + n - 2, "PS")) {
981 + name->del(n - 2, 2);
982 + n -= 2;
983 + }
984 +
985 + // search for the font
986 + fi = NULL;
987 + for (i = 0; i < fonts->getLength(); ++i) {
988 + fi = (WinFontInfo *)fonts->get(i);
989 + if (!fi->name->cmp(name) && fi->bold == bold && fi->italic == italic) {
990 + break;
991 + }
992 + fi = NULL;
993 + }
994 +
995 + delete name;
996 + return fi;
997 +}
998 +
999 +int CALLBACK WinFontList::enumFunc1(CONST LOGFONT *font,
1000 + CONST TEXTMETRIC *metrics,
1001 + DWORD type, LPARAM data) {
1002 + WinFontList *fl = (WinFontList *)data;
1003 +
1004 + EnumFonts(fl->dc, font->lfFaceName, &WinFontList::enumFunc2, (LPARAM)fl);
1005 + return 1;
1006 +}
1007 +
1008 +int CALLBACK WinFontList::enumFunc2(CONST LOGFONT *font,
1009 + CONST TEXTMETRIC *metrics,
1010 + DWORD type, LPARAM data) {
1011 + WinFontList *fl = (WinFontList *)data;
1012 + WinFontInfo *fi;
1013 +
1014 + if (type & TRUETYPE_FONTTYPE) {
1015 + if ((fi = WinFontInfo::make(new GooString(font->lfFaceName),
1016 + font->lfWeight >= 600,
1017 + font->lfItalic ? gTrue : gFalse,
1018 + fl->regKey, fl->winFontDir))) {
1019 + fl->add(fi);
1020 + }
1021 + }
1022 + return 1;
1023 +}
1024 +
1025 +#endif // WIN32
1026 +
1027 +//------------------------------------------------------------------------
1028 +// PSFontParam
1029 +//------------------------------------------------------------------------
1030 +
1031 +PSFontParam::PSFontParam(GooString *pdfFontNameA, int wModeA,
1032 + GooString *psFontNameA, GooString *encodingA) {
1033 + pdfFontName = pdfFontNameA;
1034 + wMode = wModeA;
1035 + psFontName = psFontNameA;
1036 + encoding = encodingA;
1037 +}
1038 +
1039 +PSFontParam::~PSFontParam() {
1040 + delete pdfFontName;
1041 + delete psFontName;
1042 + if (encoding) {
1043 + delete encoding;
1044 + }
1045 +}
1046 +
1047 +//------------------------------------------------------------------------
1048 +// KeyBinding
1049 +//------------------------------------------------------------------------
1050 +
1051 +KeyBinding::KeyBinding(int codeA, int modsA, int contextA, char *cmd0) {
1052 + code = codeA;
1053 + mods = modsA;
1054 + context = contextA;
1055 + cmds = new GooList();
1056 + cmds->append(new GooString(cmd0));
1057 +}
1058 +
1059 +KeyBinding::KeyBinding(int codeA, int modsA, int contextA,
1060 + char *cmd0, char *cmd1) {
1061 + code = codeA;
1062 + mods = modsA;
1063 + context = contextA;
1064 + cmds = new GooList();
1065 + cmds->append(new GooString(cmd0));
1066 + cmds->append(new GooString(cmd1));
1067 +}
1068 +
1069 +KeyBinding::KeyBinding(int codeA, int modsA, int contextA, GooList *cmdsA) {
1070 + code = codeA;
1071 + mods = modsA;
1072 + context = contextA;
1073 + cmds = cmdsA;
1074 +}
1075 +
1076 +KeyBinding::~KeyBinding() {
1077 + deleteGooList(cmds, GooString);
1078 +}
1079 +
1080 +#ifdef ENABLE_PLUGINS
1081 +//------------------------------------------------------------------------
1082 +// Plugin
1083 +//------------------------------------------------------------------------
1084 +
1085 +class Plugin {
1086 +public:
1087 +
1088 + static Plugin *load(char *type, char *name);
1089 + ~Plugin();
1090 +
1091 +private:
1092 +
1093 +#ifdef WIN32
1094 + Plugin(HMODULE libA);
1095 + HMODULE lib;
1096 +#else
1097 + Plugin(void *dlA);
1098 + void *dl;
1099 +#endif
1100 +};
1101 +
1102 +Plugin *Plugin::load(char *type, char *name) {
1103 + GooString *path;
1104 + Plugin *plugin;
1105 + XpdfPluginVecTable *vt;
1106 + XpdfBool (*xpdfInitPlugin)(void);
1107 +#ifdef WIN32
1108 + HMODULE libA;
1109 +#else
1110 + void *dlA;
1111 +#endif
1112 +
1113 + path = globalParamsGUI->getBaseDir();
1114 + appendToPath(path, "plugins");
1115 + appendToPath(path, type);
1116 + appendToPath(path, name);
1117 +
1118 +#ifdef WIN32
1119 + path->append(".dll");
1120 + if (!(libA = LoadLibrary(path->getCString()))) {
1121 + error(-1, "Failed to load plugin '%s'",
1122 + path->getCString());
1123 + goto err1;
1124 + }
1125 + if (!(vt = (XpdfPluginVecTable *)
1126 + GetProcAddress(libA, "xpdfPluginVecTable"))) {
1127 + error(-1, "Failed to find xpdfPluginVecTable in plugin '%s'",
1128 + path->getCString());
1129 + goto err2;
1130 + }
1131 +#else
1132 + //~ need to deal with other extensions here
1133 + path->append(".so");
1134 + if (!(dlA = dlopen(path->getCString(), RTLD_NOW))) {
1135 + error(-1, "Failed to load plugin '%s': %s",
1136 + path->getCString(), dlerror());
1137 + goto err1;
1138 + }
1139 + if (!(vt = (XpdfPluginVecTable *)dlsym(dlA, "xpdfPluginVecTable"))) {
1140 + error(-1, "Failed to find xpdfPluginVecTable in plugin '%s'",
1141 + path->getCString());
1142 + goto err2;
1143 + }
1144 +#endif
1145 +
1146 + if (vt->version != xpdfPluginVecTable.version) {
1147 + error(-1, "Plugin '%s' is wrong version", path->getCString());
1148 + goto err2;
1149 + }
1150 + memcpy(vt, &xpdfPluginVecTable, sizeof(xpdfPluginVecTable));
1151 +
1152 +#ifdef WIN32
1153 + if (!(xpdfInitPlugin = (XpdfBool (*)(void))
1154 + GetProcAddress(libA, "xpdfInitPlugin"))) {
1155 + error(-1, "Failed to find xpdfInitPlugin in plugin '%s'",
1156 + path->getCString());
1157 + goto err2;
1158 + }
1159 +#else
1160 + if (!(xpdfInitPlugin = (XpdfBool (*)(void))dlsym(dlA, "xpdfInitPlugin"))) {
1161 + error(-1, "Failed to find xpdfInitPlugin in plugin '%s'",
1162 + path->getCString());
1163 + goto err2;
1164 + }
1165 +#endif
1166 +
1167 + if (!(*xpdfInitPlugin)()) {
1168 + error(-1, "Initialization of plugin '%s' failed",
1169 + path->getCString());
1170 + goto err2;
1171 + }
1172 +
1173 +#ifdef WIN32
1174 + plugin = new Plugin(libA);
1175 +#else
1176 + plugin = new Plugin(dlA);
1177 +#endif
1178 +
1179 + delete path;
1180 + return plugin;
1181 +
1182 + err2:
1183 +#ifdef WIN32
1184 + FreeLibrary(libA);
1185 +#else
1186 + dlclose(dlA);
1187 +#endif
1188 + err1:
1189 + delete path;
1190 + return NULL;
1191 +}
1192 +
1193 +#ifdef WIN32
1194 +Plugin::Plugin(HMODULE libA) {
1195 + lib = libA;
1196 +}
1197 +#else
1198 +Plugin::Plugin(void *dlA) {
1199 + dl = dlA;
1200 +}
1201 +#endif
1202 +
1203 +Plugin::~Plugin() {
1204 + void (*xpdfFreePlugin)(void);
1205 +
1206 +#ifdef WIN32
1207 + if ((xpdfFreePlugin = (void (*)(void))
1208 + GetProcAddress(lib, "xpdfFreePlugin"))) {
1209 + (*xpdfFreePlugin)();
1210 + }
1211 + FreeLibrary(lib);
1212 +#else
1213 + if ((xpdfFreePlugin = (void (*)(void))dlsym(dl, "xpdfFreePlugin"))) {
1214 + (*xpdfFreePlugin)();
1215 + }
1216 + dlclose(dl);
1217 +#endif
1218 +}
1219 +
1220 +#endif // ENABLE_PLUGINS
1221 +
1222 +//------------------------------------------------------------------------
1223 +// parsing
1224 +//------------------------------------------------------------------------
1225 +
1226 +GlobalParamsGUI::GlobalParamsGUI(char *cfgFileName) {
1227 + UnicodeMap *map;
1228 + GooString *fileName;
1229 + FILE *f;
1230 + int i;
1231 +
1232 + FcInit();
1233 + FCcfg = FcConfigGetCurrent();
1234 +
1235 +#if MULTITHREADED
1236 + gInitMutex(&mutex);
1237 + gInitMutex(&unicodeMapCacheMutex);
1238 + gInitMutex(&cMapCacheMutex);
1239 +#endif
1240 +
1241 + initBuiltinFontTables();
1242 +
1243 + // scan the encoding in reverse because we want the lowest-numbered
1244 + // index for each char name ('space' is encoded twice)
1245 + macRomanReverseMap = new NameToCharCode();
1246 + for (i = 255; i >= 0; --i) {
1247 + if (macRomanEncoding[i]) {
1248 + macRomanReverseMap->add(macRomanEncoding[i], (CharCode)i);
1249 + }
1250 + }
1251 +
1252 +#ifdef WIN32
1253 + // baseDir will be set by a call to setBaseDir
1254 + baseDir = new GooString();
1255 +#else
1256 + baseDir = appendToPath(getHomeDir(), ".xpdf");
1257 +#endif
1258 + nameToUnicode = new NameToCharCode();
1259 + cidToUnicodes = new GooHash(gTrue);
1260 + unicodeToUnicodes = new GooHash(gTrue);
1261 + residentUnicodeMaps = new GooHash();
1262 + unicodeMaps = new GooHash(gTrue);
1263 + cMapDirs = new GooHash(gTrue);
1264 + toUnicodeDirs = new GooList();
1265 + displayFonts = new GooHash();
1266 + displayCIDFonts = new GooHash();
1267 + displayNamedCIDFonts = new GooHash();
1268 +#if HAVE_PAPER_H
1269 + char *paperName;
1270 + const struct paper *paperType;
1271 + paperinit();
1272 + if ((paperName = systempapername())) {
1273 + paperType = paperinfo(paperName);
1274 + psPaperWidth = (int)paperpswidth(paperType);
1275 + psPaperHeight = (int)paperpsheight(paperType);
1276 + } else {
1277 + error(-1, "No paper information available - using defaults");
1278 + psPaperWidth = defPaperWidth;
1279 + psPaperHeight = defPaperHeight;
1280 + }
1281 + paperdone();
1282 +#else
1283 + psPaperWidth = defPaperWidth;
1284 + psPaperHeight = defPaperHeight;
1285 +#endif
1286 + psImageableLLX = psImageableLLY = 0;
1287 + psImageableURX = psPaperWidth;
1288 + psImageableURY = psPaperHeight;
1289 + psCrop = gTrue;
1290 + psExpandSmaller = gFalse;
1291 + psShrinkLarger = gTrue;
1292 + psCenter = gTrue;
1293 + psDuplex = gFalse;
1294 + psLevel = psLevel2;
1295 + psFile = NULL;
1296 + psFonts = new GooHash();
1297 + psNamedFonts16 = new GooList();
1298 + psFonts16 = new GooList();
1299 + psEmbedType1 = gTrue;
1300 + psEmbedTrueType = gTrue;
1301 + psEmbedCIDPostScript = gTrue;
1302 + psEmbedCIDTrueType = gTrue;
1303 + psPreload = gFalse;
1304 + psOPI = gFalse;
1305 + psASCIIHex = gFalse;
1306 + setlocale(LC_ALL,"");
1307 + setlocale(LC_NUMERIC,"POSIX");
1308 + if (strcmp("UTF-8",nl_langinfo(CODESET)))
1309 + textEncoding = new GooString("Latin1");
1310 + else
1311 + textEncoding = new GooString("UTF-8");
1312 +#if defined(WIN32)
1313 + textEOL = eolDOS;
1314 +#elif defined(MACOS)
1315 + textEOL = eolMac;
1316 +#else
1317 + textEOL = eolUnix;
1318 +#endif
1319 + textPageBreaks = gTrue;
1320 + textKeepTinyChars = gFalse;
1321 + fontDirs = new GooList();
1322 + initialZoom = new GooString("125");
1323 + continuousView = gFalse;
1324 + enableT1lib = gTrue;
1325 + enableFreeType = gTrue;
1326 + antialias = gTrue;
1327 + vectorAntialias = gTrue;
1328 + strokeAdjust = gTrue;
1329 + screenType = screenUnset;
1330 + screenSize = -1;
1331 + screenDotRadius = -1;
1332 + screenGamma = 1.0;
1333 + screenBlackThreshold = 0.0;
1334 + screenWhiteThreshold = 1.0;
1335 + urlCommand = NULL;
1336 + movieCommand = NULL;
1337 + mapNumericCharNames = gTrue;
1338 + mapUnknownCharNames = gFalse;
1339 + createDefaultKeyBindings();
1340 + printCommands = gFalse;
1341 + profileCommands = gFalse;
1342 + errQuiet = gFalse;
1343 +
1344 + cidToUnicodeCache = new CharCodeToUnicodeCache(cidToUnicodeCacheSize);
1345 + unicodeToUnicodeCache =
1346 + new CharCodeToUnicodeCache(unicodeToUnicodeCacheSize);
1347 + unicodeMapCache = new UnicodeMapCache();
1348 + cMapCache = new CMapCache();
1349 +
1350 +#ifdef WIN32
1351 + winFontList = NULL;
1352 +#endif
1353 +
1354 +#ifdef ENABLE_PLUGINS
1355 + plugins = new GooList();
1356 + securityHandlers = new GooList();
1357 +#endif
1358 +
1359 + // set up the initial nameToUnicode table
1360 + for (i = 0; nameToUnicodeTab[i].name; ++i) {
1361 + nameToUnicode->add(nameToUnicodeTab[i].name, nameToUnicodeTab[i].u);
1362 + }
1363 +
1364 + // set up the residentUnicodeMaps table
1365 + map = new UnicodeMap("Latin1", gFalse,
1366 + latin1UnicodeMapRanges, latin1UnicodeMapLen);
1367 + residentUnicodeMaps->add(map->getEncodingName(), map);
1368 + map = new UnicodeMap("ASCII7", gFalse,
1369 + ascii7UnicodeMapRanges, ascii7UnicodeMapLen);
1370 + residentUnicodeMaps->add(map->getEncodingName(), map);
1371 + map = new UnicodeMap("Symbol", gFalse,
1372 + symbolUnicodeMapRanges, symbolUnicodeMapLen);
1373 + residentUnicodeMaps->add(map->getEncodingName(), map);
1374 + map = new UnicodeMap("ZapfDingbats", gFalse, zapfDingbatsUnicodeMapRanges,
1375 + zapfDingbatsUnicodeMapLen);
1376 + residentUnicodeMaps->add(map->getEncodingName(), map);
1377 + map = new UnicodeMap("UTF-8", gTrue, &mapUTF8);
1378 + residentUnicodeMaps->add(map->getEncodingName(), map);
1379 + map = new UnicodeMap("UCS-2", gTrue, &mapUCS2);
1380 + residentUnicodeMaps->add(map->getEncodingName(), map);
1381 +
1382 + // look for a user config file, then a system-wide config file
1383 + f = NULL;
1384 + fileName = NULL;
1385 + if (cfgFileName && cfgFileName[0]) {
1386 + fileName = new GooString(cfgFileName);
1387 + if (!(f = fopen(fileName->getCString(), "r"))) {
1388 + delete fileName;
1389 + }
1390 + }
1391 + if (!f) {
1392 + fileName = appendToPath(getHomeDir(), xpdfUserConfigFile);
1393 + if (!(f = fopen(fileName->getCString(), "r"))) {
1394 + delete fileName;
1395 + }
1396 + }
1397 + if (!f) {
1398 +#if defined(WIN32) && !defined(__CYGWIN32__)
1399 + char buf[512];
1400 + i = GetModuleFileName(NULL, buf, sizeof(buf));
1401 + if (i <= 0 || i >= sizeof(buf)) {
1402 + // error or path too long for buffer - just use the current dir
1403 + buf[0] = '\0';
1404 + }
1405 + fileName = grabPath(buf);
1406 + appendToPath(fileName, xpdfSysConfigFile);
1407 +#else
1408 + fileName = new GooString(xpdfSysConfigFile);
1409 +#endif
1410 + if (!(f = fopen(fileName->getCString(), "r"))) {
1411 + delete fileName;
1412 + }
1413 + }
1414 + if (f) {
1415 + parseFile(fileName, f);
1416 + delete fileName;
1417 + fclose(f);
1418 + }
1419 +}
1420 +
1421 +void GlobalParamsGUI::createDefaultKeyBindings() {
1422 + keyBindings = new GooList();
1423 +
1424 + //----- mouse buttons
1425 + keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress1, xpdfKeyModNone,
1426 + xpdfKeyContextAny, "startSelection"));
1427 + keyBindings->append(new KeyBinding(xpdfKeyCodeMouseRelease1, xpdfKeyModNone,
1428 + xpdfKeyContextAny, "endSelection",
1429 + "followLinkNoSel"));
1430 + keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress2, xpdfKeyModNone,
1431 + xpdfKeyContextAny, "startPan"));
1432 + keyBindings->append(new KeyBinding(xpdfKeyCodeMouseRelease2, xpdfKeyModNone,
1433 + xpdfKeyContextAny, "endPan"));
1434 + keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress3, xpdfKeyModNone,
1435 + xpdfKeyContextAny, "postPopupMenu"));
1436 + keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress4, xpdfKeyModNone,
1437 + xpdfKeyContextAny,
1438 + "scrollUpPrevPage(16)"));
1439 + keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress5, xpdfKeyModNone,
1440 + xpdfKeyContextAny,
1441 + "scrollDownNextPage(16)"));
1442 + keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress6, xpdfKeyModNone,
1443 + xpdfKeyContextAny, "scrollLeft(16)"));
1444 + keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress7, xpdfKeyModNone,
1445 + xpdfKeyContextAny, "scrollRight(16)"));
1446 +
1447 + //----- keys
1448 + keyBindings->append(new KeyBinding(xpdfKeyCodeHome, xpdfKeyModCtrl,
1449 + xpdfKeyContextAny, "gotoPage(1)"));
1450 + keyBindings->append(new KeyBinding(xpdfKeyCodeHome, xpdfKeyModNone,
1451 + xpdfKeyContextAny, "scrollToTopLeft"));
1452 + keyBindings->append(new KeyBinding(xpdfKeyCodeEnd, xpdfKeyModCtrl,
1453 + xpdfKeyContextAny, "gotoLastPage"));
1454 + keyBindings->append(new KeyBinding(xpdfKeyCodeEnd, xpdfKeyModNone,
1455 + xpdfKeyContextAny,
1456 + "scrollToBottomRight"));
1457 + keyBindings->append(new KeyBinding(xpdfKeyCodePgUp, xpdfKeyModNone,
1458 + xpdfKeyContextAny, "pageUp"));
1459 + keyBindings->append(new KeyBinding(xpdfKeyCodeBackspace, xpdfKeyModNone,
1460 + xpdfKeyContextAny, "pageUp"));
1461 + keyBindings->append(new KeyBinding(xpdfKeyCodeDelete, xpdfKeyModNone,
1462 + xpdfKeyContextAny, "pageUp"));
1463 + keyBindings->append(new KeyBinding(xpdfKeyCodePgDn, xpdfKeyModNone,
1464 + xpdfKeyContextAny, "pageDown"));
1465 + keyBindings->append(new KeyBinding(' ', xpdfKeyModNone,
1466 + xpdfKeyContextAny, "pageDown"));
1467 + keyBindings->append(new KeyBinding(xpdfKeyCodeLeft, xpdfKeyModNone,
1468 + xpdfKeyContextAny, "scrollLeft(16)"));
1469 + keyBindings->append(new KeyBinding(xpdfKeyCodeRight, xpdfKeyModNone,
1470 + xpdfKeyContextAny, "scrollRight(16)"));
1471 + keyBindings->append(new KeyBinding(xpdfKeyCodeUp, xpdfKeyModNone,
1472 + xpdfKeyContextAny, "scrollUp(16)"));
1473 + keyBindings->append(new KeyBinding(xpdfKeyCodeDown, xpdfKeyModNone,
1474 + xpdfKeyContextAny, "scrollDown(16)"));
1475 + keyBindings->append(new KeyBinding('o', xpdfKeyModNone,
1476 + xpdfKeyContextAny, "open"));
1477 + keyBindings->append(new KeyBinding('O', xpdfKeyModNone,
1478 + xpdfKeyContextAny, "open"));
1479 + keyBindings->append(new KeyBinding('r', xpdfKeyModNone,
1480 + xpdfKeyContextAny, "reload"));
1481 + keyBindings->append(new KeyBinding('R', xpdfKeyModNone,
1482 + xpdfKeyContextAny, "reload"));
1483 + keyBindings->append(new KeyBinding('f', xpdfKeyModNone,
1484 + xpdfKeyContextAny, "find"));
1485 + keyBindings->append(new KeyBinding('F', xpdfKeyModNone,
1486 + xpdfKeyContextAny, "find"));
1487 + keyBindings->append(new KeyBinding('f', xpdfKeyModCtrl,
1488 + xpdfKeyContextAny, "find"));
1489 + keyBindings->append(new KeyBinding('g', xpdfKeyModCtrl,
1490 + xpdfKeyContextAny, "findNext"));
1491 + keyBindings->append(new KeyBinding('p', xpdfKeyModCtrl,
1492 + xpdfKeyContextAny, "print"));
1493 + keyBindings->append(new KeyBinding('n', xpdfKeyModNone,
1494 + xpdfKeyContextScrLockOff, "nextPage"));
1495 + keyBindings->append(new KeyBinding('N', xpdfKeyModNone,
1496 + xpdfKeyContextScrLockOff, "nextPage"));
1497 + keyBindings->append(new KeyBinding('n', xpdfKeyModNone,
1498 + xpdfKeyContextScrLockOn,
1499 + "nextPageNoScroll"));
1500 + keyBindings->append(new KeyBinding('N', xpdfKeyModNone,
1501 + xpdfKeyContextScrLockOn,
1502 + "nextPageNoScroll"));
1503 + keyBindings->append(new KeyBinding('p', xpdfKeyModNone,
1504 + xpdfKeyContextScrLockOff, "prevPage"));
1505 + keyBindings->append(new KeyBinding('P', xpdfKeyModNone,
1506 + xpdfKeyContextScrLockOff, "prevPage"));
1507 + keyBindings->append(new KeyBinding('p', xpdfKeyModNone,
1508 + xpdfKeyContextScrLockOn,
1509 + "prevPageNoScroll"));
1510 + keyBindings->append(new KeyBinding('P', xpdfKeyModNone,
1511 + xpdfKeyContextScrLockOn,
1512 + "prevPageNoScroll"));
1513 + keyBindings->append(new KeyBinding('v', xpdfKeyModNone,
1514 + xpdfKeyContextAny, "goForward"));
1515 + keyBindings->append(new KeyBinding('b', xpdfKeyModNone,
1516 + xpdfKeyContextAny, "goBackward"));
1517 + keyBindings->append(new KeyBinding('g', xpdfKeyModNone,
1518 + xpdfKeyContextAny, "focusToPageNum"));
1519 + keyBindings->append(new KeyBinding('0', xpdfKeyModNone,
1520 + xpdfKeyContextAny, "zoomPercent(125)"));
1521 + keyBindings->append(new KeyBinding('+', xpdfKeyModNone,
1522 + xpdfKeyContextAny, "zoomIn"));
1523 + keyBindings->append(new KeyBinding(xpdfKeyCodeAdd, xpdfKeyModNone,
1524 + xpdfKeyContextAny, "zoomIn"));
1525 + keyBindings->append(new KeyBinding('-', xpdfKeyModNone,
1526 + xpdfKeyContextAny, "zoomOut"));
1527 + keyBindings->append(new KeyBinding(xpdfKeyCodeSubtract, xpdfKeyModNone,
1528 + xpdfKeyContextAny, "zoomOut"));
1529 + keyBindings->append(new KeyBinding('z', xpdfKeyModNone,
1530 + xpdfKeyContextAny, "zoomFitPage"));
1531 + keyBindings->append(new KeyBinding('w', xpdfKeyModNone,
1532 + xpdfKeyContextAny, "zoomFitWidth"));
1533 + keyBindings->append(new KeyBinding('f', xpdfKeyModAlt,
1534 + xpdfKeyContextAny,
1535 + "toggleFullScreenMode"));
1536 + keyBindings->append(new KeyBinding('l', xpdfKeyModCtrl,
1537 + xpdfKeyContextAny, "redraw"));
1538 + keyBindings->append(new KeyBinding('w', xpdfKeyModCtrl,
1539 + xpdfKeyContextAny, "closeWindow"));
1540 + keyBindings->append(new KeyBinding('?', xpdfKeyModNone,
1541 + xpdfKeyContextAny, "about"));
1542 + keyBindings->append(new KeyBinding('q', xpdfKeyModNone,
1543 + xpdfKeyContextAny, "quit"));
1544 + keyBindings->append(new KeyBinding('Q', xpdfKeyModNone,
1545 + xpdfKeyContextAny, "quit"));
1546 +}
1547 +
1548 +void GlobalParamsGUI::parseFile(GooString *fileName, FILE *f) {
1549 + int line;
1550 + char buf[512];
1551 +
1552 + line = 1;
1553 + while (getLine(buf, sizeof(buf) - 1, f)) {
1554 + parseLine(buf, fileName, line);
1555 + ++line;
1556 + }
1557 +}
1558 +
1559 +void GlobalParamsGUI::parseLine(char *buf, GooString *fileName, int line) {
1560 + GooList *tokens;
1561 + GooString *cmd, *incFile;
1562 + char *p1, *p2;
1563 + FILE *f2;
1564 +
1565 + // break the line into tokens
1566 + tokens = new GooList();
1567 + p1 = buf;
1568 + while (*p1) {
1569 + for (; *p1 && isspace(*p1); ++p1) ;
1570 + if (!*p1) {
1571 + break;
1572 + }
1573 + if (*p1 == '"' || *p1 == '\'') {
1574 + for (p2 = p1 + 1; *p2 && *p2 != *p1; ++p2) ;
1575 + ++p1;
1576 + } else {
1577 + for (p2 = p1 + 1; *p2 && !isspace(*p2); ++p2) ;
1578 + }
1579 + tokens->append(new GooString(p1, p2 - p1));
1580 + p1 = *p2 ? p2 + 1 : p2;
1581 + }
1582 +
1583 + // parse the line
1584 + if (tokens->getLength() > 0 &&
1585 + ((GooString *)tokens->get(0))->getChar(0) != '#') {
1586 + cmd = (GooString *)tokens->get(0);
1587 + if (!cmd->cmp("include")) {
1588 + if (tokens->getLength() == 2) {
1589 + incFile = (GooString *)tokens->get(1);
1590 + if ((f2 = fopen(incFile->getCString(), "r"))) {
1591 + parseFile(incFile, f2);
1592 + fclose(f2);
1593 + } else {
1594 + error(-1, "Couldn't find included config file: '%s' (%s:%d)",
1595 + incFile->getCString(), fileName->getCString(), line);
1596 + }
1597 + } else {
1598 + error(-1, "Bad 'include' config file command (%s:%d)",
1599 + fileName->getCString(), line);
1600 + }
1601 + } else if (!cmd->cmp("nameToUnicode")) {
1602 + parseNameToUnicode(tokens, fileName, line);
1603 + } else if (!cmd->cmp("cidToUnicode")) {
1604 + parseCIDToUnicode(tokens, fileName, line);
1605 + } else if (!cmd->cmp("unicodeToUnicode")) {
1606 + parseUnicodeToUnicode(tokens, fileName, line);
1607 + } else if (!cmd->cmp("unicodeMap")) {
1608 + parseUnicodeMap(tokens, fileName, line);
1609 + } else if (!cmd->cmp("cMapDir")) {
1610 + parseCMapDir(tokens, fileName, line);
1611 + } else if (!cmd->cmp("toUnicodeDir")) {
1612 + parseToUnicodeDir(tokens, fileName, line);
1613 + } else if (!cmd->cmp("displayFontT1")) {
1614 + parseDisplayFont(tokens, displayFonts, displayFontT1, fileName, line);
1615 + } else if (!cmd->cmp("displayFontTT")) {
1616 + parseDisplayFont(tokens, displayFonts, displayFontTT, fileName, line);
1617 + } else if (!cmd->cmp("displayNamedCIDFontT1")) {
1618 + parseDisplayFont(tokens, displayNamedCIDFonts,
1619 + displayFontT1, fileName, line);
1620 + } else if (!cmd->cmp("displayCIDFontT1")) {
1621 + parseDisplayFont(tokens, displayCIDFonts,
1622 + displayFontT1, fileName, line);
1623 + } else if (!cmd->cmp("displayNamedCIDFontTT")) {
1624 + parseDisplayFont(tokens, displayNamedCIDFonts,
1625 + displayFontTT, fileName, line);
1626 + } else if (!cmd->cmp("displayCIDFontTT")) {
1627 + parseDisplayFont(tokens, displayCIDFonts,
1628 + displayFontTT, fileName, line);
1629 + } else if (!cmd->cmp("psFile")) {
1630 + parsePSFile(tokens, fileName, line);
1631 + } else if (!cmd->cmp("psFont")) {
1632 + parsePSFont(tokens, fileName, line);
1633 + } else if (!cmd->cmp("psNamedFont16")) {
1634 + parsePSFont16("psNamedFont16", psNamedFonts16,
1635 + tokens, fileName, line);
1636 + } else if (!cmd->cmp("psFont16")) {
1637 + parsePSFont16("psFont16", psFonts16, tokens, fileName, line);
1638 + } else if (!cmd->cmp("psPaperSize")) {
1639 + parsePSPaperSize(tokens, fileName, line);
1640 + } else if (!cmd->cmp("psImageableArea")) {
1641 + parsePSImageableArea(tokens, fileName, line);
1642 + } else if (!cmd->cmp("psCrop")) {
1643 + parseYesNo("psCrop", &psCrop, tokens, fileName, line);
1644 + } else if (!cmd->cmp("psExpandSmaller")) {
1645 + parseYesNo("psExpandSmaller", &psExpandSmaller,
1646 + tokens, fileName, line);
1647 + } else if (!cmd->cmp("psShrinkLarger")) {
1648 + parseYesNo("psShrinkLarger", &psShrinkLarger, tokens, fileName, line);
1649 + } else if (!cmd->cmp("psCenter")) {
1650 + parseYesNo("psCenter", &psCenter, tokens, fileName, line);
1651 + } else if (!cmd->cmp("psDuplex")) {
1652 + parseYesNo("psDuplex", &psDuplex, tokens, fileName, line);
1653 + } else if (!cmd->cmp("psLevel")) {
1654 + parsePSLevel(tokens, fileName, line);
1655 + } else if (!cmd->cmp("psEmbedType1Fonts")) {
1656 + parseYesNo("psEmbedType1", &psEmbedType1, tokens, fileName, line);
1657 + } else if (!cmd->cmp("psEmbedTrueTypeFonts")) {
1658 + parseYesNo("psEmbedTrueType", &psEmbedTrueType,
1659 + tokens, fileName, line);
1660 + } else if (!cmd->cmp("psEmbedCIDPostScriptFonts")) {
1661 + parseYesNo("psEmbedCIDPostScript", &psEmbedCIDPostScript,
1662 + tokens, fileName, line);
1663 + } else if (!cmd->cmp("psEmbedCIDTrueTypeFonts")) {
1664 + parseYesNo("psEmbedCIDTrueType", &psEmbedCIDTrueType,
1665 + tokens, fileName, line);
1666 + } else if (!cmd->cmp("psPreload")) {
1667 + parseYesNo("psPreload", &psPreload, tokens, fileName, line);
1668 + } else if (!cmd->cmp("psOPI")) {
1669 + parseYesNo("psOPI", &psOPI, tokens, fileName, line);
1670 + } else if (!cmd->cmp("psASCIIHex")) {
1671 + parseYesNo("psASCIIHex", &psASCIIHex, tokens, fileName, line);
1672 + } else if (!cmd->cmp("textEncoding")) {
1673 + parseTextEncoding(tokens, fileName, line);
1674 + } else if (!cmd->cmp("textEOL")) {
1675 + parseTextEOL(tokens, fileName, line);
1676 + } else if (!cmd->cmp("textPageBreaks")) {
1677 + parseYesNo("textPageBreaks", &textPageBreaks,
1678 + tokens, fileName, line);
1679 + } else if (!cmd->cmp("textKeepTinyChars")) {
1680 + parseYesNo("textKeepTinyChars", &textKeepTinyChars,
1681 + tokens, fileName, line);
1682 + } else if (!cmd->cmp("fontDir")) {
1683 + parseFontDir(tokens, fileName, line);
1684 + } else if (!cmd->cmp("initialZoom")) {
1685 + parseInitialZoom(tokens, fileName, line);
1686 + } else if (!cmd->cmp("continuousView")) {
1687 + parseYesNo("continuousView", &continuousView, tokens, fileName, line);
1688 + } else if (!cmd->cmp("enableT1lib")) {
1689 + parseYesNo("enableT1lib", &enableT1lib, tokens, fileName, line);
1690 + } else if (!cmd->cmp("enableFreeType")) {
1691 + parseYesNo("enableFreeType", &enableFreeType, tokens, fileName, line);
1692 + } else if (!cmd->cmp("antialias")) {
1693 + parseYesNo("antialias", &antialias, tokens, fileName, line);
1694 + } else if (!cmd->cmp("vectorAntialias")) {
1695 + parseYesNo("vectorAntialias", &vectorAntialias,
1696 + tokens, fileName, line);
1697 + } else if (!cmd->cmp("strokeAdjust")) {
1698 + parseYesNo("strokeAdjust", &strokeAdjust, tokens, fileName, line);
1699 + } else if (!cmd->cmp("screenType")) {
1700 + parseScreenType(tokens, fileName, line);
1701 + } else if (!cmd->cmp("screenSize")) {
1702 + parseInteger("screenSize", &screenSize, tokens, fileName, line);
1703 + } else if (!cmd->cmp("screenDotRadius")) {
1704 + parseInteger("screenDotRadius", &screenDotRadius,
1705 + tokens, fileName, line);
1706 + } else if (!cmd->cmp("screenGamma")) {
1707 + parseFloat("screenGamma", &screenGamma,
1708 + tokens, fileName, line);
1709 + } else if (!cmd->cmp("screenBlackThreshold")) {
1710 + parseFloat("screenBlackThreshold", &screenBlackThreshold,
1711 + tokens, fileName, line);
1712 + } else if (!cmd->cmp("screenWhiteThreshold")) {
1713 + parseFloat("screenWhiteThreshold", &screenWhiteThreshold,
1714 + tokens, fileName, line);
1715 + } else if (!cmd->cmp("urlCommand")) {
1716 + parseCommand("urlCommand", &urlCommand, tokens, fileName, line);
1717 + } else if (!cmd->cmp("movieCommand")) {
1718 + parseCommand("movieCommand", &movieCommand, tokens, fileName, line);
1719 + } else if (!cmd->cmp("mapNumericCharNames")) {
1720 + parseYesNo("mapNumericCharNames", &mapNumericCharNames,
1721 + tokens, fileName, line);
1722 + } else if (!cmd->cmp("mapUnknownCharNames")) {
1723 + parseYesNo("mapUnknownCharNames", &mapUnknownCharNames,
1724 + tokens, fileName, line);
1725 + } else if (!cmd->cmp("bind")) {
1726 + parseBind(tokens, fileName, line);
1727 + } else if (!cmd->cmp("unbind")) {
1728 + parseUnbind(tokens, fileName, line);
1729 + } else if (!cmd->cmp("printCommands")) {
1730 + parseYesNo("printCommands", &printCommands, tokens, fileName, line);
1731 + } else if (!cmd->cmp("errQuiet")) {
1732 + parseYesNo("errQuiet", &errQuiet, tokens, fileName, line);
1733 + } else {
1734 + error(-1, "Unknown config file command '%s' (%s:%d)",
1735 + cmd->getCString(), fileName->getCString(), line);
1736 + if (!cmd->cmp("displayFontX") ||
1737 + !cmd->cmp("displayNamedCIDFontX") ||
1738 + !cmd->cmp("displayCIDFontX")) {
1739 + error(-1, "-- Xpdf no longer supports X fonts");
1740 + } else if (!cmd->cmp("t1libControl") || !cmd->cmp("freetypeControl")) {
1741 + error(-1, "-- The t1libControl and freetypeControl options have been replaced");
1742 + error(-1, " by the enableT1lib, enableFreeType, and antialias options");
1743 + } else if (!cmd->cmp("fontpath") || !cmd->cmp("fontmap")) {
1744 + error(-1, "-- the config file format has changed since Xpdf 0.9x");
1745 + }
1746 + }
1747 + }
1748 +
1749 + deleteGooList(tokens, GooString);
1750 +}
1751 +
1752 +void GlobalParamsGUI::parseNameToUnicode(GooList *tokens, GooString *fileName,
1753 + int line) {
1754 + GooString *name;
1755 + char *tok1, *tok2;
1756 + FILE *f;
1757 + char buf[256];
1758 + int line2;
1759 + Unicode u;
1760 +
1761 + if (tokens->getLength() != 2) {
1762 + error(-1, "Bad 'nameToUnicode' config file command (%s:%d)",
1763 + fileName->getCString(), line);
1764 + return;
1765 + }
1766 + name = (GooString *)tokens->get(1);
1767 + if (!(f = fopen(name->getCString(), "r"))) {
1768 + error(-1, "Couldn't open 'nameToUnicode' file '%s'",
1769 + name->getCString());
1770 + return;
1771 + }
1772 + line2 = 1;
1773 + while (getLine(buf, sizeof(buf), f)) {
1774 + tok1 = strtok(buf, " \t\r\n");
1775 + tok2 = strtok(NULL, " \t\r\n");
1776 + if (tok1 && tok2) {
1777 + sscanf(tok1, "%x", &u);
1778 + nameToUnicode->add(tok2, u);
1779 + } else {
1780 + error(-1, "Bad line in 'nameToUnicode' file (%s:%d)",
1781 + name->getCString(), line2);
1782 + }
1783 + ++line2;
1784 + }
1785 + fclose(f);
1786 +}
1787 +
1788 +void GlobalParamsGUI::parseNameToUnicode(GooString *name) {
1789 + char *tok1, *tok2;
1790 + FILE *f;
1791 + char buf[256];
1792 + int line;
1793 + Unicode u;
1794 +
1795 + if (!(f = fopen(name->getCString(), "r"))) {
1796 + error(-1, "Couldn't open 'nameToUnicode' file '%s'",
1797 + name->getCString());
1798 + return;
1799 + }
1800 + line = 1;
1801 + while (getLine(buf, sizeof(buf), f)) {
1802 + tok1 = strtok(buf, " \t\r\n");
1803 + tok2 = strtok(NULL, " \t\r\n");
1804 + if (tok1 && tok2) {
1805 + sscanf(tok1, "%x", &u);
1806 + nameToUnicode->add(tok2, u);
1807 + } else {
1808 + error(-1, "Bad line in 'nameToUnicode' file (%s:%d)",
1809 + name->getCString(), line);
1810 + }
1811 + ++line;
1812 + }
1813 + fclose(f);
1814 +}
1815 +
1816 +void GlobalParamsGUI::parseCIDToUnicode(GooList *tokens, GooString *fileName,
1817 + int line) {
1818 + GooString *collection, *name, *old;
1819 +
1820 + if (tokens->getLength() != 3) {
1821 + error(-1, "Bad 'cidToUnicode' config file command (%s:%d)",
1822 + fileName->getCString(), line);
1823 + return;
1824 + }
1825 + collection = (GooString *)tokens->get(1);
1826 + name = (GooString *)tokens->get(2);
1827 + if ((old = (GooString *)cidToUnicodes->remove(collection))) {
1828 + delete old;
1829 + }
1830 + cidToUnicodes->add(collection->copy(), name->copy());
1831 +}
1832 +
1833 +void GlobalParamsGUI::parseUnicodeToUnicode(GooList *tokens, GooString *fileName,
1834 + int line) {
1835 + GooString *font, *file, *old;
1836 +
1837 + if (tokens->getLength() != 3) {
1838 + error(-1, "Bad 'unicodeToUnicode' config file command (%s:%d)",
1839 + fileName->getCString(), line);
1840 + return;
1841 + }
1842 + font = (GooString *)tokens->get(1);
1843 + file = (GooString *)tokens->get(2);
1844 + if ((old = (GooString *)unicodeToUnicodes->remove(font))) {
1845 + delete old;
1846 + }
1847 + unicodeToUnicodes->add(font->copy(), file->copy());
1848 +}
1849 +
1850 +void GlobalParamsGUI::parseUnicodeMap(GooList *tokens, GooString *fileName,
1851 + int line) {
1852 + GooString *encodingName, *name, *old;
1853 +
1854 + if (tokens->getLength() != 3) {
1855 + error(-1, "Bad 'unicodeMap' config file command (%s:%d)",
1856 + fileName->getCString(), line);
1857 + return;
1858 + }
1859 + encodingName = (GooString *)tokens->get(1);
1860 + name = (GooString *)tokens->get(2);
1861 + if ((old = (GooString *)unicodeMaps->remove(encodingName))) {
1862 + delete old;
1863 + }
1864 + unicodeMaps->add(encodingName->copy(), name->copy());
1865 +}
1866 +
1867 +void GlobalParamsGUI::parseCMapDir(GooList *tokens, GooString *fileName, int line) {
1868 + GooString *collection, *dir;
1869 + GooList *list;
1870 +
1871 + if (tokens->getLength() != 3) {
1872 + error(-1, "Bad 'cMapDir' config file command (%s:%d)",
1873 + fileName->getCString(), line);
1874 + return;
1875 + }
1876 + collection = (GooString *)tokens->get(1);
1877 + dir = (GooString *)tokens->get(2);
1878 + if (!(list = (GooList *)cMapDirs->lookup(collection))) {
1879 + list = new GooList();
1880 + cMapDirs->add(collection->copy(), list);
1881 + }
1882 + list->append(dir->copy());
1883 +}
1884 +
1885 +void GlobalParamsGUI::parseToUnicodeDir(GooList *tokens, GooString *fileName,
1886 + int line) {
1887 + if (tokens->getLength() != 2) {
1888 + error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
1889 + fileName->getCString(), line);
1890 + return;
1891 + }
1892 + toUnicodeDirs->append(((GooString *)tokens->get(1))->copy());
1893 +}
1894 +
1895 +void GlobalParamsGUI::parseDisplayFont(GooList *tokens, GooHash *fontHash,
1896 + DisplayFontParamKind kind,
1897 + GooString *fileName, int line) {
1898 + DisplayFontParam *param, *old;
1899 +
1900 + if (tokens->getLength() < 2) {
1901 + goto err1;
1902 + }
1903 + param = new DisplayFontParam(((GooString *)tokens->get(1))->copy(), kind);
1904 +
1905 + switch (kind) {
1906 + case displayFontT1:
1907 + if (tokens->getLength() != 3) {
1908 + goto err2;
1909 + }
1910 + param->t1.fileName = ((GooString *)tokens->get(2))->copy();
1911 + break;
1912 + case displayFontTT:
1913 + if (tokens->getLength() != 3) {
1914 + goto err2;
1915 + }
1916 + param->tt.fileName = ((GooString *)tokens->get(2))->copy();
1917 + break;
1918 + }
1919 +
1920 + if ((old = (DisplayFontParam *)fontHash->remove(param->name))) {
1921 + delete old;
1922 + }
1923 + fontHash->add(param->name, param);
1924 + return;
1925 +
1926 + err2:
1927 + delete param;
1928 + err1:
1929 + error(-1, "Bad 'display*Font*' config file command (%s:%d)",
1930 + fileName->getCString(), line);
1931 +}
1932 +
1933 +void GlobalParamsGUI::parsePSPaperSize(GooList *tokens, GooString *fileName,
1934 + int line) {
1935 + GooString *tok;
1936 +
1937 + if (tokens->getLength() == 2) {
1938 + tok = (GooString *)tokens->get(1);
1939 + if (!setPSPaperSize(tok->getCString())) {
1940 + error(-1, "Bad 'psPaperSize' config file command (%s:%d)",
1941 + fileName->getCString(), line);
1942 + }
1943 + } else if (tokens->getLength() == 3) {
1944 + tok = (GooString *)tokens->get(1);
1945 + psPaperWidth = atoi(tok->getCString());
1946 + tok = (GooString *)tokens->get(2);
1947 + psPaperHeight = atoi(tok->getCString());
1948 + psImageableLLX = psImageableLLY = 0;
1949 + psImageableURX = psPaperWidth;
1950 + psImageableURY = psPaperHeight;
1951 + } else {
1952 + error(-1, "Bad 'psPaperSize' config file command (%s:%d)",
1953 + fileName->getCString(), line);
1954 + }
1955 +}
1956 +
1957 +void GlobalParamsGUI::parsePSImageableArea(GooList *tokens, GooString *fileName,
1958 + int line) {
1959 + if (tokens->getLength() != 5) {
1960 + error(-1, "Bad 'psImageableArea' config file command (%s:%d)",
1961 + fileName->getCString(), line);
1962 + return;
1963 + }
1964 + psImageableLLX = atoi(((GooString *)tokens->get(1))->getCString());
1965 + psImageableLLY = atoi(((GooString *)tokens->get(2))->getCString());
1966 + psImageableURX = atoi(((GooString *)tokens->get(3))->getCString());
1967 + psImageableURY = atoi(((GooString *)tokens->get(4))->getCString());
1968 +}
1969 +
1970 +void GlobalParamsGUI::parsePSLevel(GooList *tokens, GooString *fileName, int line) {
1971 + GooString *tok;
1972 +
1973 + if (tokens->getLength() != 2) {
1974 + error(-1, "Bad 'psLevel' config file command (%s:%d)",
1975 + fileName->getCString(), line);
1976 + return;
1977 + }
1978 + tok = (GooString *)tokens->get(1);
1979 + if (!tok->cmp("level1")) {
1980 + psLevel = psLevel1;
1981 + } else if (!tok->cmp("level1sep")) {
1982 + psLevel = psLevel1Sep;
1983 + } else if (!tok->cmp("level2")) {
1984 + psLevel = psLevel2;
1985 + } else if (!tok->cmp("level2sep")) {
1986 + psLevel = psLevel2Sep;
1987 + } else if (!tok->cmp("level3")) {
1988 + psLevel = psLevel3;
1989 + } else if (!tok->cmp("level3Sep")) {
1990 + psLevel = psLevel3Sep;
1991 + } else {
1992 + error(-1, "Bad 'psLevel' config file command (%s:%d)",
1993 + fileName->getCString(), line);
1994 + }
1995 +}
1996 +
1997 +void GlobalParamsGUI::parsePSFile(GooList *tokens, GooString *fileName, int line) {
1998 + if (tokens->getLength() != 2) {
1999 + error(-1, "Bad 'psFile' config file command (%s:%d)",
2000 + fileName->getCString(), line);
2001 + return;
2002 + }
2003 + if (psFile) {
2004 + delete psFile;
2005 + }
2006 + psFile = ((GooString *)tokens->get(1))->copy();
2007 +}
2008 +
2009 +void GlobalParamsGUI::parsePSFont(GooList *tokens, GooString *fileName, int line) {
2010 + PSFontParam *param;
2011 +
2012 + if (tokens->getLength() != 3) {
2013 + error(-1, "Bad 'psFont' config file command (%s:%d)",
2014 + fileName->getCString(), line);
2015 + return;
2016 + }
2017 + param = new PSFontParam(((GooString *)tokens->get(1))->copy(), 0,
2018 + ((GooString *)tokens->get(2))->copy(), NULL);
2019 + psFonts->add(param->pdfFontName, param);
2020 +}
2021 +
2022 +void GlobalParamsGUI::parsePSFont16(char *cmdName, GooList *fontList,
2023 + GooList *tokens, GooString *fileName, int line) {
2024 + PSFontParam *param;
2025 + int wMode;
2026 + GooString *tok;
2027 +
2028 + if (tokens->getLength() != 5) {
2029 + error(-1, "Bad '%s' config file command (%s:%d)",
2030 + cmdName, fileName->getCString(), line);
2031 + return;
2032 + }
2033 + tok = (GooString *)tokens->get(2);
2034 + if (!tok->cmp("H")) {
2035 + wMode = 0;
2036 + } else if (!tok->cmp("V")) {
2037 + wMode = 1;
2038 + } else {
2039 + error(-1, "Bad '%s' config file command (%s:%d)",
2040 + cmdName, fileName->getCString(), line);
2041 + return;
2042 + }
2043 + param = new PSFontParam(((GooString *)tokens->get(1))->copy(),
2044 + wMode,
2045 + ((GooString *)tokens->get(3))->copy(),
2046 + ((GooString *)tokens->get(4))->copy());
2047 + fontList->append(param);
2048 +}
2049 +
2050 +void GlobalParamsGUI::parseTextEncoding(GooList *tokens, GooString *fileName,
2051 + int line) {
2052 + if (tokens->getLength() != 2) {
2053 + error(-1, "Bad 'textEncoding' config file command (%s:%d)",
2054 + fileName->getCString(), line);
2055 + return;
2056 + }
2057 + delete textEncoding;
2058 + textEncoding = ((GooString *)tokens->get(1))->copy();
2059 +}
2060 +
2061 +void GlobalParamsGUI::parseTextEOL(GooList *tokens, GooString *fileName, int line) {
2062 + GooString *tok;
2063 +
2064 + if (tokens->getLength() != 2) {
2065 + error(-1, "Bad 'textEOL' config file command (%s:%d)",
2066 + fileName->getCString(), line);
2067 + return;
2068 + }
2069 + tok = (GooString *)tokens->get(1);
2070 + if (!tok->cmp("unix")) {
2071 + textEOL = eolUnix;
2072 + } else if (!tok->cmp("dos")) {
2073 + textEOL = eolDOS;
2074 + } else if (!tok->cmp("mac")) {
2075 + textEOL = eolMac;
2076 + } else {
2077 + error(-1, "Bad 'textEOL' config file command (%s:%d)",
2078 + fileName->getCString(), line);
2079 + }
2080 +}
2081 +
2082 +void GlobalParamsGUI::parseFontDir(GooList *tokens, GooString *fileName, int line) {
2083 + if (tokens->getLength() != 2) {
2084 + error(-1, "Bad 'fontDir' config file command (%s:%d)",
2085 + fileName->getCString(), line);
2086 + return;
2087 + }
2088 + fontDirs->append(((GooString *)tokens->get(1))->copy());
2089 +}
2090 +
2091 +void GlobalParamsGUI::parseInitialZoom(GooList *tokens,
2092 + GooString *fileName, int line) {
2093 + if (tokens->getLength() != 2) {
2094 + error(-1, "Bad 'initialZoom' config file command (%s:%d)",
2095 + fileName->getCString(), line);
2096 + return;
2097 + }
2098 + delete initialZoom;
2099 + initialZoom = ((GooString *)tokens->get(1))->copy();
2100 +}
2101 +
2102 +void GlobalParamsGUI::parseScreenType(GooList *tokens, GooString *fileName,
2103 + int line) {
2104 + GooString *tok;
2105 +
2106 + if (tokens->getLength() != 2) {
2107 + error(-1, "Bad 'screenType' config file command (%s:%d)",
2108 + fileName->getCString(), line);
2109 + return;
2110 + }
2111 + tok = (GooString *)tokens->get(1);
2112 + if (!tok->cmp("dispersed")) {
2113 + screenType = screenDispersed;
2114 + } else if (!tok->cmp("clustered")) {
2115 + screenType = screenClustered;
2116 + } else if (!tok->cmp("stochasticClustered")) {
2117 + screenType = screenStochasticClustered;
2118 + } else {
2119 + error(-1, "Bad 'screenType' config file command (%s:%d)",
2120 + fileName->getCString(), line);
2121 + }
2122 +}
2123 +
2124 +void GlobalParamsGUI::parseBind(GooList *tokens, GooString *fileName, int line) {
2125 + KeyBinding *binding;
2126 + GooList *cmds;
2127 + int code, mods, context, i;
2128 +
2129 + if (tokens->getLength() < 4) {
2130 + error(-1, "Bad 'bind' config file command (%s:%d)",
2131 + fileName->getCString(), line);
2132 + return;
2133 + }
2134 + if (!parseKey((GooString *)tokens->get(1), (GooString *)tokens->get(2),
2135 + &code, &mods, &context,
2136 + "bind", tokens, fileName, line)) {
2137 + return;
2138 + }
2139 + for (i = 0; i < keyBindings->getLength(); ++i) {
2140 + binding = (KeyBinding *)keyBindings->get(i);
2141 + if (binding->code == code &&
2142 + binding->mods == mods &&
2143 + binding->context == context) {
2144 + delete (KeyBinding *)keyBindings->del(i);
2145 + break;
2146 + }
2147 + }
2148 + cmds = new GooList();
2149 + for (i = 3; i < tokens->getLength(); ++i) {
2150 + cmds->append(((GooString *)tokens->get(i))->copy());
2151 + }
2152 + keyBindings->append(new KeyBinding(code, mods, context, cmds));
2153 +}
2154 +
2155 +void GlobalParamsGUI::parseUnbind(GooList *tokens, GooString *fileName, int line) {
2156 + KeyBinding *binding;
2157 + int code, mods, context, i;
2158 +
2159 + if (tokens->getLength() != 3) {
2160 + error(-1, "Bad 'unbind' config file command (%s:%d)",
2161 + fileName->getCString(), line);
2162 + return;
2163 + }
2164 + if (!parseKey((GooString *)tokens->get(1), (GooString *)tokens->get(2),
2165 + &code, &mods, &context,
2166 + "unbind", tokens, fileName, line)) {
2167 + return;
2168 + }
2169 + for (i = 0; i < keyBindings->getLength(); ++i) {
2170 + binding = (KeyBinding *)keyBindings->get(i);
2171 + if (binding->code == code &&
2172 + binding->mods == mods &&
2173 + binding->context == context) {
2174 + delete (KeyBinding *)keyBindings->del(i);
2175 + break;
2176 + }
2177 + }
2178 +}
2179 +
2180 +GBool GlobalParamsGUI::parseKey(GooString *modKeyStr, GooString *contextStr,
2181 + int *code, int *mods, int *context,
2182 + char *cmdName,
2183 + GooList *tokens, GooString *fileName, int line) {
2184 + char *p0;
2185 +
2186 + *mods = xpdfKeyModNone;
2187 + p0 = modKeyStr->getCString();
2188 + while (1) {
2189 + if (!strncmp(p0, "shift-", 6)) {
2190 + *mods |= xpdfKeyModShift;
2191 + p0 += 6;
2192 + } else if (!strncmp(p0, "ctrl-", 5)) {
2193 + *mods |= xpdfKeyModCtrl;
2194 + p0 += 5;
2195 + } else if (!strncmp(p0, "alt-", 4)) {
2196 + *mods |= xpdfKeyModAlt;
2197 + p0 += 4;
2198 + } else {
2199 + break;
2200 + }
2201 + }
2202 +
2203 + if (!strcmp(p0, "space")) {
2204 + *code = ' ';
2205 + } else if (!strcmp(p0, "tab")) {
2206 + *code = xpdfKeyCodeTab;
2207 + } else if (!strcmp(p0, "return")) {
2208 + *code = xpdfKeyCodeReturn;
2209 + } else if (!strcmp(p0, "enter")) {
2210 + *code = xpdfKeyCodeEnter;
2211 + } else if (!strcmp(p0, "backspace")) {
2212 + *code = xpdfKeyCodeBackspace;
2213 + } else if (!strcmp(p0, "insert")) {
2214 + *code = xpdfKeyCodeInsert;
2215 + } else if (!strcmp(p0, "delete")) {
2216 + *code = xpdfKeyCodeDelete;
2217 + } else if (!strcmp(p0, "home")) {
2218 + *code = xpdfKeyCodeHome;
2219 + } else if (!strcmp(p0, "end")) {
2220 + *code = xpdfKeyCodeEnd;
2221 + } else if (!strcmp(p0, "pgup")) {
2222 + *code = xpdfKeyCodePgUp;
2223 + } else if (!strcmp(p0, "pgdn")) {
2224 + *code = xpdfKeyCodePgDn;
2225 + } else if (!strcmp(p0, "left")) {
2226 + *code = xpdfKeyCodeLeft;
2227 + } else if (!strcmp(p0, "right")) {
2228 + *code = xpdfKeyCodeRight;
2229 + } else if (!strcmp(p0, "up")) {
2230 + *code = xpdfKeyCodeUp;
2231 + } else if (!strcmp(p0, "down")) {
2232 + *code = xpdfKeyCodeDown;
2233 + } else if (p0[0] == 'f' && p0[1] >= '1' && p0[1] <= '9' && !p0[2]) {
2234 + *code = xpdfKeyCodeF1 + (p0[1] - '1');
2235 + } else if (p0[0] == 'f' &&
2236 + ((p0[1] >= '1' && p0[1] <= '2' && p0[2] >= '0' && p0[2] <= '9') ||
2237 + (p0[1] == '3' && p0[2] >= '0' && p0[2] <= '5')) &&
2238 + !p0[3]) {
2239 + *code = xpdfKeyCodeF1 + 10 * (p0[1] - '0') + (p0[2] - '0') - 1;
2240 + } else if (!strncmp(p0, "mousePress", 10) &&
2241 + p0[10] >= '1' && p0[10] <= '7' && !p0[11]) {
2242 + *code = xpdfKeyCodeMousePress1 + (p0[10] - '1');
2243 + } else if (!strncmp(p0, "mouseRelease", 12) &&
2244 + p0[12] >= '1' && p0[12] <= '7' && !p0[13]) {
2245 + *code = xpdfKeyCodeMouseRelease1 + (p0[12] - '1');
2246 + } else if (*p0 >= 0x20 && *p0 <= 0x7e && !p0[1]) {
2247 + *code = (int)*p0;
2248 + } else {
2249 + error(-1, "Bad key/modifier in '%s' config file command (%s:%d)",
2250 + cmdName, fileName->getCString(), line);
2251 + return gFalse;
2252 + }
2253 +
2254 + p0 = contextStr->getCString();
2255 + if (!strcmp(p0, "any")) {
2256 + *context = xpdfKeyContextAny;
2257 + } else {
2258 + *context = xpdfKeyContextAny;
2259 + while (1) {
2260 + if (!strncmp(p0, "fullScreen", 10)) {
2261 + *context |= xpdfKeyContextFullScreen;
2262 + p0 += 10;
2263 + } else if (!strncmp(p0, "window", 6)) {
2264 + *context |= xpdfKeyContextWindow;
2265 + p0 += 6;
2266 + } else if (!strncmp(p0, "continuous", 10)) {
2267 + *context |= xpdfKeyContextContinuous;
2268 + p0 += 10;
2269 + } else if (!strncmp(p0, "singlePage", 10)) {
2270 + *context |= xpdfKeyContextSinglePage;
2271 + p0 += 10;
2272 + } else if (!strncmp(p0, "overLink", 8)) {
2273 + *context |= xpdfKeyContextOverLink;
2274 + p0 += 8;
2275 + } else if (!strncmp(p0, "offLink", 7)) {
2276 + *context |= xpdfKeyContextOffLink;
2277 + p0 += 7;
2278 + } else if (!strncmp(p0, "outline", 7)) {
2279 + *context |= xpdfKeyContextOutline;
2280 + p0 += 7;
2281 + } else if (!strncmp(p0, "mainWin", 7)) {
2282 + *context |= xpdfKeyContextMainWin;
2283 + p0 += 7;
2284 + } else if (!strncmp(p0, "scrLockOn", 9)) {
2285 + *context |= xpdfKeyContextScrLockOn;
2286 + p0 += 9;
2287 + } else if (!strncmp(p0, "scrLockOff", 10)) {
2288 + *context |= xpdfKeyContextScrLockOff;
2289 + p0 += 10;
2290 + } else {
2291 + error(-1, "Bad context in '%s' config file command (%s:%d)",
2292 + cmdName, fileName->getCString(), line);
2293 + return gFalse;
2294 + }
2295 + if (!*p0) {
2296 + break;
2297 + }
2298 + if (*p0 != ',') {
2299 + error(-1, "Bad context in '%s' config file command (%s:%d)",
2300 + cmdName, fileName->getCString(), line);
2301 + return gFalse;
2302 + }
2303 + ++p0;
2304 + }
2305 + }
2306 +
2307 + return gTrue;
2308 +}
2309 +
2310 +void GlobalParamsGUI::parseCommand(char *cmdName, GooString **val,
2311 + GooList *tokens, GooString *fileName, int line) {
2312 + if (tokens->getLength() != 2) {
2313 + error(-1, "Bad '%s' config file command (%s:%d)",
2314 + cmdName, fileName->getCString(), line);
2315 + return;
2316 + }
2317 + if (*val) {
2318 + delete *val;
2319 + }
2320 + *val = ((GooString *)tokens->get(1))->copy();
2321 +}
2322 +
2323 +void GlobalParamsGUI::parseYesNo(char *cmdName, GBool *flag,
2324 + GooList *tokens, GooString *fileName, int line) {
2325 + GooString *tok;
2326 +
2327 + if (tokens->getLength() != 2) {
2328 + error(-1, "Bad '%s' config file command (%s:%d)",
2329 + cmdName, fileName->getCString(), line);
2330 + return;
2331 + }
2332 + tok = (GooString *)tokens->get(1);
2333 + if (!parseYesNo2(tok->getCString(), flag)) {
2334 + error(-1, "Bad '%s' config file command (%s:%d)",
2335 + cmdName, fileName->getCString(), line);
2336 + }
2337 +}
2338 +
2339 +GBool GlobalParamsGUI::parseYesNo2(char *token, GBool *flag) {
2340 + if (!strcmp(token, "yes")) {
2341 + *flag = gTrue;
2342 + } else if (!strcmp(token, "no")) {
2343 + *flag = gFalse;
2344 + } else {
2345 + return gFalse;
2346 + }
2347 + return gTrue;
2348 +}
2349 +
2350 +void GlobalParamsGUI::parseInteger(char *cmdName, int *val,
2351 + GooList *tokens, GooString *fileName, int line) {
2352 + GooString *tok;
2353 + int i;
2354 +
2355 + if (tokens->getLength() != 2) {
2356 + error(-1, "Bad '%s' config file command (%s:%d)",
2357 + cmdName, fileName->getCString(), line);
2358 + return;
2359 + }
2360 + tok = (GooString *)tokens->get(1);
2361 + if (tok->getLength() == 0) {
2362 + error(-1, "Bad '%s' config file command (%s:%d)",
2363 + cmdName, fileName->getCString(), line);
2364 + return;
2365 + }
2366 + if (tok->getChar(0) == '-') {
2367 + i = 1;
2368 + } else {
2369 + i = 0;
2370 + }
2371 + for (; i < tok->getLength(); ++i) {
2372 + if (tok->getChar(i) < '0' || tok->getChar(i) > '9') {
2373 + error(-1, "Bad '%s' config file command (%s:%d)",
2374 + cmdName, fileName->getCString(), line);
2375 + return;
2376 + }
2377 + }
2378 + *val = atoi(tok->getCString());
2379 +}
2380 +
2381 +void GlobalParamsGUI::parseFloat(char *cmdName, double *val,
2382 + GooList *tokens, GooString *fileName, int line) {
2383 + GooString *tok;
2384 + int i;
2385 +
2386 + if (tokens->getLength() != 2) {
2387 + error(-1, "Bad '%s' config file command (%s:%d)",
2388 + cmdName, fileName->getCString(), line);
2389 + return;
2390 + }
2391 + tok = (GooString *)tokens->get(1);
2392 + if (tok->getLength() == 0) {
2393 + error(-1, "Bad '%s' config file command (%s:%d)",
2394 + cmdName, fileName->getCString(), line);
2395 + return;
2396 + }
2397 + if (tok->getChar(0) == '-') {
2398 + i = 1;
2399 + } else {
2400 + i = 0;
2401 + }
2402 + for (; i < tok->getLength(); ++i) {
2403 + if (!((tok->getChar(i) >= '0' && tok->getChar(i) <= '9') ||
2404 + tok->getChar(i) == '.')) {
2405 + error(-1, "Bad '%s' config file command (%s:%d)",
2406 + cmdName, fileName->getCString(), line);
2407 + return;
2408 + }
2409 + }
2410 + *val = atof(tok->getCString());
2411 +}
2412 +
2413 +void GlobalParamsGUI::addCIDToUnicode(GooString *collection,
2414 + GooString *fileName) {
2415 + GooString *old;
2416 +
2417 + if ((old = (GooString *)cidToUnicodes->remove(collection))) {
2418 + delete old;
2419 + }
2420 + cidToUnicodes->add(collection->copy(), fileName->copy());
2421 +}
2422 +
2423 +void GlobalParamsGUI::addUnicodeMap(GooString *encodingName, GooString *fileName)
2424 +{
2425 + GooString *old;
2426 +
2427 + if ((old = (GooString *)unicodeMaps->remove(encodingName))) {
2428 + delete old;
2429 + }
2430 + unicodeMaps->add(encodingName->copy(), fileName->copy());
2431 +}
2432 +
2433 +void GlobalParamsGUI::addCMapDir(GooString *collection, GooString *dir) {
2434 + GooList *list;
2435 +
2436 + if (!(list = (GooList *)cMapDirs->lookup(collection))) {
2437 + list = new GooList();
2438 + cMapDirs->add(collection->copy(), list);
2439 + }
2440 + list->append(dir->copy());
2441 +}
2442 +
2443 +GlobalParamsGUI::~GlobalParamsGUI() {
2444 + GooHashIter *iter;
2445 + GooString *key;
2446 + GooList *list;
2447 +
2448 + freeBuiltinFontTables();
2449 +
2450 + delete macRomanReverseMap;
2451 +
2452 + delete baseDir;
2453 + delete nameToUnicode;
2454 + deleteGooHash(cidToUnicodes, GooString);
2455 + deleteGooHash(unicodeToUnicodes, GooString);
2456 + deleteGooHash(residentUnicodeMaps, UnicodeMap);
2457 + deleteGooHash(unicodeMaps, GooString);
2458 + deleteGooList(toUnicodeDirs, GooString);
2459 + deleteGooHash(displayFonts, DisplayFontParam);
2460 + deleteGooHash(displayCIDFonts, DisplayFontParam);
2461 + deleteGooHash(displayNamedCIDFonts, DisplayFontParam);
2462 +#ifdef WIN32
2463 + if (winFontList) {
2464 + delete winFontList;
2465 + }
2466 +#endif
2467 + if (psFile) {
2468 + delete psFile;
2469 + }
2470 + deleteGooHash(psFonts, PSFontParam);
2471 + deleteGooList(psNamedFonts16, PSFontParam);
2472 + deleteGooList(psFonts16, PSFontParam);
2473 + delete textEncoding;
2474 + deleteGooList(fontDirs, GooString);
2475 +
2476 + cMapDirs->startIter(&iter);
2477 + while (cMapDirs->getNext(&iter, &key, (void **)&list)) {
2478 + deleteGooList(list, GooString);
2479 + }
2480 + delete cMapDirs;
2481 +
2482 + delete cidToUnicodeCache;
2483 + delete unicodeToUnicodeCache;
2484 + delete unicodeMapCache;
2485 + delete cMapCache;
2486 +
2487 +#ifdef ENABLE_PLUGINS
2488 + delete securityHandlers;
2489 + deleteGooList(plugins, Plugin);
2490 +#endif
2491 +
2492 +#if MULTITHREADED
2493 + gDestroyMutex(&mutex);
2494 + gDestroyMutex(&unicodeMapCacheMutex);
2495 + gDestroyMutex(&cMapCacheMutex);
2496 +#endif
2497 +}
2498 +
2499 +//------------------------------------------------------------------------
2500 +
2501 +void GlobalParamsGUI::setBaseDir(char *dir) {
2502 + delete baseDir;
2503 + baseDir = new GooString(dir);
2504 +}
2505 +
2506 +void GlobalParamsGUI::setupBaseFonts(char *dir) {
2507 + GooString *fontName;
2508 + GooString *fileName;
2509 +#ifdef WIN32
2510 + HMODULE shell32Lib;
2511 + BOOL (__stdcall *SHGetSpecialFolderPathFunc)(HWND hwndOwner,
2512 + LPTSTR lpszPath,
2513 + int nFolder,
2514 + BOOL fCreate);
2515 + char winFontDir[MAX_PATH];
2516 +#endif
2517 + FILE *f;
2518 + DisplayFontParamKind kind;
2519 + DisplayFontParam *dfp;
2520 + int i, j;
2521 +
2522 +#ifdef WIN32
2523 + // SHGetSpecialFolderPath isn't available in older versions of
2524 + // shell32.dll (Win95 and WinNT4), so do a dynamic load
2525 + winFontDir[0] = '\0';
2526 + if ((shell32Lib = LoadLibrary("shell32.dll"))) {
2527 + if ((SHGetSpecialFolderPathFunc =
2528 + (BOOL (__stdcall *)(HWND hwndOwner, LPTSTR lpszPath,
2529 + int nFolder, BOOL fCreate))
2530 + GetProcAddress(shell32Lib, "SHGetSpecialFolderPathA"))) {
2531 + if (!(*SHGetSpecialFolderPathFunc)(NULL, winFontDir,
2532 + CSIDL_FONTS, FALSE)) {
2533 + winFontDir[0] = '\0';
2534 + }
2535 + }
2536 + }
2537 +#endif
2538 + for (i = 0; displayFontTab[i].name; ++i) {
2539 + fontName = new GooString(displayFontTab[i].name);
2540 + if (getDisplayFont(fontName)) {
2541 + delete fontName;
2542 + continue;
2543 + }
2544 + fileName = NULL;
2545 + kind = displayFontT1; // make gcc happy
2546 + if (dir) {
2547 + fileName = appendToPath(new GooString(dir), displayFontTab[i].t1FileName);
2548 + kind = displayFontT1;
2549 + if ((f = fopen(fileName->getCString(), "rb"))) {
2550 + fclose(f);
2551 + } else {
2552 + delete fileName;
2553 + fileName = NULL;
2554 + }
2555 + }
2556 +#ifdef WIN32
2557 + if (!fileName && winFontDir[0] && displayFontTab[i].ttFileName) {
2558 + fileName = appendToPath(new GooString(winFontDir),
2559 + displayFontTab[i].ttFileName);
2560 + kind = displayFontTT;
2561 + if ((f = fopen(fileName->getCString(), "rb"))) {
2562 + fclose(f);
2563 + } else {
2564 + delete fileName;
2565 + fileName = NULL;
2566 + }
2567 + }
2568 + // SHGetSpecialFolderPath(CSIDL_FONTS) doesn't work on Win 2k Server
2569 + // or Win2003 Server, or with older versions of shell32.dll, so check
2570 + // the "standard" directories
2571 + if (displayFontTab[i].ttFileName) {
2572 + for (j = 0; !fileName && displayFontDirs[j]; ++j) {
2573 + fileName = appendToPath(new GooString(displayFontDirs[j]),
2574 + displayFontTab[i].ttFileName);
2575 + kind = displayFontTT;
2576 + if ((f = fopen(fileName->getCString(), "rb"))) {
2577 + fclose(f);
2578 + } else {
2579 + delete fileName;
2580 + fileName = NULL;
2581 + }
2582 + }
2583 + }
2584 +#else
2585 + for (j = 0; !fileName && displayFontDirs[j]; ++j) {
2586 + fileName = appendToPath(new GooString(displayFontDirs[j]),
2587 + displayFontTab[i].t1FileName);
2588 + kind = displayFontT1;
2589 + if ((f = fopen(fileName->getCString(), "rb"))) {
2590 + fclose(f);
2591 + } else {
2592 + delete fileName;
2593 + fileName = NULL;
2594 + }
2595 + }
2596 +#endif
2597 + if (!fileName) {
2598 + error(-1, "No display font for '%s'", displayFontTab[i].name);
2599 + delete fontName;
2600 + continue;
2601 + }
2602 + dfp = new DisplayFontParam(fontName, kind);
2603 + dfp->t1.fileName = fileName;
2604 + globalParamsGUI->addDisplayFont(dfp);
2605 + }
2606 +
2607 +#ifdef WIN32
2608 + if (winFontDir[0]) {
2609 + winFontList = new WinFontList(winFontDir);
2610 + }
2611 +#endif
2612 +}
2613 +
2614 +//------------------------------------------------------------------------
2615 +// accessors
2616 +//------------------------------------------------------------------------
2617 +
2618 +CharCode GlobalParamsGUI::getMacRomanCharCode(char *charName) {
2619 + // no need to lock - macRomanReverseMap is constant
2620 + return macRomanReverseMap->lookup(charName);
2621 +}
2622 +
2623 +GooString *GlobalParamsGUI::getBaseDir() {
2624 + GooString *s;
2625 +
2626 + lockGlobalParamsGUI;
2627 + s = baseDir->copy();
2628 + unlockGlobalParamsGUI;
2629 + return s;
2630 +}
2631 +
2632 +Unicode GlobalParamsGUI::mapNameToUnicode(char *charName) {
2633 + // no need to lock - nameToUnicode is constant
2634 + return nameToUnicode->lookup(charName);
2635 +}
2636 +
2637 +UnicodeMap *GlobalParamsGUI::getResidentUnicodeMap(GooString *encodingName) {
2638 + UnicodeMap *map;
2639 +
2640 + lockGlobalParamsGUI;
2641 + map = (UnicodeMap *)residentUnicodeMaps->lookup(encodingName);
2642 + unlockGlobalParamsGUI;
2643 + if (map) {
2644 + map->incRefCnt();
2645 + }
2646 + return map;
2647 +}
2648 +
2649 +FILE *GlobalParamsGUI::getUnicodeMapFile(GooString *encodingName) {
2650 + GooString *fileName;
2651 + FILE *f;
2652 +
2653 + lockGlobalParamsGUI;
2654 + if ((fileName = (GooString *)unicodeMaps->lookup(encodingName))) {
2655 + f = fopen(fileName->getCString(), "r");
2656 + } else {
2657 + f = NULL;
2658 + }
2659 + unlockGlobalParamsGUI;
2660 + return f;
2661 +}
2662 +
2663 +FILE *GlobalParamsGUI::findCMapFile(GooString *collection, GooString *cMapName) {
2664 + GooList *list;
2665 + GooString *dir;
2666 + GooString *fileName;
2667 + FILE *f;
2668 + int i;
2669 +
2670 + lockGlobalParamsGUI;
2671 + if (!(list = (GooList *)cMapDirs->lookup(collection))) {
2672 + unlockGlobalParamsGUI;
2673 + return NULL;
2674 + }
2675 + for (i = 0; i < list->getLength(); ++i) {
2676 + dir = (GooString *)list->get(i);
2677 + fileName = appendToPath(dir->copy(), cMapName->getCString());
2678 + f = fopen(fileName->getCString(), "r");
2679 + delete fileName;
2680 + if (f) {
2681 + unlockGlobalParamsGUI;
2682 + return f;
2683 + }
2684 + }
2685 + unlockGlobalParamsGUI;
2686 + return NULL;
2687 +}
2688 +
2689 +FILE *GlobalParamsGUI::findToUnicodeFile(GooString *name) {
2690 + GooString *dir, *fileName;
2691 + FILE *f;
2692 + int i;
2693 +
2694 + lockGlobalParamsGUI;
2695 + for (i = 0; i < toUnicodeDirs->getLength(); ++i) {
2696 + dir = (GooString *)toUnicodeDirs->get(i);
2697 + fileName = appendToPath(dir->copy(), name->getCString());
2698 + f = fopen(fileName->getCString(), "r");
2699 + delete fileName;
2700 + if (f) {
2701 + unlockGlobalParamsGUI;
2702 + return f;
2703 + }
2704 + }
2705 + unlockGlobalParamsGUI;
2706 + return NULL;
2707 +}
2708 +
2709 +GBool findModifier(const char *name, const char *modifier, const char **start)
2710 +{
2711 + const char *match;
2712 +
2713 + if (name == NULL)
2714 + return gFalse;
2715 +
2716 + match = strstr(name, modifier);
2717 + if (match) {
2718 + if (*start == NULL || match < *start)
2719 + *start = match;
2720 + return gTrue;
2721 + }
2722 + else {
2723 + return gFalse;
2724 + }
2725 +}
2726 +
2727 +static FcPattern *buildFcPattern(GfxFont *font)
2728 +{
2729 + int weight = FC_WEIGHT_NORMAL,
2730 + slant = FC_SLANT_ROMAN,
2731 + width = FC_WIDTH_NORMAL,
2732 + spacing = FC_PROPORTIONAL;
2733 + bool deleteFamily = false;
2734 + char *family, *name, *lang, *modifiers;
2735 + const char *start;
2736 + FcPattern *p;
2737 +
2738 + // this is all heuristics will be overwritten if font had proper info
2739 + name = font->getName()->getCString();
2740 +
2741 + modifiers = strchr (name, ',');
2742 + if (modifiers == NULL)
2743 + modifiers = strchr (name, '-');
2744 +
2745 + // remove the - from the names, for some reason, Fontconfig does not
2746 + // understand "MS-Mincho" but does with "MS Mincho"
2747 + int len = strlen(name);
2748 + for (int i = 0; i < len; i++)
2749 + name[i] = (name[i] == '-' ? ' ' : name[i]);
2750 +
2751 + start = NULL;
2752 + findModifier(modifiers, "Regular", &start);
2753 + findModifier(modifiers, "Roman", &start);
2754 +
2755 + if (findModifier(modifiers, "Oblique", &start))
2756 + slant = FC_SLANT_OBLIQUE;
2757 + if (findModifier(modifiers, "Italic", &start))
2758 + slant = FC_SLANT_ITALIC;
2759 + if (findModifier(modifiers, "Bold", &start))
2760 + weight = FC_WEIGHT_BOLD;
2761 + if (findModifier(modifiers, "Light", &start))
2762 + weight = FC_WEIGHT_LIGHT;
2763 + if (findModifier(modifiers, "Condensed", &start))
2764 + width = FC_WIDTH_CONDENSED;
2765 +
2766 + if (start) {
2767 + // There have been "modifiers" in the name, crop them to obtain
2768 + // the family name
2769 + family = new char[len+1];
2770 + strcpy(family, name);
2771 + int pos = (modifiers - name);
2772 + family[pos] = '\0';
2773 + deleteFamily = true;
2774 + }
2775 + else {
2776 + family = name;
2777 + }
2778 +
2779 + // use font flags
2780 + if (font->isFixedWidth())
2781 + spacing = FC_MONO;
2782 + if (font->isBold())
2783 + weight = FC_WEIGHT_BOLD;
2784 + if (font->isItalic())
2785 + slant = FC_SLANT_ITALIC;
2786 +
2787 + // if the FontDescriptor specified a family name use it
2788 + if (font->getFamily()) {
2789 + if (deleteFamily) {
2790 + delete[] family;
2791 + deleteFamily = false;
2792 + }
2793 + family = font->getFamily()->getCString();
2794 + }
2795 +
2796 + // if the FontDescriptor specified a weight use it
2797 + switch (font -> getWeight())
2798 + {
2799 + case GfxFont::W100: weight = FC_WEIGHT_EXTRALIGHT; break;
2800 + case GfxFont::W200: weight = FC_WEIGHT_LIGHT; break;
2801 + case GfxFont::W300: weight = FC_WEIGHT_BOOK; break;
2802 + case GfxFont::W400: weight = FC_WEIGHT_NORMAL; break;
2803 + case GfxFont::W500: weight = FC_WEIGHT_MEDIUM; break;
2804 + case GfxFont::W600: weight = FC_WEIGHT_DEMIBOLD; break;
2805 + case GfxFont::W700: weight = FC_WEIGHT_BOLD; break;
2806 + case GfxFont::W800: weight = FC_WEIGHT_EXTRABOLD; break;
2807 + case GfxFont::W900: weight = FC_WEIGHT_BLACK; break;
2808 + default: break;
2809 + }
2810 +
2811 + // if the FontDescriptor specified a width use it
2812 + switch (font -> getStretch())
2813 + {
2814 + case GfxFont::UltraCondensed: width = FC_WIDTH_ULTRACONDENSED; break;
2815 + case GfxFont::ExtraCondensed: width = FC_WIDTH_EXTRACONDENSED; break;
2816 + case GfxFont::Condensed: width = FC_WIDTH_CONDENSED; break;
2817 + case GfxFont::SemiCondensed: width = FC_WIDTH_SEMICONDENSED; break;
2818 + case GfxFont::Normal: width = FC_WIDTH_NORMAL; break;
2819 + case GfxFont::SemiExpanded: width = FC_WIDTH_SEMIEXPANDED; break;
2820 + case GfxFont::Expanded: width = FC_WIDTH_EXPANDED; break;
2821 + case GfxFont::ExtraExpanded: width = FC_WIDTH_EXTRAEXPANDED; break;
2822 + case GfxFont::UltraExpanded: width = FC_WIDTH_ULTRAEXPANDED; break;
2823 + default: break;
2824 + }
2825 +
2826 + // find the language we want the font to support
2827 + if (font->isCIDFont())
2828 + {
2829 + GooString *collection = ((GfxCIDFont *)font)->getCollection();
2830 + if (collection)
2831 + {
2832 + if (strcmp(collection->getCString(), "Adobe-GB1") == 0)
2833 + lang = "zh-cn"; // Simplified Chinese
2834 + else if (strcmp(collection->getCString(), "Adobe-CNS1") == 0)
2835 + lang = "zh-tw"; // Traditional Chinese
2836 + else if (strcmp(collection->getCString(), "Adobe-Japan1") == 0)
2837 + lang = "ja"; // Japanese
2838 + else if (strcmp(collection->getCString(), "Adobe-Japan2") == 0)
2839 + lang = "ja"; // Japanese
2840 + else if (strcmp(collection->getCString(), "Adobe-Korea1") == 0)
2841 + lang = "ko"; // Korean
2842 + else if (strcmp(collection->getCString(), "Adobe-UCS") == 0)
2843 + lang = "xx";
2844 + else if (strcmp(collection->getCString(), "Adobe-Identity") == 0)
2845 + lang = "xx";
2846 + else
2847 + {
2848 + error(-1, "Unknown CID font collection, please report to poppler bugzilla.");
2849 + lang = "xx";
2850 + }
2851 + }
2852 + else lang = "xx";
2853 + }
2854 + else lang = "xx";
2855 +
2856 + p = FcPatternBuild(NULL,
2857 + FC_FAMILY, FcTypeString, family,
2858 + FC_SLANT, FcTypeInteger, slant,
2859 + FC_WEIGHT, FcTypeInteger, weight,
2860 + FC_WIDTH, FcTypeInteger, width,
2861 + FC_SPACING, FcTypeInteger, spacing,
2862 + FC_LANG, FcTypeString, lang,
2863 + NULL);
2864 + if (deleteFamily)
2865 + delete[] family;
2866 + return p;
2867 +}
2868 +
2869 +DisplayFontParam *GlobalParamsGUI::getDisplayFont(GfxFont *font) {
2870 + DisplayFontParam *dfp;
2871 + FcPattern *p=0;
2872 +
2873 + GooString *fontName = font->getName();
2874 + if (!fontName) return NULL;
2875 +
2876 + lockGlobalParamsGUI;
2877 + dfp = font->dfp;
2878 + if (!dfp)
2879 + {
2880 + FcChar8* s;
2881 + char * ext;
2882 + FcResult res;
2883 + FcFontSet *set;
2884 + int i;
2885 + p = buildFcPattern(font);
2886 +
2887 + if (!p)
2888 + goto fin;
2889 + FcConfigSubstitute(FCcfg, p, FcMatchPattern);
2890 + FcDefaultSubstitute(p);
2891 + set = FcFontSort(FCcfg, p, FcFalse, NULL, &res);
2892 + if (!set)
2893 + goto fin;
2894 + for (i = 0; i < set->nfont; ++i)
2895 + {
2896 + res = FcPatternGetString(set->fonts[i], FC_FILE, 0, &s);
2897 + if (res != FcResultMatch || !s)
2898 + continue;
2899 + ext = strrchr((char*)s,'.');
2900 + if (!ext)
2901 + continue;
2902 + if (!strncasecmp(ext,".ttf",4) || !strncasecmp(ext, ".ttc", 4))
2903 + {
2904 + dfp = new DisplayFontParam(fontName->copy(), displayFontTT);
2905 + dfp->tt.fileName = new GooString((char*)s);
2906 + FcPatternGetInteger(set->fonts[i], FC_INDEX, 0, &(dfp->tt.faceIndex));
2907 + }
2908 + else if (!strncasecmp(ext,".pfa",4) || !strncasecmp(ext,".pfb",4))
2909 + {
2910 + dfp = new DisplayFontParam(fontName->copy(), displayFontT1);
2911 + dfp->t1.fileName = new GooString((char*)s);
2912 + }
2913 + else
2914 + continue;
2915 + font->dfp = dfp;
2916 + break;
2917 + }
2918 + FcFontSetDestroy(set);
2919 + }
2920 +fin:
2921 + if (p)
2922 + FcPatternDestroy(p);
2923 +
2924 + unlockGlobalParamsGUI;
2925 + return dfp;
2926 +}
2927 +
2928 +DisplayFontParam *GlobalParamsGUI::getDisplayFont(GooString *fontName) {
2929 + DisplayFontParam *dfp;
2930 +
2931 + lockGlobalParamsGUI;
2932 + dfp = (DisplayFontParam *)displayFonts->lookup(fontName);
2933 +#ifdef WIN32
2934 + if (!dfp && winFontList) {
2935 + dfp = winFontList->find(fontName);
2936 + }
2937 +#endif
2938 + unlockGlobalParamsGUI;
2939 + return dfp;
2940 +}
2941 +
2942 +DisplayFontParam *GlobalParamsGUI::getDisplayCIDFont(GooString *fontName,
2943 + GooString *collection) {
2944 + DisplayFontParam *dfp;
2945 +
2946 + lockGlobalParamsGUI;
2947 + if (!fontName ||
2948 + !(dfp = (DisplayFontParam *)displayNamedCIDFonts->lookup(fontName))) {
2949 + dfp = (DisplayFontParam *)displayCIDFonts->lookup(collection);
2950 + }
2951 + unlockGlobalParamsGUI;
2952 + return dfp;
2953 +}
2954 +
2955 +GooString *GlobalParamsGUI::getPSFile() {
2956 + GooString *s;
2957 +
2958 + lockGlobalParamsGUI;
2959 + s = psFile ? psFile->copy() : (GooString *)NULL;
2960 + unlockGlobalParamsGUI;
2961 + return s;
2962 +}
2963 +
2964 +int GlobalParamsGUI::getPSPaperWidth() {
2965 + int w;
2966 +
2967 + lockGlobalParamsGUI;
2968 + w = psPaperWidth;
2969 + unlockGlobalParamsGUI;
2970 + return w;
2971 +}
2972 +
2973 +int GlobalParamsGUI::getPSPaperHeight() {
2974 + int h;
2975 +
2976 + lockGlobalParamsGUI;
2977 + h = psPaperHeight;
2978 + unlockGlobalParamsGUI;
2979 + return h;
2980 +}
2981 +
2982 +void GlobalParamsGUI::getPSImageableArea(int *llx, int *lly, int *urx, int *ury) {
2983 + lockGlobalParamsGUI;
2984 + *llx = psImageableLLX;
2985 + *lly = psImageableLLY;
2986 + *urx = psImageableURX;
2987 + *ury = psImageableURY;
2988 + unlockGlobalParamsGUI;
2989 +}
2990 +
2991 +GBool GlobalParamsGUI::getPSCrop() {
2992 + GBool f;
2993 +
2994 + lockGlobalParamsGUI;
2995 + f = psCrop;
2996 + unlockGlobalParamsGUI;
2997 + return f;
2998 +}
2999 +
3000 +GBool GlobalParamsGUI::getPSExpandSmaller() {
3001 + GBool f;
3002 +
3003 + lockGlobalParamsGUI;
3004 + f = psExpandSmaller;
3005 + unlockGlobalParamsGUI;
3006 + return f;
3007 +}
3008 +
3009 +GBool GlobalParamsGUI::getPSShrinkLarger() {
3010 + GBool f;
3011 +
3012 + lockGlobalParamsGUI;
3013 + f = psShrinkLarger;
3014 + unlockGlobalParamsGUI;
3015 + return f;
3016 +}
3017 +
3018 +GBool GlobalParamsGUI::getPSCenter() {
3019 + GBool f;
3020 +
3021 + lockGlobalParamsGUI;
3022 + f = psCenter;
3023 + unlockGlobalParamsGUI;
3024 + return f;
3025 +}
3026 +
3027 +GBool GlobalParamsGUI::getPSDuplex() {
3028 + GBool d;
3029 +
3030 + lockGlobalParamsGUI;
3031 + d = psDuplex;
3032 + unlockGlobalParamsGUI;
3033 + return d;
3034 +}
3035 +
3036 +PSLevel GlobalParamsGUI::getPSLevel() {
3037 + PSLevel level;
3038 +
3039 + lockGlobalParamsGUI;
3040 + level = psLevel;
3041 + unlockGlobalParamsGUI;
3042 + return level;
3043 +}
3044 +
3045 +PSFontParam *GlobalParamsGUI::getPSFont(GooString *fontName) {
3046 + PSFontParam *p;
3047 +
3048 + lockGlobalParamsGUI;
3049 + p = (PSFontParam *)psFonts->lookup(fontName);
3050 + unlockGlobalParamsGUI;
3051 + return p;
3052 +}
3053 +
3054 +PSFontParam *GlobalParamsGUI::getPSFont16(GooString *fontName,
3055 + GooString *collection, int wMode) {
3056 + PSFontParam *p;
3057 + int i;
3058 +
3059 + lockGlobalParamsGUI;
3060 + p = NULL;
3061 + if (fontName) {
3062 + for (i = 0; i < psNamedFonts16->getLength(); ++i) {
3063 + p = (PSFontParam *)psNamedFonts16->get(i);
3064 + if (!p->pdfFontName->cmp(fontName) &&
3065 + p->wMode == wMode) {
3066 + break;
3067 + }
3068 + p = NULL;
3069 + }
3070 + }
3071 + if (!p && collection) {
3072 + for (i = 0; i < psFonts16->getLength(); ++i) {
3073 + p = (PSFontParam *)psFonts16->get(i);
3074 + if (!p->pdfFontName->cmp(collection) &&
3075 + p->wMode == wMode) {
3076 + break;
3077 + }
3078 + p = NULL;
3079 + }
3080 + }
3081 + unlockGlobalParamsGUI;
3082 + return p;
3083 +}
3084 +
3085 +GBool GlobalParamsGUI::getPSEmbedType1() {
3086 + GBool e;
3087 +
3088 + lockGlobalParamsGUI;
3089 + e = psEmbedType1;
3090 + unlockGlobalParamsGUI;
3091 + return e;
3092 +}
3093 +
3094 +GBool GlobalParamsGUI::getPSEmbedTrueType() {
3095 + GBool e;
3096 +
3097 + lockGlobalParamsGUI;
3098 + e = psEmbedTrueType;
3099 + unlockGlobalParamsGUI;
3100 + return e;
3101 +}
3102 +
3103 +GBool GlobalParamsGUI::getPSEmbedCIDPostScript() {
3104 + GBool e;
3105 +
3106 + lockGlobalParamsGUI;
3107 + e = psEmbedCIDPostScript;
3108 + unlockGlobalParamsGUI;
3109 + return e;
3110 +}
3111 +
3112 +GBool GlobalParamsGUI::getPSEmbedCIDTrueType() {
3113 + GBool e;
3114 +
3115 + lockGlobalParamsGUI;
3116 + e = psEmbedCIDTrueType;
3117 + unlockGlobalParamsGUI;
3118 + return e;
3119 +}
3120 +
3121 +GBool GlobalParamsGUI::getPSPreload() {
3122 + GBool preload;
3123 +
3124 + lockGlobalParamsGUI;
3125 + preload = psPreload;
3126 + unlockGlobalParamsGUI;
3127 + return preload;
3128 +}
3129 +
3130 +GBool GlobalParamsGUI::getPSOPI() {
3131 + GBool opi;
3132 +
3133 + lockGlobalParamsGUI;
3134 + opi = psOPI;
3135 + unlockGlobalParamsGUI;
3136 + return opi;
3137 +}
3138 +
3139 +GBool GlobalParamsGUI::getPSASCIIHex() {
3140 + GBool ah;
3141 +
3142 + lockGlobalParamsGUI;
3143 + ah = psASCIIHex;
3144 + unlockGlobalParamsGUI;
3145 + return ah;
3146 +}
3147 +
3148 +GooString *GlobalParamsGUI::getTextEncodingName() {
3149 + GooString *s;
3150 +
3151 + lockGlobalParamsGUI;
3152 + s = textEncoding->copy();
3153 + unlockGlobalParamsGUI;
3154 + return s;
3155 +}
3156 +
3157 +EndOfLineKind GlobalParamsGUI::getTextEOL() {
3158 + EndOfLineKind eol;
3159 +
3160 + lockGlobalParamsGUI;
3161 + eol = textEOL;
3162 + unlockGlobalParamsGUI;
3163 + return eol;
3164 +}
3165 +
3166 +GBool GlobalParamsGUI::getTextPageBreaks() {
3167 + GBool pageBreaks;
3168 +
3169 + lockGlobalParamsGUI;
3170 + pageBreaks = textPageBreaks;
3171 + unlockGlobalParamsGUI;
3172 + return pageBreaks;
3173 +}
3174 +
3175 +GBool GlobalParamsGUI::getTextKeepTinyChars() {
3176 + GBool tiny;
3177 +
3178 + lockGlobalParamsGUI;
3179 + tiny = textKeepTinyChars;
3180 + unlockGlobalParamsGUI;
3181 + return tiny;
3182 +}
3183 +
3184 +GooString *GlobalParamsGUI::findFontFile(GooString *fontName, char **exts) {
3185 + GooString *dir, *fileName;
3186 + char **ext;
3187 + FILE *f;
3188 + int i;
3189 +
3190 + lockGlobalParamsGUI;
3191 + for (i = 0; i < fontDirs->getLength(); ++i) {
3192 + dir = (GooString *)fontDirs->get(i);
3193 + for (ext = exts; *ext; ++ext) {
3194 + fileName = appendToPath(dir->copy(), fontName->getCString());
3195 + fileName->append(*ext);
3196 + if ((f = fopen(fileName->getCString(), "rb"))) {
3197 + fclose(f);
3198 + unlockGlobalParamsGUI;
3199 + return fileName;
3200 + }
3201 + delete fileName;
3202 + }
3203 + }
3204 + unlockGlobalParamsGUI;
3205 + return NULL;
3206 +}
3207 +
3208 +GooString *GlobalParamsGUI::getInitialZoom() {
3209 + GooString *s;
3210 +
3211 + lockGlobalParamsGUI;
3212 + s = initialZoom->copy();
3213 + unlockGlobalParamsGUI;
3214 + return s;
3215 +}
3216 +
3217 +GBool GlobalParamsGUI::getContinuousView() {
3218 + GBool f;
3219 +
3220 + lockGlobalParamsGUI;
3221 + f = continuousView;
3222 + unlockGlobalParamsGUI;
3223 + return f;
3224 +}
3225 +
3226 +GBool GlobalParamsGUI::getEnableT1lib() {
3227 + GBool f;
3228 +
3229 + lockGlobalParamsGUI;
3230 + f = enableT1lib;
3231 + unlockGlobalParamsGUI;
3232 + return f;
3233 +}
3234 +
3235 +GBool GlobalParamsGUI::getEnableFreeType() {
3236 + GBool f;
3237 +
3238 + lockGlobalParamsGUI;
3239 + f = enableFreeType;
3240 + unlockGlobalParamsGUI;
3241 + return f;
3242 +}
3243 +
3244 +
3245 +GBool GlobalParamsGUI::getAntialias() {
3246 + GBool f;
3247 +
3248 + lockGlobalParamsGUI;
3249 + f = antialias;
3250 + unlockGlobalParamsGUI;
3251 + return f;
3252 +}
3253 +
3254 +GBool GlobalParamsGUI::getVectorAntialias() {
3255 + GBool f;
3256 +
3257 + lockGlobalParamsGUI;
3258 + f = vectorAntialias;
3259 + unlockGlobalParamsGUI;
3260 + return f;
3261 +}
3262 +
3263 +GBool GlobalParamsGUI::getStrokeAdjust() {
3264 + GBool f;
3265 +
3266 + lockGlobalParamsGUI;
3267 + f = strokeAdjust;
3268 + unlockGlobalParamsGUI;
3269 + return f;
3270 +}
3271 +
3272 +ScreenType GlobalParamsGUI::getScreenType() {
3273 + ScreenType t;
3274 +
3275 + lockGlobalParamsGUI;
3276 + t = screenType;
3277 + unlockGlobalParamsGUI;
3278 + return t;
3279 +}
3280 +
3281 +int GlobalParamsGUI::getScreenSize() {
3282 + int size;
3283 +
3284 + lockGlobalParamsGUI;
3285 + size = screenSize;
3286 + unlockGlobalParamsGUI;
3287 + return size;
3288 +}
3289 +
3290 +int GlobalParamsGUI::getScreenDotRadius() {
3291 + int r;
3292 +
3293 + lockGlobalParamsGUI;
3294 + r = screenDotRadius;
3295 + unlockGlobalParamsGUI;
3296 + return r;
3297 +}
3298 +
3299 +double GlobalParamsGUI::getScreenGamma() {
3300 + double gamma;
3301 +
3302 + lockGlobalParamsGUI;
3303 + gamma = screenGamma;
3304 + unlockGlobalParamsGUI;
3305 + return gamma;
3306 +}
3307 +
3308 +double GlobalParamsGUI::getScreenBlackThreshold() {
3309 + double thresh;
3310 +
3311 + lockGlobalParamsGUI;
3312 + thresh = screenBlackThreshold;
3313 + unlockGlobalParamsGUI;
3314 + return thresh;
3315 +}
3316 +
3317 +double GlobalParamsGUI::getScreenWhiteThreshold() {
3318 + double thresh;
3319 +
3320 + lockGlobalParamsGUI;
3321 + thresh = screenWhiteThreshold;
3322 + unlockGlobalParamsGUI;
3323 + return thresh;
3324 +}
3325 +
3326 +GBool GlobalParamsGUI::getMapNumericCharNames() {
3327 + GBool map;
3328 +
3329 + lockGlobalParamsGUI;
3330 + map = mapNumericCharNames;
3331 + unlockGlobalParamsGUI;
3332 + return map;
3333 +}
3334 +
3335 +GBool GlobalParamsGUI::getMapUnknownCharNames() {
3336 + GBool map;
3337 +
3338 + lockGlobalParamsGUI;
3339 + map = mapUnknownCharNames;
3340 + unlockGlobalParamsGUI;
3341 + return map;
3342 +}
3343 +
3344 +GooList *GlobalParamsGUI::getKeyBinding(int code, int mods, int context) {
3345 + KeyBinding *binding;
3346 + GooList *cmds;
3347 + int modMask;
3348 + int i, j;
3349 +
3350 + lockGlobalParamsGUI;
3351 + cmds = NULL;
3352 + // for ASCII chars, ignore the shift modifier
3353 + modMask = code <= 0xff ? ~xpdfKeyModShift : ~0;
3354 + for (i = 0; i < keyBindings->getLength(); ++i) {
3355 + binding = (KeyBinding *)keyBindings->get(i);
3356 + if (binding->code == code &&
3357 + (binding->mods & modMask) == (mods & modMask) &&
3358 + (~binding->context | context) == ~0) {
3359 + cmds = new GooList();
3360 + for (j = 0; j < binding->cmds->getLength(); ++j) {
3361 + cmds->append(((GooString *)binding->cmds->get(j))->copy());
3362 + }
3363 + break;
3364 + }
3365 + }
3366 + unlockGlobalParamsGUI;
3367 + return cmds;
3368 +}
3369 +
3370 +GBool GlobalParamsGUI::getPrintCommands() {
3371 + GBool p;
3372 +
3373 + lockGlobalParamsGUI;
3374 + p = printCommands;
3375 + unlockGlobalParamsGUI;
3376 + return p;
3377 +}
3378 +
3379 +GBool GlobalParamsGUI::getProfileCommands() {
3380 + GBool p;
3381 +
3382 + lockGlobalParamsGUI;
3383 + p = profileCommands;
3384 + unlockGlobalParamsGUI;
3385 + return p;
3386 +}
3387 +
3388 +GBool GlobalParamsGUI::getErrQuiet() {
3389 + // no locking -- this function may get called from inside a locked
3390 + // section
3391 + return errQuiet;
3392 +}
3393 +
3394 +CharCodeToUnicode *GlobalParamsGUI::getCIDToUnicode(GooString *collection) {
3395 + GooString *fileName;
3396 + CharCodeToUnicode *ctu;
3397 +
3398 + lockGlobalParamsGUI;
3399 + if (!(ctu = cidToUnicodeCache->getCharCodeToUnicode(collection))) {
3400 + if ((fileName = (GooString *)cidToUnicodes->lookup(collection)) &&
3401 + (ctu = CharCodeToUnicode::parseCIDToUnicode(fileName, collection))) {
3402 + cidToUnicodeCache->add(ctu);
3403 + }
3404 + }
3405 + unlockGlobalParamsGUI;
3406 + return ctu;
3407 +}
3408 +
3409 +CharCodeToUnicode *GlobalParamsGUI::getUnicodeToUnicode(GooString *fontName) {
3410 + CharCodeToUnicode *ctu;
3411 + GooHashIter *iter;
3412 + GooString *fontPattern, *fileName;
3413 +
3414 + lockGlobalParamsGUI;
3415 + fileName = NULL;
3416 + unicodeToUnicodes->startIter(&iter);
3417 + while (unicodeToUnicodes->getNext(&iter, &fontPattern, (void **)&fileName)) {
3418 + if (strstr(fontName->getCString(), fontPattern->getCString())) {
3419 + unicodeToUnicodes->killIter(&iter);
3420 + break;
3421 + }
3422 + fileName = NULL;
3423 + }
3424 + if (fileName) {
3425 + if (!(ctu = unicodeToUnicodeCache->getCharCodeToUnicode(fileName))) {
3426 + if ((ctu = CharCodeToUnicode::parseUnicodeToUnicode(fileName))) {
3427 + unicodeToUnicodeCache->add(ctu);
3428 + }
3429 + }
3430 + } else {
3431 + ctu = NULL;
3432 + }
3433 + unlockGlobalParamsGUI;
3434 + return ctu;
3435 +}
3436 +
3437 +UnicodeMap *GlobalParamsGUI::getUnicodeMap(GooString *encodingName) {
3438 + return getUnicodeMap2(encodingName);
3439 +}
3440 +
3441 +UnicodeMap *GlobalParamsGUI::getUnicodeMap2(GooString *encodingName) {
3442 + UnicodeMap *map;
3443 +
3444 + if (!(map = getResidentUnicodeMap(encodingName))) {
3445 + lockUnicodeMapCache;
3446 + map = unicodeMapCache->getUnicodeMap(encodingName);
3447 + unlockUnicodeMapCache;
3448 + }
3449 + return map;
3450 +}
3451 +
3452 +CMap *GlobalParamsGUI::getCMap(GooString *collection, GooString *cMapName) {
3453 + CMap *cMap;
3454 +
3455 + lockCMapCache;
3456 + cMap = cMapCache->getCMap(collection, cMapName);
3457 + unlockCMapCache;
3458 + return cMap;
3459 +}
3460 +
3461 +UnicodeMap *GlobalParamsGUI::getTextEncoding() {
3462 + return getUnicodeMap2(textEncoding);
3463 +}
3464 +
3465 +//------------------------------------------------------------------------
3466 +// functions to set parameters
3467 +//------------------------------------------------------------------------
3468 +
3469 +void GlobalParamsGUI::addDisplayFont(DisplayFontParam *param) {
3470 + DisplayFontParam *old;
3471 +
3472 + lockGlobalParamsGUI;
3473 + if ((old = (DisplayFontParam *)displayFonts->remove(param->name))) {
3474 + delete old;
3475 + }
3476 + displayFonts->add(param->name, param);
3477 + unlockGlobalParamsGUI;
3478 +}
3479 +
3480 +void GlobalParamsGUI::setPSFile(char *file) {
3481 + lockGlobalParamsGUI;
3482 + if (psFile) {
3483 + delete psFile;
3484 + }
3485 + psFile = new GooString(file);
3486 + unlockGlobalParamsGUI;
3487 +}
3488 +
3489 +GBool GlobalParamsGUI::setPSPaperSize(char *size) {
3490 + lockGlobalParamsGUI;
3491 + if (!strcmp(size, "match")) {
3492 + psPaperWidth = psPaperHeight = -1;
3493 + } else if (!strcmp(size, "letter")) {
3494 + psPaperWidth = 612;
3495 + psPaperHeight = 792;
3496 + } else if (!strcmp(size, "legal")) {
3497 + psPaperWidth = 612;
3498 + psPaperHeight = 1008;
3499 + } else if (!strcmp(size, "A4")) {
3500 + psPaperWidth = 595;
3501 + psPaperHeight = 842;
3502 + } else if (!strcmp(size, "A3")) {
3503 + psPaperWidth = 842;
3504 + psPaperHeight = 1190;
3505 + } else {
3506 + unlockGlobalParamsGUI;
3507 + return gFalse;
3508 + }
3509 + psImageableLLX = psImageableLLY = 0;
3510 + psImageableURX = psPaperWidth;
3511 + psImageableURY = psPaperHeight;
3512 + unlockGlobalParamsGUI;
3513 + return gTrue;
3514 +}
3515 +
3516 +void GlobalParamsGUI::setPSPaperWidth(int width) {
3517 + lockGlobalParamsGUI;
3518 + psPaperWidth = width;
3519 + psImageableLLX = 0;
3520 + psImageableURX = psPaperWidth;
3521 + unlockGlobalParamsGUI;
3522 +}
3523 +
3524 +void GlobalParamsGUI::setPSPaperHeight(int height) {
3525 + lockGlobalParamsGUI;
3526 + psPaperHeight = height;
3527 + psImageableLLY = 0;
3528 + psImageableURY = psPaperHeight;
3529 + unlockGlobalParamsGUI;
3530 +}
3531 +
3532 +void GlobalParamsGUI::setPSImageableArea(int llx, int lly, int urx, int ury) {
3533 + lockGlobalParamsGUI;
3534 + psImageableLLX = llx;
3535 + psImageableLLY = lly;
3536 + psImageableURX = urx;
3537 + psImageableURY = ury;
3538 + unlockGlobalParamsGUI;
3539 +}
3540 +
3541 +void GlobalParamsGUI::setPSCrop(GBool crop) {
3542 + lockGlobalParamsGUI;
3543 + psCrop = crop;
3544 + unlockGlobalParamsGUI;
3545 +}
3546 +
3547 +void GlobalParamsGUI::setPSExpandSmaller(GBool expand) {
3548 + lockGlobalParamsGUI;
3549 + psExpandSmaller = expand;
3550 + unlockGlobalParamsGUI;
3551 +}
3552 +
3553 +void GlobalParamsGUI::setPSShrinkLarger(GBool shrink) {
3554 + lockGlobalParamsGUI;
3555 + psShrinkLarger = shrink;
3556 + unlockGlobalParamsGUI;
3557 +}
3558 +
3559 +void GlobalParamsGUI::setPSCenter(GBool center) {
3560 + lockGlobalParamsGUI;
3561 + psCenter = center;
3562 + unlockGlobalParamsGUI;
3563 +}
3564 +
3565 +void GlobalParamsGUI::setPSDuplex(GBool duplex) {
3566 + lockGlobalParamsGUI;
3567 + psDuplex = duplex;
3568 + unlockGlobalParamsGUI;
3569 +}
3570 +
3571 +void GlobalParamsGUI::setPSLevel(PSLevel level) {
3572 + lockGlobalParamsGUI;
3573 + psLevel = level;
3574 + unlockGlobalParamsGUI;
3575 +}
3576 +
3577 +void GlobalParamsGUI::setPSEmbedType1(GBool embed) {
3578 + lockGlobalParamsGUI;
3579 + psEmbedType1 = embed;
3580 + unlockGlobalParamsGUI;
3581 +}
3582 +
3583 +void GlobalParamsGUI::setPSEmbedTrueType(GBool embed) {
3584 + lockGlobalParamsGUI;
3585 + psEmbedTrueType = embed;
3586 + unlockGlobalParamsGUI;
3587 +}
3588 +
3589 +void GlobalParamsGUI::setPSEmbedCIDPostScript(GBool embed) {
3590 + lockGlobalParamsGUI;
3591 + psEmbedCIDPostScript = embed;
3592 + unlockGlobalParamsGUI;
3593 +}
3594 +
3595 +void GlobalParamsGUI::setPSEmbedCIDTrueType(GBool embed) {
3596 + lockGlobalParamsGUI;
3597 + psEmbedCIDTrueType = embed;
3598 + unlockGlobalParamsGUI;
3599 +}
3600 +
3601 +void GlobalParamsGUI::setPSPreload(GBool preload) {
3602 + lockGlobalParamsGUI;
3603 + psPreload = preload;
3604 + unlockGlobalParamsGUI;
3605 +}
3606 +
3607 +void GlobalParamsGUI::setPSOPI(GBool opi) {
3608 + lockGlobalParamsGUI;
3609 + psOPI = opi;
3610 + unlockGlobalParamsGUI;
3611 +}
3612 +
3613 +void GlobalParamsGUI::setPSASCIIHex(GBool hex) {
3614 + lockGlobalParamsGUI;
3615 + psASCIIHex = hex;
3616 + unlockGlobalParamsGUI;
3617 +}
3618 +
3619 +void GlobalParamsGUI::setTextEncoding(char *encodingName) {
3620 + lockGlobalParamsGUI;
3621 + delete textEncoding;
3622 + textEncoding = new GooString(encodingName);
3623 + unlockGlobalParamsGUI;
3624 +}
3625 +
3626 +GBool GlobalParamsGUI::setTextEOL(char *s) {
3627 + lockGlobalParamsGUI;
3628 + if (!strcmp(s, "unix")) {
3629 + textEOL = eolUnix;
3630 + } else if (!strcmp(s, "dos")) {
3631 + textEOL = eolDOS;
3632 + } else if (!strcmp(s, "mac")) {
3633 + textEOL = eolMac;
3634 + } else {
3635 + unlockGlobalParamsGUI;
3636 + return gFalse;
3637 + }
3638 + unlockGlobalParamsGUI;
3639 + return gTrue;
3640 +}
3641 +
3642 +void GlobalParamsGUI::setTextPageBreaks(GBool pageBreaks) {
3643 + lockGlobalParamsGUI;
3644 + textPageBreaks = pageBreaks;
3645 + unlockGlobalParamsGUI;
3646 +}
3647 +
3648 +void GlobalParamsGUI::setTextKeepTinyChars(GBool keep) {
3649 + lockGlobalParamsGUI;
3650 + textKeepTinyChars = keep;
3651 + unlockGlobalParamsGUI;
3652 +}
3653 +
3654 +void GlobalParamsGUI::setInitialZoom(char *s) {
3655 + lockGlobalParamsGUI;
3656 + delete initialZoom;
3657 + initialZoom = new GooString(s);
3658 + unlockGlobalParamsGUI;
3659 +}
3660 +
3661 +void GlobalParamsGUI::setContinuousView(GBool cont) {
3662 + lockGlobalParamsGUI;
3663 + continuousView = cont;
3664 + unlockGlobalParamsGUI;
3665 +}
3666 +
3667 +GBool GlobalParamsGUI::setEnableT1lib(char *s) {
3668 + GBool ok;
3669 +
3670 + lockGlobalParamsGUI;
3671 + ok = parseYesNo2(s, &enableT1lib);
3672 + unlockGlobalParamsGUI;
3673 + return ok;
3674 +}
3675 +
3676 +GBool GlobalParamsGUI::setEnableFreeType(char *s) {
3677 + GBool ok;
3678 +
3679 + lockGlobalParamsGUI;
3680 + ok = parseYesNo2(s, &enableFreeType);
3681 + unlockGlobalParamsGUI;
3682 + return ok;
3683 +}
3684 +
3685 +
3686 +GBool GlobalParamsGUI::setAntialias(char *s) {
3687 + GBool ok;
3688 +
3689 + lockGlobalParamsGUI;
3690 + ok = parseYesNo2(s, &antialias);
3691 + unlockGlobalParamsGUI;
3692 + return ok;
3693 +}
3694 +
3695 +GBool GlobalParamsGUI::setVectorAntialias(char *s) {
3696 + GBool ok;
3697 +
3698 + lockGlobalParamsGUI;
3699 + ok = parseYesNo2(s, &vectorAntialias);
3700 + unlockGlobalParamsGUI;
3701 + return ok;
3702 +}
3703 +
3704 +void GlobalParamsGUI::setStrokeAdjust(GBool adjust)
3705 +{
3706 + lockGlobalParamsGUI;
3707 + strokeAdjust = adjust;
3708 + unlockGlobalParamsGUI;
3709 +}
3710 +
3711 +void GlobalParamsGUI::setScreenType(ScreenType st)
3712 +{
3713 + lockGlobalParamsGUI;
3714 + screenType = st;
3715 + unlockGlobalParamsGUI;
3716 +}
3717 +
3718 +void GlobalParamsGUI::setScreenSize(int size)
3719 +{
3720 + lockGlobalParamsGUI;
3721 + screenSize = size;
3722 + unlockGlobalParamsGUI;
3723 +}
3724 +
3725 +void GlobalParamsGUI::setScreenDotRadius(int radius)
3726 +{
3727 + lockGlobalParamsGUI;
3728 + screenDotRadius = radius;
3729 + unlockGlobalParamsGUI;
3730 +}
3731 +
3732 +void GlobalParamsGUI::setScreenGamma(double gamma)
3733 +{
3734 + lockGlobalParamsGUI;
3735 + screenGamma = gamma;
3736 + unlockGlobalParamsGUI;
3737 +}
3738 +
3739 +void GlobalParamsGUI::setScreenBlackThreshold(double blackThreshold)
3740 +{
3741 + lockGlobalParamsGUI;
3742 + screenBlackThreshold = blackThreshold;
3743 + unlockGlobalParamsGUI;
3744 +}
3745 +
3746 +void GlobalParamsGUI::setScreenWhiteThreshold(double whiteThreshold)
3747 +{
3748 + lockGlobalParamsGUI;
3749 + screenWhiteThreshold = whiteThreshold;
3750 + unlockGlobalParamsGUI;
3751 +}
3752 +
3753 +void GlobalParamsGUI::setMapNumericCharNames(GBool map) {
3754 + lockGlobalParamsGUI;
3755 + mapNumericCharNames = map;
3756 + unlockGlobalParamsGUI;
3757 +}
3758 +
3759 +void GlobalParamsGUI::setMapUnknownCharNames(GBool map) {
3760 + lockGlobalParamsGUI;
3761 + mapUnknownCharNames = map;
3762 + unlockGlobalParamsGUI;
3763 +}
3764 +
3765 +void GlobalParamsGUI::setPrintCommands(GBool printCommandsA) {
3766 + lockGlobalParamsGUI;
3767 + printCommands = printCommandsA;
3768 + unlockGlobalParamsGUI;
3769 +}
3770 +
3771 +void GlobalParamsGUI::setProfileCommands(GBool profileCommandsA) {
3772 + lockGlobalParamsGUI;
3773 + profileCommands = profileCommandsA;
3774 + unlockGlobalParamsGUI;
3775 +}
3776 +
3777 +void GlobalParamsGUI::setErrQuiet(GBool errQuietA) {
3778 + lockGlobalParamsGUI;
3779 + errQuiet = errQuietA;
3780 + unlockGlobalParamsGUI;
3781 +}
3782 +
3783 +void GlobalParamsGUI::addSecurityHandler(XpdfSecurityHandler *handler) {
3784 +#ifdef ENABLE_PLUGINS
3785 + lockGlobalParamsGUI;
3786 + securityHandlers->append(handler);
3787 + unlockGlobalParamsGUI;
3788 +#endif
3789 +}
3790 +
3791 +XpdfSecurityHandler *GlobalParamsGUI::getSecurityHandler(char *name) {
3792 +#ifdef ENABLE_PLUGINS
3793 + XpdfSecurityHandler *hdlr;
3794 + int i;
3795 +
3796 + lockGlobalParamsGUI;
3797 + for (i = 0; i < securityHandlers->getLength(); ++i) {
3798 + hdlr = (XpdfSecurityHandler *)securityHandlers->get(i);
3799 + if (!strcasecmp(hdlr->name, name)) {
3800 + unlockGlobalParamsGUI;
3801 + return hdlr;
3802 + }
3803 + }
3804 + unlockGlobalParamsGUI;
3805 +
3806 + if (!loadPlugin("security", name)) {
3807 + return NULL;
3808 + }
3809 + deleteGooList(keyBindings, KeyBinding);
3810 +
3811 + lockGlobalParamsGUI;
3812 + for (i = 0; i < securityHandlers->getLength(); ++i) {
3813 + hdlr = (XpdfSecurityHandler *)securityHandlers->get(i);
3814 + if (!strcmp(hdlr->name, name)) {
3815 + unlockGlobalParamsGUI;
3816 + return hdlr;
3817 + }
3818 + }
3819 + unlockGlobalParamsGUI;
3820 +#else
3821 + (void)name;
3822 +#endif
3823 +
3824 + return NULL;
3825 +}
3826 +
3827 +#ifdef ENABLE_PLUGINS
3828 +//------------------------------------------------------------------------
3829 +// plugins
3830 +//------------------------------------------------------------------------
3831 +
3832 +GBool GlobalParamsGUI::loadPlugin(char *type, char *name) {
3833 + Plugin *plugin;
3834 +
3835 + if (!(plugin = Plugin::load(type, name))) {
3836 + return gFalse;
3837 + }
3838 + lockGlobalParamsGUI;
3839 + plugins->append(plugin);
3840 + unlockGlobalParamsGUI;
3841 + return gTrue;
3842 +}
3843 +
3844 +#endif // ENABLE_PLUGINS
3845 --- GlobalParamsGUI.h
3846 +++ GlobalParamsGUI.h
3847 @@ -0,0 +1,479 @@
3848 +//========================================================================
3849 +//
3850 +// GlobalParamsGUI.h
3851 +//
3852 +// Copyright 2001-2003 Glyph & Cog, LLC
3853 +//
3854 +//========================================================================
3855 +
3856 +#ifndef GLOBALPARAMSGUI_H
3857 +#define GLOBALPARAMSGUI_H
3858 +
3859 +#ifdef USE_GCC_PRAGMAS
3860 +#pragma interface
3861 +#endif
3862 +
3863 +#include "config.h"
3864 +#include <stdio.h>
3865 +#include <fontconfig/fontconfig.h>
3866 +#include <GlobalParams.h>
3867 +#include "goo/gtypes.h"
3868 +#include "CharTypes.h"
3869 +
3870 +#if MULTITHREADED
3871 +#include "goo/GooMutex.h"
3872 +#endif
3873 +
3874 +class GooString;
3875 +class GooList;
3876 +class GooHash;
3877 +class NameToCharCode;
3878 +class CharCodeToUnicode;
3879 +class CharCodeToUnicodeCache;
3880 +class UnicodeMap;
3881 +class UnicodeMapCache;
3882 +class CMap;
3883 +class CMapCache;
3884 +struct XpdfSecurityHandler;
3885 +class GlobalParamsGUI;
3886 +class GfxFont;
3887 +#ifdef WIN32
3888 +class WinFontList;
3889 +#endif
3890 +
3891 +//------------------------------------------------------------------------
3892 +
3893 +// The global parameters object.
3894 +extern GlobalParamsGUI *globalParamsGUI;
3895 +
3896 +//------------------------------------------------------------------------
3897 +
3898 +/*enum DisplayFontParamKind {
3899 + displayFontT1,
3900 + displayFontTT
3901 +};
3902 +
3903 +struct DisplayFontParamT1 {
3904 + GooString *fileName;
3905 +};
3906 +
3907 +struct DisplayFontParamTT {
3908 + GooString *fileName;
3909 + int faceIndex;
3910 +};
3911 +
3912 +class DisplayFontParam {
3913 +public:
3914 +
3915 + GooString *name; // font name for 8-bit fonts and named
3916 + // CID fonts; collection name for
3917 + // generic CID fonts
3918 + DisplayFontParamKind kind;
3919 + union {
3920 + DisplayFontParamT1 t1;
3921 + DisplayFontParamTT tt;
3922 + };
3923 +
3924 + DisplayFontParam(GooString *nameA, DisplayFontParamKind kindA);
3925 + virtual ~DisplayFontParam();
3926 +};
3927 +
3928 +//------------------------------------------------------------------------
3929 +
3930 +class PSFontParam {
3931 +public:
3932 +
3933 + GooString *pdfFontName; // PDF font name for 8-bit fonts and
3934 + // named 16-bit fonts; char collection
3935 + // name for generic 16-bit fonts
3936 + int wMode; // writing mode (0=horiz, 1=vert) for
3937 + // 16-bit fonts
3938 + GooString *psFontName; // PostScript font name
3939 + GooString *encoding; // encoding, for 16-bit fonts only
3940 +
3941 + PSFontParam(GooString *pdfFontNameA, int wModeA,
3942 + GooString *psFontNameA, GooString *encodingA);
3943 + ~PSFontParam();
3944 +};*/
3945 +
3946 +//------------------------------------------------------------------------
3947 +
3948 +/*enum PSLevel {
3949 + psLevel1,
3950 + psLevel1Sep,
3951 + psLevel2,
3952 + psLevel2Sep,
3953 + psLevel3,
3954 + psLevel3Sep
3955 +};*/
3956 +
3957 +//------------------------------------------------------------------------
3958 +
3959 +/*enum EndOfLineKind {
3960 + eolUnix, // LF
3961 + eolDOS, // CR+LF
3962 + eolMac // CR
3963 +};*/
3964 +
3965 +//------------------------------------------------------------------------
3966 +
3967 +/*enum ScreenType {
3968 + screenUnset,
3969 + screenDispersed,
3970 + screenClustered,
3971 + screenStochasticClustered
3972 +};*/
3973 +
3974 +//------------------------------------------------------------------------
3975 +
3976 +class KeyBinding {
3977 +public:
3978 +
3979 + int code; // 0x20 .. 0xfe = ASCII,
3980 + // >=0x10000 = special keys, mouse buttons,
3981 + // etc. (xpdfKeyCode* symbols)
3982 + int mods; // modifiers (xpdfKeyMod* symbols, or-ed
3983 + // together)
3984 + int context; // context (xpdfKeyContext* symbols, or-ed
3985 + // together)
3986 + GooList *cmds; // list of commands [GooString]
3987 +
3988 + KeyBinding(int codeA, int modsA, int contextA, char *cmd0);
3989 + KeyBinding(int codeA, int modsA, int contextA, char *cmd0, char *cmd1);
3990 + KeyBinding(int codeA, int modsA, int contextA, GooList *cmdsA);
3991 + ~KeyBinding();
3992 +};
3993 +
3994 +#define xpdfKeyCodeTab 0x1000
3995 +#define xpdfKeyCodeReturn 0x1001
3996 +#define xpdfKeyCodeEnter 0x1002
3997 +#define xpdfKeyCodeBackspace 0x1003
3998 +#define xpdfKeyCodeInsert 0x1004
3999 +#define xpdfKeyCodeDelete 0x1005
4000 +#define xpdfKeyCodeHome 0x1006
4001 +#define xpdfKeyCodeEnd 0x1007
4002 +#define xpdfKeyCodePgUp 0x1008
4003 +#define xpdfKeyCodePgDn 0x1009
4004 +#define xpdfKeyCodeLeft 0x100a
4005 +#define xpdfKeyCodeRight 0x100b
4006 +#define xpdfKeyCodeUp 0x100c
4007 +#define xpdfKeyCodeDown 0x100d
4008 +#define xpdfKeyCodeF1 0x1100
4009 +#define xpdfKeyCodeF35 0x1122
4010 +#define xpdfKeyCodeAdd 0x1200
4011 +#define xpdfKeyCodeSubtract 0x1201
4012 +#define xpdfKeyCodeMousePress1 0x2001
4013 +#define xpdfKeyCodeMousePress2 0x2002
4014 +#define xpdfKeyCodeMousePress3 0x2003
4015 +#define xpdfKeyCodeMousePress4 0x2004
4016 +#define xpdfKeyCodeMousePress5 0x2005
4017 +#define xpdfKeyCodeMousePress6 0x2006
4018 +#define xpdfKeyCodeMousePress7 0x2007
4019 +#define xpdfKeyCodeMouseRelease1 0x2101
4020 +#define xpdfKeyCodeMouseRelease2 0x2102
4021 +#define xpdfKeyCodeMouseRelease3 0x2103
4022 +#define xpdfKeyCodeMouseRelease4 0x2104
4023 +#define xpdfKeyCodeMouseRelease5 0x2105
4024 +#define xpdfKeyCodeMouseRelease6 0x2106
4025 +#define xpdfKeyCodeMouseRelease7 0x2107
4026 +#define xpdfKeyModNone 0
4027 +#define xpdfKeyModShift (1 << 0)
4028 +#define xpdfKeyModCtrl (1 << 1)
4029 +#define xpdfKeyModAlt (1 << 2)
4030 +#define xpdfKeyContextAny 0
4031 +#define xpdfKeyContextFullScreen (1 << 0)
4032 +#define xpdfKeyContextWindow (2 << 0)
4033 +#define xpdfKeyContextContinuous (1 << 2)
4034 +#define xpdfKeyContextSinglePage (2 << 2)
4035 +#define xpdfKeyContextOverLink (1 << 4)
4036 +#define xpdfKeyContextOffLink (2 << 4)
4037 +#define xpdfKeyContextOutline (1 << 6)
4038 +#define xpdfKeyContextMainWin (2 << 6)
4039 +#define xpdfKeyContextScrLockOn (1 << 8)
4040 +#define xpdfKeyContextScrLockOff (2 << 8)
4041 +
4042 +//------------------------------------------------------------------------
4043 +
4044 +class GlobalParamsGUI {
4045 +public:
4046 +
4047 + // Initialize the global parameters by attempting to read a config
4048 + // file.
4049 + GlobalParamsGUI(char *cfgFileName = NULL);
4050 +
4051 + ~GlobalParamsGUI();
4052 +
4053 + void setBaseDir(char *dir);
4054 + void setupBaseFonts(char *dir);
4055 +
4056 + void parseLine(char *buf, GooString *fileName, int line);
4057 +
4058 + //----- accessors
4059 +
4060 + CharCode getMacRomanCharCode(char *charName);
4061 +
4062 + GooString *getBaseDir();
4063 + Unicode mapNameToUnicode(char *charName);
4064 + UnicodeMap *getResidentUnicodeMap(GooString *encodingName);
4065 + FILE *getUnicodeMapFile(GooString *encodingName);
4066 + FILE *findCMapFile(GooString *collection, GooString *cMapName);
4067 + FILE *findToUnicodeFile(GooString *name);
4068 + DisplayFontParam *getDisplayFont(GfxFont *font);
4069 + DisplayFontParam *getDisplayFont(GooString *fontName);
4070 + DisplayFontParam *getDisplayCIDFont(GooString *fontName, GooString *collection);
4071 + GooString *getPSFile();
4072 + int getPSPaperWidth();
4073 + int getPSPaperHeight();
4074 + void getPSImageableArea(int *llx, int *lly, int *urx, int *ury);
4075 + GBool getPSDuplex();
4076 + GBool getPSCrop();
4077 + GBool getPSExpandSmaller();
4078 + GBool getPSShrinkLarger();
4079 + GBool getPSCenter();
4080 + PSLevel getPSLevel();
4081 + PSFontParam *getPSFont(GooString *fontName);
4082 + PSFontParam *getPSFont16(GooString *fontName, GooString *collection, int wMode);
4083 + GBool getPSEmbedType1();
4084 + GBool getPSEmbedTrueType();
4085 + GBool getPSEmbedCIDPostScript();
4086 + GBool getPSEmbedCIDTrueType();
4087 + GBool getPSPreload();
4088 + GBool getPSOPI();
4089 + GBool getPSASCIIHex();
4090 + GooString *getTextEncodingName();
4091 + EndOfLineKind getTextEOL();
4092 + GBool getTextPageBreaks();
4093 + GBool getTextKeepTinyChars();
4094 + GooString *findFontFile(GooString *fontName, char **exts);
4095 + GooString *getInitialZoom();
4096 + GBool getContinuousView();
4097 + GBool getEnableT1lib();
4098 + GBool getEnableFreeType();
4099 + GBool getAntialias();
4100 + GBool getVectorAntialias();
4101 + GBool getStrokeAdjust();
4102 + ScreenType getScreenType();
4103 + int getScreenSize();
4104 + int getScreenDotRadius();
4105 + double getScreenGamma();
4106 + double getScreenBlackThreshold();
4107 + double getScreenWhiteThreshold();
4108 + GooString *getURLCommand() { return urlCommand; }
4109 + GooString *getMovieCommand() { return movieCommand; }
4110 + GBool getMapNumericCharNames();
4111 + GBool getMapUnknownCharNames();
4112 + GooList *getKeyBinding(int code, int mods, int context);
4113 + GBool getPrintCommands();
4114 + GBool getProfileCommands();
4115 + GBool getErrQuiet();
4116 +
4117 + CharCodeToUnicode *getCIDToUnicode(GooString *collection);
4118 + CharCodeToUnicode *getUnicodeToUnicode(GooString *fontName);
4119 + UnicodeMap *getUnicodeMap(GooString *encodingName);
4120 + CMap *getCMap(GooString *collection, GooString *cMapName);
4121 + UnicodeMap *getTextEncoding();
4122 +#ifdef ENABLE_PLUGINS
4123 + GBool loadPlugin(char *type, char *name);
4124 +#endif
4125 +
4126 + //----- functions to set parameters
4127 + void addDisplayFont(DisplayFontParam *param);
4128 + void setPSFile(char *file);
4129 + GBool setPSPaperSize(char *size);
4130 + void setPSPaperWidth(int width);
4131 + void setPSPaperHeight(int height);
4132 + void setPSImageableArea(int llx, int lly, int urx, int ury);
4133 + void setPSDuplex(GBool duplex);
4134 + void setPSCrop(GBool crop);
4135 + void setPSExpandSmaller(GBool expand);
4136 + void setPSShrinkLarger(GBool shrink);
4137 + void setPSCenter(GBool center);
4138 + void setPSLevel(PSLevel level);
4139 + void setPSEmbedType1(GBool embed);
4140 + void setPSEmbedTrueType(GBool embed);
4141 + void setPSEmbedCIDPostScript(GBool embed);
4142 + void setPSEmbedCIDTrueType(GBool embed);
4143 + void setPSPreload(GBool preload);
4144 + void setPSOPI(GBool opi);
4145 + void setPSASCIIHex(GBool hex);
4146 + void setTextEncoding(char *encodingName);
4147 + GBool setTextEOL(char *s);
4148 + void setTextPageBreaks(GBool pageBreaks);
4149 + void setTextKeepTinyChars(GBool keep);
4150 + void setInitialZoom(char *s);
4151 + void setContinuousView(GBool cont);
4152 + GBool setEnableT1lib(char *s);
4153 + GBool setEnableFreeType(char *s);
4154 + GBool setAntialias(char *s);
4155 + GBool setVectorAntialias(char *s);
4156 + void setStrokeAdjust(GBool strokeAdjust);
4157 + void setScreenType(ScreenType st);
4158 + void setScreenSize(int size);
4159 + void setScreenDotRadius(int radius);
4160 + void setScreenGamma(double gamma);
4161 + void setScreenBlackThreshold(double blackThreshold);
4162 + void setScreenWhiteThreshold(double whiteThreshold);
4163 + void setMapNumericCharNames(GBool map);
4164 + void setMapUnknownCharNames(GBool map);
4165 + void setPrintCommands(GBool printCommandsA);
4166 + void setProfileCommands(GBool profileCommandsA);
4167 + void setErrQuiet(GBool errQuietA);
4168 +
4169 + //----- security handlers
4170 +
4171 + void addSecurityHandler(XpdfSecurityHandler *handler);
4172 + XpdfSecurityHandler *getSecurityHandler(char *name);
4173 +
4174 + GBool parseYesNo2(char *token, GBool *flag);
4175 +private:
4176 +
4177 + void createDefaultKeyBindings();
4178 + void parseFile(GooString *fileName, FILE *f);
4179 + void parseNameToUnicode(GooList *tokens, GooString *fileName, int line);
4180 + void parseNameToUnicode(GooString *name);
4181 + void parseCIDToUnicode(GooList *tokens, GooString *fileName, int line);
4182 + void parseUnicodeToUnicode(GooList *tokens, GooString *fileName, int line);
4183 + void parseUnicodeMap(GooList *tokens, GooString *fileName, int line);
4184 + void parseCMapDir(GooList *tokens, GooString *fileName, int line);
4185 + void parseToUnicodeDir(GooList *tokens, GooString *fileName, int line);
4186 + void parseDisplayFont(GooList *tokens, GooHash *fontHash,
4187 + DisplayFontParamKind kind,
4188 + GooString *fileName, int line);
4189 + void parsePSFile(GooList *tokens, GooString *fileName, int line);
4190 + void parsePSPaperSize(GooList *tokens, GooString *fileName, int line);
4191 + void parsePSImageableArea(GooList *tokens, GooString *fileName, int line);
4192 + void parsePSLevel(GooList *tokens, GooString *fileName, int line);
4193 + void parsePSFont(GooList *tokens, GooString *fileName, int line);
4194 + void parsePSFont16(char *cmdName, GooList *fontList,
4195 + GooList *tokens, GooString *fileName, int line);
4196 + void parseTextEncoding(GooList *tokens, GooString *fileName, int line);
4197 + void parseTextEOL(GooList *tokens, GooString *fileName, int line);
4198 + void parseFontDir(GooList *tokens, GooString *fileName, int line);
4199 + void parseInitialZoom(GooList *tokens, GooString *fileName, int line);
4200 + void parseScreenType(GooList *tokens, GooString *fileName, int line);
4201 + void parseBind(GooList *tokens, GooString *fileName, int line);
4202 + void parseUnbind(GooList *tokens, GooString *fileName, int line);
4203 + GBool parseKey(GooString *modKeyStr, GooString *contextStr,
4204 + int *code, int *mods, int *context,
4205 + char *cmdName,
4206 + GooList *tokens, GooString *fileName, int line);
4207 + void parseCommand(char *cmdName, GooString **val,
4208 + GooList *tokens, GooString *fileName, int line);
4209 + void parseYesNo(char *cmdName, GBool *flag,
4210 + GooList *tokens, GooString *fileName, int line);
4211 + void parseInteger(char *cmdName, int *val,
4212 + GooList *tokens, GooString *fileName, int line);
4213 + void parseFloat(char *cmdName, double *val,
4214 + GooList *tokens, GooString *fileName, int line);
4215 + UnicodeMap *getUnicodeMap2(GooString *encodingName);
4216 +
4217 + void addCIDToUnicode(GooString *collection, GooString *fileName);
4218 + void addUnicodeMap(GooString *encodingName, GooString *fileName);
4219 + void addCMapDir(GooString *collection, GooString *dir);
4220 +
4221 + //----- static tables
4222 +
4223 + NameToCharCode * // mapping from char name to
4224 + macRomanReverseMap; // MacRomanEncoding index
4225 +
4226 + //----- user-modifiable settings
4227 +
4228 + GooString *baseDir; // base directory - for plugins, etc.
4229 + NameToCharCode * // mapping from char name to Unicode
4230 + nameToUnicode;
4231 + GooHash *cidToUnicodes; // files for mappings from char collections
4232 + // to Unicode, indexed by collection name
4233 + // [GooString]
4234 + GooHash *unicodeToUnicodes; // files for Unicode-to-Unicode mappings,
4235 + // indexed by font name pattern [GooString]
4236 + GooHash *residentUnicodeMaps; // mappings from Unicode to char codes,
4237 + // indexed by encoding name [UnicodeMap]
4238 + GooHash *unicodeMaps; // files for mappings from Unicode to char
4239 + // codes, indexed by encoding name [GooString]
4240 + GooHash *cMapDirs; // list of CMap dirs, indexed by collection
4241 + // name [GooList[GooString]]
4242 + GooList *toUnicodeDirs; // list of ToUnicode CMap dirs [GooString]
4243 + GooHash *displayFonts; // display font info, indexed by font name
4244 + // [DisplayFontParam]
4245 +#ifdef WIN32
4246 + WinFontList *winFontList; // system TrueType fonts
4247 +#endif
4248 + GooHash *displayCIDFonts; // display CID font info, indexed by
4249 + // collection [DisplayFontParam]
4250 + GooHash *displayNamedCIDFonts; // display CID font info, indexed by
4251 + // font name [DisplayFontParam]
4252 + GooString *psFile; // PostScript file or command (for xpdf)
4253 + int psPaperWidth; // paper size, in PostScript points, for
4254 + int psPaperHeight; // PostScript output
4255 + int psImageableLLX, // imageable area, in PostScript points,
4256 + psImageableLLY, // for PostScript output
4257 + psImageableURX,
4258 + psImageableURY;
4259 + GBool psCrop; // crop PS output to CropBox
4260 + GBool psExpandSmaller; // expand smaller pages to fill paper
4261 + GBool psShrinkLarger; // shrink larger pages to fit paper
4262 + GBool psCenter; // center pages on the paper
4263 + GBool psDuplex; // enable duplexing in PostScript?
4264 + PSLevel psLevel; // PostScript level to generate
4265 + GooHash *psFonts; // PostScript font info, indexed by PDF
4266 + // font name [PSFontParam]
4267 + GooList *psNamedFonts16; // named 16-bit fonts [PSFontParam]
4268 + GooList *psFonts16; // generic 16-bit fonts [PSFontParam]
4269 + GBool psEmbedType1; // embed Type 1 fonts?
4270 + GBool psEmbedTrueType; // embed TrueType fonts?
4271 + GBool psEmbedCIDPostScript; // embed CID PostScript fonts?
4272 + GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
4273 + GBool psPreload; // preload PostScript images and forms into
4274 + // memory
4275 + GBool psOPI; // generate PostScript OPI comments?
4276 + GBool psASCIIHex; // use ASCIIHex instead of ASCII85?
4277 + GooString *textEncoding; // encoding (unicodeMap) to use for text
4278 + // output
4279 + EndOfLineKind textEOL; // type of EOL marker to use for text
4280 + // output
4281 + GBool textPageBreaks; // insert end-of-page markers?
4282 + GBool textKeepTinyChars; // keep all characters in text output
4283 + GooList *fontDirs; // list of font dirs [GooString]
4284 + GooString *initialZoom; // initial zoom level
4285 + GBool continuousView; // continuous view mode
4286 + GBool enableT1lib; // t1lib enable flag
4287 + GBool enableFreeType; // FreeType enable flag
4288 + GBool antialias; // anti-aliasing enable flag
4289 + GBool vectorAntialias; // vector anti-aliasing enable flag
4290 + GBool strokeAdjust; // stroke adjustment enable flag
4291 + ScreenType screenType; // halftone screen type
4292 + int screenSize; // screen matrix size
4293 + int screenDotRadius; // screen dot radius
4294 + double screenGamma; // screen gamma correction
4295 + double screenBlackThreshold; // screen black clamping threshold
4296 + double screenWhiteThreshold; // screen white clamping threshold
4297 + GooString *urlCommand; // command executed for URL links
4298 + GooString *movieCommand; // command executed for movie annotations
4299 + GBool mapNumericCharNames; // map numeric char names (from font subsets)?
4300 + GBool mapUnknownCharNames; // map unknown char names?
4301 + GooList *keyBindings; // key & mouse button bindings [KeyBinding]
4302 + GBool printCommands; // print the drawing commands
4303 + GBool profileCommands; // profile the drawing commands
4304 + GBool errQuiet; // suppress error messages?
4305 +
4306 + CharCodeToUnicodeCache *cidToUnicodeCache;
4307 + CharCodeToUnicodeCache *unicodeToUnicodeCache;
4308 + UnicodeMapCache *unicodeMapCache;
4309 + CMapCache *cMapCache;
4310 +
4311 + FcConfig *FCcfg;
4312 +
4313 +#ifdef ENABLE_PLUGINS
4314 + GooList *plugins; // list of plugins [Plugin]
4315 + GooList *securityHandlers; // list of loaded security handlers
4316 + // [XpdfSecurityHandler]
4317 +#endif
4318 +
4319 +#if MULTITHREADED
4320 + GooMutex mutex;
4321 + GooMutex unicodeMapCacheMutex;
4322 + GooMutex cMapCacheMutex;
4323 +#endif
4324 +};
4325 +
4326 +#endif
4327 --- Makefile
4328 +++ Makefile
4329 @@ -4,7 +4,7 @@
4330
4331 CPPFLAGS+= $(INCLUDES) -DHAVE_DIRENT_H
4332
4333 -xpdf: CoreOutputDev.o GlobalParams.o ImageOutputDev.o PDFCore.o XPDFApp.o XPDFCore.o XPDFTree.o XPDFViewer.o parseargs.o xpdf.o
4334 +xpdf: CoreOutputDev.o GlobalParamsGUI.o ImageOutputDev.o PDFCore.o XPDFApp.o XPDFCore.o XPDFTree.o XPDFViewer.o parseargs.o xpdf.o
4335 $(CXX) $(CXXFLAGS) $(LDFLAGS) -o xpdf *.o $(LIBS)
4336
4337 clean:
4338 --- PDFCore.cc
4339 +++ PDFCore.cc
4340 @@ -19,7 +19,7 @@
4341 #include <endian.h>
4342 #include "GooString.h"
4343 #include "GooList.h"
4344 -#include "GlobalParams.h"
4345 +#include "GlobalParamsGUI.h"
4346 #include "Splash.h"
4347 #include "SplashBitmap.h"
4348 #include "SplashPattern.h"
4349 @@ -88,7 +88,7 @@
4350 int i;
4351
4352 doc = NULL;
4353 - continuousMode = globalParams->getContinuousView();
4354 + continuousMode = globalParamsGUI->getContinuousView();
4355 drawAreaWidth = drawAreaHeight = 0;
4356 maxPageW = totalDocH = 0;
4357 pageY = NULL;
4358 --- XPDFCore.cc
4359 +++ XPDFCore.cc
4360 @@ -19,7 +19,7 @@
4361 #include "GooString.h"
4362 #include "GooList.h"
4363 #include "Error.h"
4364 -#include "GlobalParams.h"
4365 +#include "GlobalParamsGUI.h"
4366 #include "PDFDoc.h"
4367 #include "Link.h"
4368 #include "FileSpec.h"
4369 @@ -114,7 +114,7 @@
4370 if (fullScreen) {
4371 zoom = zoomPage;
4372 } else {
4373 - initialZoom = globalParams->getInitialZoom();
4374 + initialZoom = globalParamsGUI->getInitialZoom();
4375 if (!initialZoom->cmp("page")) {
4376 zoom = zoomPage;
4377 } else if (!initialZoom->cmp("width")) {
4378 @@ -435,7 +435,7 @@
4379 if (!(array = (Atom *)XtMalloc(sizeof(Atom)))) {
4380 return False;
4381 }
4382 - if (strcmp("UTF-8",globalParams->getTextEncodingName()->getCString()))
4383 + if (strcmp("UTF-8",globalParamsGUI->getTextEncodingName()->getCString()))
4384 array[0] = XA_STRING;
4385 else
4386 array[0] = utf8str;
4387 @@ -571,7 +571,7 @@
4388
4389 // URI action
4390 case actionURI:
4391 - if (!(cmd = globalParams->getURLCommand())) {
4392 + if (!(cmd = globalParamsGUI->getURLCommand())) {
4393 error(-1, "No urlCommand defined in config file");
4394 break;
4395 }
4396 @@ -608,7 +608,7 @@
4397
4398 // Movie action
4399 case actionMovie:
4400 - if (!(cmd = globalParams->getMovieCommand())) {
4401 + if (!(cmd = globalParamsGUI->getMovieCommand())) {
4402 error(-1, "No movieCommand defined in config file");
4403 break;
4404 }
4405 --- XPDFViewer.cc
4406 +++ XPDFViewer.cc
4407 @@ -30,7 +30,7 @@
4408 #include "GooString.h"
4409 #include "GooList.h"
4410 #include "Error.h"
4411 -#include "GlobalParams.h"
4412 +#include "GlobalParamsGUI.h"
4413 #include "PDFDoc.h"
4414 #include "Link.h"
4415 #include "ErrorCodes.h"
4416 @@ -583,7 +583,7 @@
4417 return;
4418 }
4419
4420 - if ((cmds = globalParams->getKeyBinding(keyCode,
4421 + if ((cmds = globalParamsGUI->getKeyBinding(keyCode,
4422 viewer->getModifiers(modifiers),
4423 viewer->getContext(modifiers)))) {
4424 for (i = 0; i < cmds->getLength(); ++i) {
4425 @@ -615,7 +615,7 @@
4426 return;
4427 }
4428
4429 - if ((cmds = globalParams->getKeyBinding(keyCode,
4430 + if ((cmds = globalParamsGUI->getKeyBinding(keyCode,
4431 viewer->getModifiers(
4432 event->xkey.state),
4433 viewer->getContext(
4434 @@ -2668,11 +2668,11 @@
4435 // create the new labels
4436 items = core->getDoc()->getOutline()->getItems();
4437 if (items && items->getLength() > 0) {
4438 - if (strcmp("UTF-8",globalParams->getTextEncodingName()->getCString()))
4439 + if (strcmp("UTF-8",globalParamsGUI->getTextEncodingName()->getCString()))
4440 enc = new GooString("Latin1");
4441 else
4442 enc = new GooString("UTF-8");
4443 - uMap = globalParams->getUnicodeMap(enc);
4444 + uMap = globalParamsGUI->getUnicodeMap(enc);
4445 delete enc;
4446 setupOutlineItems(items, NULL, uMap);
4447 uMap->decRefCnt();
4448 @@ -3329,7 +3329,7 @@
4449 XtSetValues(printDialog, args, n);
4450
4451 //----- initial values
4452 - if ((psFileName = globalParams->getPSFile())) {
4453 + if ((psFileName = globalParamsGUI->getPSFile())) {
4454 if (psFileName->getChar(0) == '|') {
4455 XmTextFieldSetString(printCmdText,
4456 psFileName->getCString() + 1);
4457 @@ -3347,7 +3347,7 @@
4458 char *p;
4459
4460 doc = core->getDoc();
4461 - psFileName = globalParams->getPSFile();
4462 + psFileName = globalParamsGUI->getPSFile();
4463 if (!psFileName || psFileName->getChar(0) == '|') {
4464 pdfFileName = doc->getFileName();
4465 p = pdfFileName->getCString() + pdfFileName->getLength() - 4;
4466 @@ -3453,7 +3453,7 @@
4467 firstPage, lastPage, psModePS);
4468 if (psOut->isOk()) {
4469 doc->displayPages(psOut, firstPage, lastPage, 72, 72,
4470 - 0, gTrue, globalParams->getPSCrop(), gTrue);
4471 + 0, gTrue, globalParamsGUI->getPSCrop(), gTrue);
4472 }
4473 delete psOut;
4474 delete psFileName;
4475 --- xpdf.cc
4476 +++ xpdf.cc
4477 @@ -12,7 +12,8 @@
4478 #include "parseargs.h"
4479 #include "gfile.h"
4480 #include "gmem.h"
4481 -#include "GlobalParams.h"
4482 +#include "GlobalParamsGUI.h"
4483 +#include <GlobalParams.h>
4484 #include "Object.h"
4485 #include "XPDFApp.h"
4486 #include "config.h"
4487 @@ -26,6 +27,7 @@
4488 static char enableFreeTypeStr[16] = "";
4489 static char antialiasStr[16] = "";
4490 static char vectorAntialiasStr[16] = "";
4491 +static char autohintingStr[16] = "no";
4492 static char psFileArg[256];
4493 static char paperSize[15] = "";
4494 static int paperWidth = 0;
4495 @@ -78,6 +80,8 @@
4496 "enable font anti-aliasing: yes, no"},
4497 {"-aaVector", argString, vectorAntialiasStr, sizeof(vectorAntialiasStr),
4498 "enable vector anti-aliasing: yes, no"},
4499 + {"-ah", argString, autohintingStr, sizeof(autohintingStr),
4500 + "enable font auto-hinting: yes, no (default no)"},
4501 {"-ps", argString, psFileArg, sizeof(psFileArg),
4502 "default PostScript file name or command"},
4503 {"-paper", argString, paperSize, sizeof(paperSize),
4504 @@ -153,63 +157,76 @@
4505 goto done0;
4506 }
4507
4508 + // poppler's globalParams
4509 + globalParams = new GlobalParams;
4510 +
4511 // read config file
4512 - globalParams = new GlobalParams(cfgFileName);
4513 - globalParams->setupBaseFonts(NULL);
4514 + globalParamsGUI = new GlobalParamsGUI(cfgFileName);
4515 + globalParamsGUI->setupBaseFonts(NULL);
4516 if (contView) {
4517 - globalParams->setContinuousView(contView);
4518 + globalParamsGUI->setContinuousView(contView);
4519 }
4520 if (psFileArg[0]) {
4521 - globalParams->setPSFile(psFileArg);
4522 + globalParamsGUI->setPSFile(psFileArg);
4523 }
4524 if (paperSize[0]) {
4525 - if (!globalParams->setPSPaperSize(paperSize)) {
4526 + if (!globalParamsGUI->setPSPaperSize(paperSize)) {
4527 fprintf(stderr, "Invalid paper size\n");
4528 }
4529 } else {
4530 if (paperWidth) {
4531 - globalParams->setPSPaperWidth(paperWidth);
4532 + globalParamsGUI->setPSPaperWidth(paperWidth);
4533 }
4534 if (paperHeight) {
4535 - globalParams->setPSPaperHeight(paperHeight);
4536 + globalParamsGUI->setPSPaperHeight(paperHeight);
4537 }
4538 }
4539 if (level1) {
4540 - globalParams->setPSLevel(psLevel1);
4541 + globalParamsGUI->setPSLevel(psLevel1);
4542 }
4543 if (textEncName[0]) {
4544 - globalParams->setTextEncoding(textEncName);
4545 + globalParamsGUI->setTextEncoding(textEncName);
4546 }
4547 if (textEOL[0]) {
4548 - if (!globalParams->setTextEOL(textEOL)) {
4549 + if (!globalParamsGUI->setTextEOL(textEOL)) {
4550 fprintf(stderr, "Bad '-eol' value on command line\n");
4551 }
4552 }
4553 if (enableT1libStr[0]) {
4554 - if (!globalParams->setEnableT1lib(enableT1libStr)) {
4555 + if (!globalParamsGUI->setEnableT1lib(enableT1libStr)) {
4556 fprintf(stderr, "Bad '-t1lib' value on command line\n");
4557 }
4558 }
4559 if (enableFreeTypeStr[0]) {
4560 - if (!globalParams->setEnableFreeType(enableFreeTypeStr)) {
4561 + if (!globalParamsGUI->setEnableFreeType(enableFreeTypeStr)) {
4562 fprintf(stderr, "Bad '-freetype' value on command line\n");
4563 }
4564 }
4565 if (antialiasStr[0]) {
4566 - if (!globalParams->setAntialias(antialiasStr)) {
4567 + if (!globalParamsGUI->setAntialias(antialiasStr)) {
4568 fprintf(stderr, "Bad '-aa' value on command line\n");
4569 }
4570 }
4571 if (vectorAntialiasStr[0]) {
4572 - if (!globalParams->setVectorAntialias(vectorAntialiasStr)) {
4573 + if (!globalParamsGUI->setVectorAntialias(vectorAntialiasStr)) {
4574 fprintf(stderr, "Bad '-aaVector' value on command line\n");
4575 }
4576 }
4577 + if (autohintingStr[0]) {
4578 + GBool ah;
4579 + if (!globalParamsGUI->parseYesNo2(autohintingStr, &ah)) {
4580 + fprintf(stderr, "Bad '-ah' value on command line\n");
4581 + }
4582 + if (ah == gTrue)
4583 + globalParams->setForceNoFTAutoHinting("no");
4584 + else
4585 + globalParams->setForceNoFTAutoHinting("yes");
4586 + }
4587 if (printCommands) {
4588 - globalParams->setPrintCommands(printCommands);
4589 + globalParamsGUI->setPrintCommands(printCommands);
4590 }
4591 if (quiet) {
4592 - globalParams->setErrQuiet(quiet);
4593 + globalParamsGUI->setErrQuiet(quiet);
4594 }
4595
4596 // create the XPDFApp object
4597 @@ -218,7 +235,7 @@
4598 // the initialZoom parameter can be set in either the config file or
4599 // as an X resource (or command line arg)
4600 if (app->getInitialZoom()) {
4601 - globalParams->setInitialZoom(app->getInitialZoom()->getCString());
4602 + globalParamsGUI->setInitialZoom(app->getInitialZoom()->getCString());
4603 }
4604
4605 // check command line
4606 @@ -333,6 +350,7 @@
4607 }
4608 done1:
4609 delete app;
4610 + delete globalParamsGUI;
4611 delete globalParams;
4612
4613 // check for memory leaks
4614
4615
4616
4617 1.1 src/patchsets/xpdf/3.02/45_all_xpdf-poppler-private-textpage-destructor.patch
4618
4619 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/45_all_xpdf-poppler-private-textpage-destructor.patch?rev=1.1&view=markup
4620 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/45_all_xpdf-poppler-private-textpage-destructor.patch?rev=1.1&content-type=text/plain
4621
4622 Index: 45_all_xpdf-poppler-private-textpage-destructor.patch
4623 ===================================================================
4624 --- PDFCore.cc
4625 +++ PDFCore.cc
4626 @@ -53,7 +53,7 @@
4627 delete links;
4628 }
4629 if (text) {
4630 - delete text;
4631 + text->decRefCnt(); // this will delete text itself
4632 }
4633 }
4634
4635
4636
4637
4638 1.1 src/patchsets/xpdf/3.02/50_all_xpdf-poppler-getCMap-arguments.patch
4639
4640 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/50_all_xpdf-poppler-getCMap-arguments.patch?rev=1.1&view=markup
4641 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/xpdf/3.02/50_all_xpdf-poppler-getCMap-arguments.patch?rev=1.1&content-type=text/plain
4642
4643 Index: 50_all_xpdf-poppler-getCMap-arguments.patch
4644 ===================================================================
4645 --- GlobalParams.cc
4646 +++ GlobalParams.cc
4647 @@ -2835,11 +2835,11 @@
4648 return map;
4649 }
4650
4651 -CMap *GlobalParams::getCMap(GooString *collection, GooString *cMapName) {
4652 +CMap *GlobalParams::getCMap(GooString *collection, GooString *cMapName, Stream *stream) {
4653 CMap *cMap;
4654
4655 lockCMapCache;
4656 - cMap = cMapCache->getCMap(collection, cMapName);
4657 + cMap = cMapCache->getCMap(collection, cMapName, stream);
4658 unlockCMapCache;
4659 return cMap;
4660 }
4661 --- GlobalParams.h
4662 +++ GlobalParams.h
4663 @@ -269,7 +269,7 @@
4664 CharCodeToUnicode *getCIDToUnicode(GooString *collection);
4665 CharCodeToUnicode *getUnicodeToUnicode(GooString *fontName);
4666 UnicodeMap *getUnicodeMap(GooString *encodingName);
4667 - CMap *getCMap(GooString *collection, GooString *cMapName);
4668 + CMap *getCMap(GooString *collection, GooString *cMapName, Stream *stream);
4669 UnicodeMap *getTextEncoding();
4670 #ifdef ENABLE_PLUGINS
4671 GBool loadPlugin(char *type, char *name);
4672 --- GlobalParamsGUI.cc
4673 +++ GlobalParamsGUI.cc
4674 @@ -2835,11 +2835,11 @@
4675 return map;
4676 }
4677
4678 -CMap *GlobalParamsGUI::getCMap(GooString *collection, GooString *cMapName) {
4679 +CMap *GlobalParamsGUI::getCMap(GooString *collection, GooString *cMapName, Stream *stream) {
4680 CMap *cMap;
4681
4682 lockCMapCache;
4683 - cMap = cMapCache->getCMap(collection, cMapName);
4684 + cMap = cMapCache->getCMap(collection, cMapName, stream);
4685 unlockCMapCache;
4686 return cMap;
4687 }
4688 --- GlobalParamsGUI.h
4689 +++ GlobalParamsGUI.h
4690 @@ -270,7 +270,7 @@
4691 CharCodeToUnicode *getCIDToUnicode(GooString *collection);
4692 CharCodeToUnicode *getUnicodeToUnicode(GooString *fontName);
4693 UnicodeMap *getUnicodeMap(GooString *encodingName);
4694 - CMap *getCMap(GooString *collection, GooString *cMapName);
4695 + CMap *getCMap(GooString *collection, GooString *cMapName, Stream *stream);
4696 UnicodeMap *getTextEncoding();
4697 #ifdef ENABLE_PLUGINS
4698 GBool loadPlugin(char *type, char *name);