file(s) added by xpdf 1.01. xpdf-1-01
authorkramm <kramm>
Mon, 27 May 2002 15:56:26 +0000 (15:56 +0000)
committerkramm <kramm>
Mon, 27 May 2002 15:56:26 +0000 (15:56 +0000)
34 files changed:
pdf2swf/xpdf/Annot.cc [new file with mode: 0644]
pdf2swf/xpdf/Annot.h [new file with mode: 0644]
pdf2swf/xpdf/BuiltinFont.cc [new file with mode: 0644]
pdf2swf/xpdf/BuiltinFont.h [new file with mode: 0644]
pdf2swf/xpdf/BuiltinFontTables.cc [new file with mode: 0644]
pdf2swf/xpdf/BuiltinFontTables.h [new file with mode: 0644]
pdf2swf/xpdf/CMap.cc [new file with mode: 0644]
pdf2swf/xpdf/CMap.h [new file with mode: 0644]
pdf2swf/xpdf/CharCodeToUnicode.cc [new file with mode: 0644]
pdf2swf/xpdf/CharCodeToUnicode.h [new file with mode: 0644]
pdf2swf/xpdf/CharTypes.h [new file with mode: 0644]
pdf2swf/xpdf/CompactFontTables.h [new file with mode: 0644]
pdf2swf/xpdf/DisplayFontTable.h [new file with mode: 0644]
pdf2swf/xpdf/ErrorCodes.h [new file with mode: 0644]
pdf2swf/xpdf/FontEncodingTables.cc [new file with mode: 0644]
pdf2swf/xpdf/FontEncodingTables.h [new file with mode: 0644]
pdf2swf/xpdf/Function.cc [new file with mode: 0644]
pdf2swf/xpdf/Function.h [new file with mode: 0644]
pdf2swf/xpdf/GHash.cc [new file with mode: 0644]
pdf2swf/xpdf/GHash.h [new file with mode: 0644]
pdf2swf/xpdf/GList.cc [new file with mode: 0644]
pdf2swf/xpdf/GList.h [new file with mode: 0644]
pdf2swf/xpdf/GlobalParams.cc [new file with mode: 0644]
pdf2swf/xpdf/GlobalParams.h [new file with mode: 0644]
pdf2swf/xpdf/NameToCharCode.cc [new file with mode: 0644]
pdf2swf/xpdf/NameToCharCode.h [new file with mode: 0644]
pdf2swf/xpdf/NameToUnicodeTable.h [new file with mode: 0644]
pdf2swf/xpdf/PSTokenizer.cc [new file with mode: 0644]
pdf2swf/xpdf/PSTokenizer.h [new file with mode: 0644]
pdf2swf/xpdf/UTF8.h [new file with mode: 0644]
pdf2swf/xpdf/UnicodeMap.cc [new file with mode: 0644]
pdf2swf/xpdf/UnicodeMap.h [new file with mode: 0644]
pdf2swf/xpdf/UnicodeMapTables.h [new file with mode: 0644]
pdf2swf/xpdf/aconf.h [new file with mode: 0644]

diff --git a/pdf2swf/xpdf/Annot.cc b/pdf2swf/xpdf/Annot.cc
new file mode 100644 (file)
index 0000000..b9c606f
--- /dev/null
@@ -0,0 +1,138 @@
+//========================================================================
+//
+// Annot.cc
+//
+// Copyright 2000-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include "gmem.h"
+#include "Object.h"
+#include "Gfx.h"
+#include "Annot.h"
+
+//------------------------------------------------------------------------
+// Annot
+//------------------------------------------------------------------------
+
+Annot::Annot(XRef *xrefA, Dict *dict) {
+  Object apObj, asObj, obj1, obj2;
+  double t;
+
+  ok = gFalse;
+  xref = xrefA;
+
+  if (dict->lookup("AP", &apObj)->isDict()) {
+    if (dict->lookup("AS", &asObj)->isName()) {
+      if (apObj.dictLookup("N", &obj1)->isDict()) {
+       if (obj1.dictLookupNF(asObj.getName(), &obj2)->isRef()) {
+         obj2.copy(&appearance);
+         ok = gTrue;
+       }
+       obj2.free();
+      }
+      obj1.free();
+    } else {
+      if (apObj.dictLookupNF("N", &obj1)->isRef()) {
+       obj1.copy(&appearance);
+       ok = gTrue;
+      }
+      obj1.free();
+    }
+    asObj.free();
+  }
+  apObj.free();
+
+  if (dict->lookup("Rect", &obj1)->isArray() &&
+      obj1.arrayGetLength() == 4) {
+    //~ should check object types here
+    obj1.arrayGet(0, &obj2);
+    xMin = obj2.getNum();
+    obj2.free();
+    obj1.arrayGet(1, &obj2);
+    yMin = obj2.getNum();
+    obj2.free();
+    obj1.arrayGet(2, &obj2);
+    xMax = obj2.getNum();
+    obj2.free();
+    obj1.arrayGet(3, &obj2);
+    yMax = obj2.getNum();
+    obj2.free();
+    if (xMin > xMax) {
+      t = xMin; xMin = xMax; xMax = t;
+    }
+    if (yMin > yMax) {
+      t = yMin; yMin = yMax; yMax = t;
+    }
+  } else {
+    //~ this should return an error
+    xMin = yMin = 0;
+    xMax = yMax = 1;
+  }
+  obj1.free();
+}
+
+Annot::~Annot() {
+  appearance.free();
+}
+
+void Annot::draw(Gfx *gfx) {
+  Object obj;
+
+  if (appearance.fetch(xref, &obj)->isStream()) {
+    gfx->doAnnot(&obj, xMin, yMin, xMax, yMax);
+  }
+  obj.free();
+}
+
+//------------------------------------------------------------------------
+// Annots
+//------------------------------------------------------------------------
+
+Annots::Annots(XRef *xref, Object *annotsObj) {
+  Annot *annot;
+  Object obj1, obj2;
+  int size;
+  int i;
+
+  annots = NULL;
+  size = 0;
+  nAnnots = 0;
+
+  if (annotsObj->isArray()) {
+    for (i = 0; i < annotsObj->arrayGetLength(); ++i) {
+      if (annotsObj->arrayGet(i, &obj1)->isDict()) {
+       obj1.dictLookup("Subtype", &obj2);
+       if (obj2.isName("Widget") ||
+           obj2.isName("Stamp")) {
+         annot = new Annot(xref, obj1.getDict());
+         if (annot->isOk()) {
+           if (nAnnots >= size) {
+             size += 16;
+             annots = (Annot **)grealloc(annots, size * sizeof(Annot *));
+           }
+           annots[nAnnots++] = annot;
+         } else {
+           delete annot;
+         }
+       }
+       obj2.free();
+      }
+      obj1.free();
+    }
+  }
+}
+
+Annots::~Annots() {
+  int i;
+
+  for (i = 0; i < nAnnots; ++i) {
+    delete annots[i];
+  }
+  gfree(annots);
+}
diff --git a/pdf2swf/xpdf/Annot.h b/pdf2swf/xpdf/Annot.h
new file mode 100644 (file)
index 0000000..4113a0b
--- /dev/null
@@ -0,0 +1,67 @@
+//========================================================================
+//
+// Annot.h
+//
+// Copyright 2000-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef ANNOT_H
+#define ANNOT_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+class XRef;
+class Gfx;
+
+//------------------------------------------------------------------------
+// Annot
+//------------------------------------------------------------------------
+
+class Annot {
+public:
+
+  Annot(XRef *xrefA, Dict *dict);
+  ~Annot();
+  GBool isOk() { return ok; }
+
+  void draw(Gfx *gfx);
+
+  // Get appearance object.
+  Object *getAppearance(Object *obj) { return appearance.fetch(xref, obj); }
+
+private:
+
+  XRef *xref;                  // the xref table for this PDF file
+  Object appearance;           // a reference to the Form XObject stream
+                               //   for the normal appearance
+  double xMin, yMin,           // annotation rectangle
+         xMax, yMax;
+  GBool ok;
+};
+
+//------------------------------------------------------------------------
+// Annots
+//------------------------------------------------------------------------
+
+class Annots {
+public:
+
+  // Extract non-link annotations from array of annotations.
+  Annots(XRef *xref, Object *annotsObj);
+
+  ~Annots();
+
+  // Iterate through list of annotations.
+  int getNumAnnots() { return nAnnots; }
+  Annot *getAnnot(int i) { return annots[i]; }
+
+private:
+
+  Annot **annots;
+  int nAnnots;
+};
+
+#endif
diff --git a/pdf2swf/xpdf/BuiltinFont.cc b/pdf2swf/xpdf/BuiltinFont.cc
new file mode 100644 (file)
index 0000000..1b07064
--- /dev/null
@@ -0,0 +1,64 @@
+//========================================================================
+//
+// BuiltinFont.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include <stdlib.h>
+#include <string.h>
+#include "gmem.h"
+#include "FontEncodingTables.h"
+#include "BuiltinFont.h"
+
+//------------------------------------------------------------------------
+
+BuiltinFontWidths::BuiltinFontWidths(BuiltinFontWidth *widths, int sizeA) {
+  int i, h;
+
+  size = sizeA;
+  tab = (BuiltinFontWidth **)gmalloc(size * sizeof(BuiltinFontWidth *));
+  for (i = 0; i < size; ++i) {
+    tab[i] = NULL;
+  }
+  for (i = 0; i < sizeA; ++i) {
+    h = hash(widths[i].name);
+    widths[i].next = tab[h];
+    tab[h] = &widths[i];
+  }
+}
+
+BuiltinFontWidths::~BuiltinFontWidths() {
+  gfree(tab);
+}
+
+GBool BuiltinFontWidths::getWidth(char *name, Gushort *width) {
+  int h;
+  BuiltinFontWidth *p;
+
+  h = hash(name);
+  for (p = tab[h]; p; p = p->next) {
+    if (!strcmp(p->name, name)) {
+      *width = p->width;
+      return gTrue;
+    }
+  }
+  return gFalse;
+}
+
+int BuiltinFontWidths::hash(char *name) {
+  char *p;
+  unsigned int h;
+
+  h = 0;
+  for (p = name; *p; ++p) {
+    h = 17 * h + (int)(*p & 0xff);
+  }
+  return (int)(h % size);
+}
diff --git a/pdf2swf/xpdf/BuiltinFont.h b/pdf2swf/xpdf/BuiltinFont.h
new file mode 100644 (file)
index 0000000..a795311
--- /dev/null
@@ -0,0 +1,55 @@
+//========================================================================
+//
+// BuiltinFont.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef BUILTINFONT_H
+#define BUILTINFONT_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include "gtypes.h"
+
+struct BuiltinFont;
+class BuiltinFontWidths;
+
+//------------------------------------------------------------------------
+
+struct BuiltinFont {
+  char *name;
+  char **defaultBaseEnc;
+  short ascent;
+  short descent;
+  short bbox[4];
+  BuiltinFontWidths *widths;
+};
+
+//------------------------------------------------------------------------
+
+struct BuiltinFontWidth {
+  char *name;
+  Gushort width;
+  BuiltinFontWidth *next;
+};
+
+class BuiltinFontWidths {
+public:
+
+  BuiltinFontWidths(BuiltinFontWidth *widths, int sizeA);
+  ~BuiltinFontWidths();
+  GBool getWidth(char *name, Gushort *width);
+
+private:
+
+  int hash(char *name);
+
+  BuiltinFontWidth **tab;
+  int size;
+};
+
+#endif
diff --git a/pdf2swf/xpdf/BuiltinFontTables.cc b/pdf2swf/xpdf/BuiltinFontTables.cc
new file mode 100644 (file)
index 0000000..845abcd
--- /dev/null
@@ -0,0 +1,3366 @@
+//========================================================================
+//
+// BuiltinFontTables.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#include <aconf.h>
+#include <stdlib.h>
+#include "FontEncodingTables.h"
+#include "BuiltinFontTables.h"
+
+static BuiltinFontWidth courierWidthsTab[] = {
+  { "Ntilde",                            600, NULL },
+  { "comma",                             600, NULL },
+  { "cedilla",                           600, NULL },
+  { "plusminus",                         600, NULL },
+  { "arrowup",                           600, NULL },
+  { "circumflex",                        600, NULL },
+  { "dotaccent",                         600, NULL },
+  { "LL",                                600, NULL },
+  { "asciitilde",                        600, NULL },
+  { "colon",                             600, NULL },
+  { "onehalf",                           600, NULL },
+  { "dollar",                            600, NULL },
+  { "ntilde",                            600, NULL },
+  { "left",                              600, NULL },
+  { "minus",                             600, NULL },
+  { "yen",                               600, NULL },
+  { "space",                             600, NULL },
+  { "questiondown",                      600, NULL },
+  { "emdash",                            600, NULL },
+  { "Agrave",                            600, NULL },
+  { "three",                             600, NULL },
+  { "numbersign",                        600, NULL },
+  { "A",                                 600, NULL },
+  { "B",                                 600, NULL },
+  { "C",                                 600, NULL },
+  { "D",                                 600, NULL },
+  { "E",                                 600, NULL },
+  { "onequarter",                        600, NULL },
+  { "F",                                 600, NULL },
+  { "G",                                 600, NULL },
+  { "H",                                 600, NULL },
+  { "I",                                 600, NULL },
+  { "J",                                 600, NULL },
+  { "K",                                 600, NULL },
+  { "L",                                 600, NULL },
+  { "backslash",                         600, NULL },
+  { "periodcentered",                    600, NULL },
+  { "M",                                 600, NULL },
+  { "N",                                 600, NULL },
+  { "O",                                 600, NULL },
+  { "P",                                 600, NULL },
+  { "Q",                                 600, NULL },
+  { "R",                                 600, NULL },
+  { "Aacute",                            600, NULL },
+  { "caron",                             600, NULL },
+  { "S",                                 600, NULL },
+  { "T",                                 600, NULL },
+  { "U",                                 600, NULL },
+  { "agrave",                            600, NULL },
+  { "V",                                 600, NULL },
+  { "tab",                               600, NULL },
+  { "W",                                 600, NULL },
+  { "ll",                                600, NULL },
+  { "equal",                             600, NULL },
+  { "question",                          600, NULL },
+  { "X",                                 600, NULL },
+  { "Y",                                 600, NULL },
+  { "Z",                                 600, NULL },
+  { "four",                              600, NULL },
+  { "a",                                 600, NULL },
+  { "b",                                 600, NULL },
+  { "c",                                 600, NULL },
+  { "d",                                 600, NULL },
+  { "e",                                 600, NULL },
+  { "f",                                 600, NULL },
+  { "g",                                 600, NULL },
+  { "bullet",                            600, NULL },
+  { "h",                                 600, NULL },
+  { "i",                                 600, NULL },
+  { "Oslash",                            600, NULL },
+  { "dagger",                            600, NULL },
+  { "j",                                 600, NULL },
+  { "k",                                 600, NULL },
+  { "l",                                 600, NULL },
+  { "m",                                 600, NULL },
+  { "n",                                 600, NULL },
+  { "o",                                 600, NULL },
+  { "ordfeminine",                       600, NULL },
+  { "ring",                              600, NULL },
+  { "p",                                 600, NULL },
+  { "q",                                 600, NULL },
+  { "r",                                 600, NULL },
+  { "twosuperior",                       600, NULL },
+  { "largebullet",                       600, NULL },
+  { "aacute",                            600, NULL },
+  { "s",                                 600, NULL },
+  { "OE",                                600, NULL },
+  { "t",                                 600, NULL },
+  { "divide",                            600, NULL },
+  { "u",                                 600, NULL },
+  { "v",                                 600, NULL },
+  { "w",                                 600, NULL },
+  { "x",                                 600, NULL },
+  { "y",                                 600, NULL },
+  { "z",                                 600, NULL },
+  { "hungarumlaut",                      600, NULL },
+  { "quotedbl",                          600, NULL },
+  { "mu",                                600, NULL },
+  { "Scaron",                            600, NULL },
+  { "Lslash",                            600, NULL },
+  { "semicolon",                         600, NULL },
+  { "oslash",                            600, NULL },
+  { "parenright",                        600, NULL },
+  { "Ecircumflex",                       600, NULL },
+  { "trademark",                         600, NULL },
+  { "daggerdbl",                         600, NULL },
+  { "macron",                            600, NULL },
+  { "Otilde",                            600, NULL },
+  { "ellipsis",                          600, NULL },
+  { "scaron",                            600, NULL },
+  { "AE",                                600, NULL },
+  { "Ucircumflex",                       600, NULL },
+  { "lslash",                            600, NULL },
+  { "lira",                              600, NULL },
+  { "quotedblleft",                      600, NULL },
+  { "hyphen",                            600, NULL },
+  { "guilsinglright",                    600, NULL },
+  { "quotesingle",                       600, NULL },
+  { "eight",                             600, NULL },
+  { "exclamdown",                        600, NULL },
+  { "endash",                            600, NULL },
+  { "oe",                                600, NULL },
+  { "ecircumflex",                       600, NULL },
+  { "copyright",                         600, NULL },
+  { "Adieresis",                         600, NULL },
+  { "Egrave",                            600, NULL },
+  { "slash",                             600, NULL },
+  { "Edieresis",                         600, NULL },
+  { "otilde",                            600, NULL },
+  { "Idieresis",                         600, NULL },
+  { "parenleft",                         600, NULL },
+  { "one",                               600, NULL },
+  { "ucircumflex",                       600, NULL },
+  { "Odieresis",                         600, NULL },
+  { "bracketleft",                       600, NULL },
+  { "Ugrave",                            600, NULL },
+  { "quoteright",                        600, NULL },
+  { "Udieresis",                         600, NULL },
+  { "perthousand",                       600, NULL },
+  { "Ydieresis",                         600, NULL },
+  { "Eacute",                            600, NULL },
+  { "adieresis",                         600, NULL },
+  { "egrave",                            600, NULL },
+  { "edieresis",                         600, NULL },
+  { "idieresis",                         600, NULL },
+  { "Eth",                               600, NULL },
+  { "ae",                                600, NULL },
+  { "asterisk",                          600, NULL },
+  { "odieresis",                         600, NULL },
+  { "Uacute",                            600, NULL },
+  { "ugrave",                            600, NULL },
+  { "five",                              600, NULL },
+  { "nine",                              600, NULL },
+  { "udieresis",                         600, NULL },
+  { "Zcaron",                            600, NULL },
+  { "threequarters",                     600, NULL },
+  { "guillemotright",                    600, NULL },
+  { "ydieresis",                         600, NULL },
+  { "Ccedilla",                          600, NULL },
+  { "tilde",                             600, NULL },
+  { "at",                                600, NULL },
+  { "eacute",                            600, NULL },
+  { "Gcaron",                            600, NULL },
+  { "underscore",                        600, NULL },
+  { "zero",                              600, NULL },
+  { "multiply",                          600, NULL },
+  { "Scedilla",                          600, NULL },
+  { "eth",                               600, NULL },
+  { "Ograve",                            600, NULL },
+  { "uacute",                            600, NULL },
+  { "braceleft",                         600, NULL },
+  { "Thorn",                             600, NULL },
+  { "zcaron",                            600, NULL },
+  { "ccedilla",                          600, NULL },
+  { "gcaron",                            600, NULL },
+  { "Oacute",                            600, NULL },
+  { "Ocircumflex",                       600, NULL },
+  { "scedilla",                          600, NULL },
+  { "ogonek",                            600, NULL },
+  { "arrowdown",                         600, NULL },
+  { "ograve",                            600, NULL },
+  { "thorn",                             600, NULL },
+  { "degree",                            600, NULL },
+  { "registered",                        600, NULL },
+  { "percent",                           600, NULL },
+  { "Aring",                             600, NULL },
+  { "six",                               600, NULL },
+  { "paragraph",                         600, NULL },
+  { "two",                               600, NULL },
+  { "Igrave",                            600, NULL },
+  { "oacute",                            600, NULL },
+  { "ocircumflex",                       600, NULL },
+  { "asciicircum",                       600, NULL },
+  { "aring",                             600, NULL },
+  { "square",                            600, NULL },
+  { "grave",                             600, NULL },
+  { "bracketright",                      600, NULL },
+  { "ampersand",                         600, NULL },
+  { "Iacute",                            600, NULL },
+  { "igrave",                            600, NULL },
+  { "return",                            600, NULL },
+  { "plus",                              600, NULL },
+  { "quotesinglbase",                    600, NULL },
+  { "Yacute",                            600, NULL },
+  { "threesuperior",                     600, NULL },
+  { "acute",                             600, NULL },
+  { "notegraphic",                       600, NULL },
+  { "section",                           600, NULL },
+  { "arrowleft",                         600, NULL },
+  { "dieresis",                          600, NULL },
+  { "quotedblbase",                      600, NULL },
+  { "iacute",                            600, NULL },
+  { "up",                                600, NULL },
+  { "florin",                            600, NULL },
+  { "yacute",                            600, NULL },
+  { "fi",                                600, NULL },
+  { "fl",                                600, NULL },
+  { "Acircumflex",                       600, NULL },
+  { "Icircumflex",                       600, NULL },
+  { "guillemotleft",                     600, NULL },
+  { "germandbls",                        600, NULL },
+  { "seven",                             600, NULL },
+  { "indent",                            600, NULL },
+  { "prescription",                      600, NULL },
+  { "dectab",                            600, NULL },
+  { "ordmasculine",                      600, NULL },
+  { "dotlessi",                          600, NULL },
+  { "sterling",                          600, NULL },
+  { "IJ",                                600, NULL },
+  { "acircumflex",                       600, NULL },
+  { "overscore",                         600, NULL },
+  { "braceright",                        600, NULL },
+  { "icircumflex",                       600, NULL },
+  { "graybox",                           600, NULL },
+  { "quotedblright",                     600, NULL },
+  { "center",                            600, NULL },
+  { "stop",                              600, NULL },
+  { "cent",                              600, NULL },
+  { "currency",                          600, NULL },
+  { "logicalnot",                        600, NULL },
+  { "Idot",                              600, NULL },
+  { "merge",                             600, NULL },
+  { "Atilde",                            600, NULL },
+  { "breve",                             600, NULL },
+  { "bar",                               600, NULL },
+  { "fraction",                          600, NULL },
+  { "less",                              600, NULL },
+  { "down",                              600, NULL },
+  { "guilsinglleft",                     600, NULL },
+  { "exclam",                            600, NULL },
+  { "period",                            600, NULL },
+  { "arrowright",                        600, NULL },
+  { "format",                            600, NULL },
+  { "greater",                           600, NULL },
+  { "atilde",                            600, NULL },
+  { "ij",                                600, NULL },
+  { "brokenbar",                         600, NULL },
+  { "arrowboth",                         600, NULL },
+  { "quoteleft",                         600, NULL },
+  { "onesuperior",                       600, NULL }
+};
+
+static BuiltinFontWidth courierBoldWidthsTab[] = {
+  { "Ntilde",                            600, NULL },
+  { "comma",                             600, NULL },
+  { "cedilla",                           600, NULL },
+  { "plusminus",                         600, NULL },
+  { "arrowup",                           600, NULL },
+  { "circumflex",                        600, NULL },
+  { "dotaccent",                         600, NULL },
+  { "LL",                                600, NULL },
+  { "asciitilde",                        600, NULL },
+  { "colon",                             600, NULL },
+  { "onehalf",                           600, NULL },
+  { "dollar",                            600, NULL },
+  { "ntilde",                            600, NULL },
+  { "left",                              600, NULL },
+  { "minus",                             600, NULL },
+  { "yen",                               600, NULL },
+  { "space",                             600, NULL },
+  { "questiondown",                      600, NULL },
+  { "emdash",                            600, NULL },
+  { "Agrave",                            600, NULL },
+  { "three",                             600, NULL },
+  { "numbersign",                        600, NULL },
+  { "A",                                 600, NULL },
+  { "B",                                 600, NULL },
+  { "C",                                 600, NULL },
+  { "D",                                 600, NULL },
+  { "E",                                 600, NULL },
+  { "onequarter",                        600, NULL },
+  { "F",                                 600, NULL },
+  { "G",                                 600, NULL },
+  { "H",                                 600, NULL },
+  { "I",                                 600, NULL },
+  { "J",                                 600, NULL },
+  { "K",                                 600, NULL },
+  { "backslash",                         600, NULL },
+  { "L",                                 600, NULL },
+  { "periodcentered",                    600, NULL },
+  { "M",                                 600, NULL },
+  { "N",                                 600, NULL },
+  { "O",                                 600, NULL },
+  { "P",                                 600, NULL },
+  { "Q",                                 600, NULL },
+  { "R",                                 600, NULL },
+  { "Aacute",                            600, NULL },
+  { "caron",                             600, NULL },
+  { "S",                                 600, NULL },
+  { "T",                                 600, NULL },
+  { "U",                                 600, NULL },
+  { "agrave",                            600, NULL },
+  { "V",                                 600, NULL },
+  { "tab",                               600, NULL },
+  { "W",                                 600, NULL },
+  { "ll",                                600, NULL },
+  { "X",                                 600, NULL },
+  { "question",                          600, NULL },
+  { "equal",                             600, NULL },
+  { "Y",                                 600, NULL },
+  { "Z",                                 600, NULL },
+  { "four",                              600, NULL },
+  { "a",                                 600, NULL },
+  { "b",                                 600, NULL },
+  { "c",                                 600, NULL },
+  { "d",                                 600, NULL },
+  { "e",                                 600, NULL },
+  { "f",                                 600, NULL },
+  { "g",                                 600, NULL },
+  { "bullet",                            600, NULL },
+  { "h",                                 600, NULL },
+  { "i",                                 600, NULL },
+  { "Oslash",                            600, NULL },
+  { "dagger",                            600, NULL },
+  { "j",                                 600, NULL },
+  { "k",                                 600, NULL },
+  { "l",                                 600, NULL },
+  { "m",                                 600, NULL },
+  { "n",                                 600, NULL },
+  { "o",                                 600, NULL },
+  { "ordfeminine",                       600, NULL },
+  { "ring",                              600, NULL },
+  { "p",                                 600, NULL },
+  { "q",                                 600, NULL },
+  { "r",                                 600, NULL },
+  { "twosuperior",                       600, NULL },
+  { "largebullet",                       600, NULL },
+  { "aacute",                            600, NULL },
+  { "s",                                 600, NULL },
+  { "OE",                                600, NULL },
+  { "t",                                 600, NULL },
+  { "divide",                            600, NULL },
+  { "u",                                 600, NULL },
+  { "v",                                 600, NULL },
+  { "w",                                 600, NULL },
+  { "x",                                 600, NULL },
+  { "y",                                 600, NULL },
+  { "z",                                 600, NULL },
+  { "hungarumlaut",                      600, NULL },
+  { "quotedbl",                          600, NULL },
+  { "mu",                                600, NULL },
+  { "Scaron",                            600, NULL },
+  { "Lslash",                            600, NULL },
+  { "semicolon",                         600, NULL },
+  { "oslash",                            600, NULL },
+  { "parenright",                        600, NULL },
+  { "Ecircumflex",                       600, NULL },
+  { "trademark",                         600, NULL },
+  { "daggerdbl",                         600, NULL },
+  { "macron",                            600, NULL },
+  { "Otilde",                            600, NULL },
+  { "ellipsis",                          600, NULL },
+  { "scaron",                            600, NULL },
+  { "AE",                                600, NULL },
+  { "Ucircumflex",                       600, NULL },
+  { "lslash",                            600, NULL },
+  { "lira",                              600, NULL },
+  { "quotedblleft",                      600, NULL },
+  { "guilsinglright",                    600, NULL },
+  { "hyphen",                            600, NULL },
+  { "quotesingle",                       600, NULL },
+  { "eight",                             600, NULL },
+  { "exclamdown",                        600, NULL },
+  { "endash",                            600, NULL },
+  { "oe",                                600, NULL },
+  { "ecircumflex",                       600, NULL },
+  { "copyright",                         600, NULL },
+  { "Adieresis",                         600, NULL },
+  { "Egrave",                            600, NULL },
+  { "slash",                             600, NULL },
+  { "Edieresis",                         600, NULL },
+  { "otilde",                            600, NULL },
+  { "Idieresis",                         600, NULL },
+  { "parenleft",                         600, NULL },
+  { "one",                               600, NULL },
+  { "ucircumflex",                       600, NULL },
+  { "Odieresis",                         600, NULL },
+  { "bracketleft",                       600, NULL },
+  { "Ugrave",                            600, NULL },
+  { "quoteright",                        600, NULL },
+  { "Udieresis",                         600, NULL },
+  { "perthousand",                       600, NULL },
+  { "Ydieresis",                         600, NULL },
+  { "Eacute",                            600, NULL },
+  { "adieresis",                         600, NULL },
+  { "egrave",                            600, NULL },
+  { "edieresis",                         600, NULL },
+  { "idieresis",                         600, NULL },
+  { "Eth",                               600, NULL },
+  { "ae",                                600, NULL },
+  { "asterisk",                          600, NULL },
+  { "odieresis",                         600, NULL },
+  { "Uacute",                            600, NULL },
+  { "ugrave",                            600, NULL },
+  { "nine",                              600, NULL },
+  { "five",                              600, NULL },
+  { "udieresis",                         600, NULL },
+  { "Zcaron",                            600, NULL },
+  { "threequarters",                     600, NULL },
+  { "guillemotright",                    600, NULL },
+  { "ydieresis",                         600, NULL },
+  { "Ccedilla",                          600, NULL },
+  { "tilde",                             600, NULL },
+  { "at",                                600, NULL },
+  { "eacute",                            600, NULL },
+  { "Gcaron",                            600, NULL },
+  { "underscore",                        600, NULL },
+  { "multiply",                          600, NULL },
+  { "zero",                              600, NULL },
+  { "eth",                               600, NULL },
+  { "Scedilla",                          600, NULL },
+  { "Ograve",                            600, NULL },
+  { "uacute",                            600, NULL },
+  { "braceleft",                         600, NULL },
+  { "Thorn",                             600, NULL },
+  { "zcaron",                            600, NULL },
+  { "ccedilla",                          600, NULL },
+  { "gcaron",                            600, NULL },
+  { "scedilla",                          600, NULL },
+  { "Ocircumflex",                       600, NULL },
+  { "Oacute",                            600, NULL },
+  { "arrowdown",                         600, NULL },
+  { "ogonek",                            600, NULL },
+  { "ograve",                            600, NULL },
+  { "thorn",                             600, NULL },
+  { "degree",                            600, NULL },
+  { "registered",                        600, NULL },
+  { "Aring",                             600, NULL },
+  { "percent",                           600, NULL },
+  { "six",                               600, NULL },
+  { "paragraph",                         600, NULL },
+  { "two",                               600, NULL },
+  { "Igrave",                            600, NULL },
+  { "ocircumflex",                       600, NULL },
+  { "oacute",                            600, NULL },
+  { "asciicircum",                       600, NULL },
+  { "square",                            600, NULL },
+  { "aring",                             600, NULL },
+  { "grave",                             600, NULL },
+  { "bracketright",                      600, NULL },
+  { "Iacute",                            600, NULL },
+  { "ampersand",                         600, NULL },
+  { "igrave",                            600, NULL },
+  { "return",                            600, NULL },
+  { "plus",                              600, NULL },
+  { "quotesinglbase",                    600, NULL },
+  { "Yacute",                            600, NULL },
+  { "threesuperior",                     600, NULL },
+  { "acute",                             600, NULL },
+  { "notegraphic",                       600, NULL },
+  { "section",                           600, NULL },
+  { "arrowleft",                         600, NULL },
+  { "dieresis",                          600, NULL },
+  { "iacute",                            600, NULL },
+  { "quotedblbase",                      600, NULL },
+  { "up",                                600, NULL },
+  { "florin",                            600, NULL },
+  { "yacute",                            600, NULL },
+  { "fi",                                600, NULL },
+  { "fl",                                600, NULL },
+  { "Acircumflex",                       600, NULL },
+  { "Icircumflex",                       600, NULL },
+  { "guillemotleft",                     600, NULL },
+  { "germandbls",                        600, NULL },
+  { "seven",                             600, NULL },
+  { "prescription",                      600, NULL },
+  { "indent",                            600, NULL },
+  { "dectab",                            600, NULL },
+  { "ordmasculine",                      600, NULL },
+  { "dotlessi",                          600, NULL },
+  { "sterling",                          600, NULL },
+  { "acircumflex",                       600, NULL },
+  { "IJ",                                600, NULL },
+  { "overscore",                         600, NULL },
+  { "icircumflex",                       600, NULL },
+  { "braceright",                        600, NULL },
+  { "graybox",                           600, NULL },
+  { "quotedblright",                     600, NULL },
+  { "center",                            600, NULL },
+  { "stop",                              600, NULL },
+  { "cent",                              600, NULL },
+  { "currency",                          600, NULL },
+  { "logicalnot",                        600, NULL },
+  { "merge",                             600, NULL },
+  { "Idot",                              600, NULL },
+  { "Atilde",                            600, NULL },
+  { "breve",                             600, NULL },
+  { "bar",                               600, NULL },
+  { "fraction",                          600, NULL },
+  { "less",                              600, NULL },
+  { "down",                              600, NULL },
+  { "guilsinglleft",                     600, NULL },
+  { "exclam",                            600, NULL },
+  { "period",                            600, NULL },
+  { "format",                            600, NULL },
+  { "arrowright",                        600, NULL },
+  { "greater",                           600, NULL },
+  { "ij",                                600, NULL },
+  { "atilde",                            600, NULL },
+  { "brokenbar",                         600, NULL },
+  { "arrowboth",                         600, NULL },
+  { "quoteleft",                         600, NULL },
+  { "onesuperior",                       600, NULL }
+};
+
+static BuiltinFontWidth courierBoldObliqueWidthsTab[] = {
+  { "Ntilde",                            600, NULL },
+  { "comma",                             600, NULL },
+  { "cedilla",                           600, NULL },
+  { "plusminus",                         600, NULL },
+  { "arrowup",                           600, NULL },
+  { "circumflex",                        600, NULL },
+  { "dotaccent",                         600, NULL },
+  { "LL",                                600, NULL },
+  { "asciitilde",                        600, NULL },
+  { "colon",                             600, NULL },
+  { "onehalf",                           600, NULL },
+  { "dollar",                            600, NULL },
+  { "ntilde",                            600, NULL },
+  { "left",                              600, NULL },
+  { "minus",                             600, NULL },
+  { "yen",                               600, NULL },
+  { "space",                             600, NULL },
+  { "questiondown",                      600, NULL },
+  { "emdash",                            600, NULL },
+  { "Agrave",                            600, NULL },
+  { "three",                             600, NULL },
+  { "numbersign",                        600, NULL },
+  { "A",                                 600, NULL },
+  { "B",                                 600, NULL },
+  { "C",                                 600, NULL },
+  { "D",                                 600, NULL },
+  { "E",                                 600, NULL },
+  { "onequarter",                        600, NULL },
+  { "F",                                 600, NULL },
+  { "G",                                 600, NULL },
+  { "H",                                 600, NULL },
+  { "I",                                 600, NULL },
+  { "J",                                 600, NULL },
+  { "K",                                 600, NULL },
+  { "backslash",                         600, NULL },
+  { "L",                                 600, NULL },
+  { "periodcentered",                    600, NULL },
+  { "M",                                 600, NULL },
+  { "N",                                 600, NULL },
+  { "O",                                 600, NULL },
+  { "P",                                 600, NULL },
+  { "Q",                                 600, NULL },
+  { "R",                                 600, NULL },
+  { "Aacute",                            600, NULL },
+  { "caron",                             600, NULL },
+  { "S",                                 600, NULL },
+  { "T",                                 600, NULL },
+  { "U",                                 600, NULL },
+  { "agrave",                            600, NULL },
+  { "V",                                 600, NULL },
+  { "tab",                               600, NULL },
+  { "W",                                 600, NULL },
+  { "ll",                                600, NULL },
+  { "X",                                 600, NULL },
+  { "question",                          600, NULL },
+  { "equal",                             600, NULL },
+  { "Y",                                 600, NULL },
+  { "Z",                                 600, NULL },
+  { "four",                              600, NULL },
+  { "a",                                 600, NULL },
+  { "b",                                 600, NULL },
+  { "c",                                 600, NULL },
+  { "d",                                 600, NULL },
+  { "e",                                 600, NULL },
+  { "f",                                 600, NULL },
+  { "g",                                 600, NULL },
+  { "bullet",                            600, NULL },
+  { "h",                                 600, NULL },
+  { "i",                                 600, NULL },
+  { "Oslash",                            600, NULL },
+  { "dagger",                            600, NULL },
+  { "j",                                 600, NULL },
+  { "k",                                 600, NULL },
+  { "l",                                 600, NULL },
+  { "m",                                 600, NULL },
+  { "n",                                 600, NULL },
+  { "o",                                 600, NULL },
+  { "ordfeminine",                       600, NULL },
+  { "ring",                              600, NULL },
+  { "p",                                 600, NULL },
+  { "q",                                 600, NULL },
+  { "r",                                 600, NULL },
+  { "twosuperior",                       600, NULL },
+  { "largebullet",                       600, NULL },
+  { "aacute",                            600, NULL },
+  { "s",                                 600, NULL },
+  { "OE",                                600, NULL },
+  { "t",                                 600, NULL },
+  { "divide",                            600, NULL },
+  { "u",                                 600, NULL },
+  { "v",                                 600, NULL },
+  { "w",                                 600, NULL },
+  { "x",                                 600, NULL },
+  { "y",                                 600, NULL },
+  { "z",                                 600, NULL },
+  { "hungarumlaut",                      600, NULL },
+  { "quotedbl",                          600, NULL },
+  { "mu",                                600, NULL },
+  { "Scaron",                            600, NULL },
+  { "Lslash",                            600, NULL },
+  { "semicolon",                         600, NULL },
+  { "oslash",                            600, NULL },
+  { "parenright",                        600, NULL },
+  { "Ecircumflex",                       600, NULL },
+  { "trademark",                         600, NULL },
+  { "daggerdbl",                         600, NULL },
+  { "macron",                            600, NULL },
+  { "Otilde",                            600, NULL },
+  { "ellipsis",                          600, NULL },
+  { "scaron",                            600, NULL },
+  { "AE",                                600, NULL },
+  { "Ucircumflex",                       600, NULL },
+  { "lslash",                            600, NULL },
+  { "lira",                              600, NULL },
+  { "quotedblleft",                      600, NULL },
+  { "guilsinglright",                    600, NULL },
+  { "hyphen",                            600, NULL },
+  { "quotesingle",                       600, NULL },
+  { "eight",                             600, NULL },
+  { "exclamdown",                        600, NULL },
+  { "endash",                            600, NULL },
+  { "oe",                                600, NULL },
+  { "ecircumflex",                       600, NULL },
+  { "copyright",                         600, NULL },
+  { "Adieresis",                         600, NULL },
+  { "Egrave",                            600, NULL },
+  { "slash",                             600, NULL },
+  { "Edieresis",                         600, NULL },
+  { "otilde",                            600, NULL },
+  { "Idieresis",                         600, NULL },
+  { "parenleft",                         600, NULL },
+  { "one",                               600, NULL },
+  { "ucircumflex",                       600, NULL },
+  { "Odieresis",                         600, NULL },
+  { "bracketleft",                       600, NULL },
+  { "Ugrave",                            600, NULL },
+  { "quoteright",                        600, NULL },
+  { "Udieresis",                         600, NULL },
+  { "perthousand",                       600, NULL },
+  { "Ydieresis",                         600, NULL },
+  { "Eacute",                            600, NULL },
+  { "adieresis",                         600, NULL },
+  { "egrave",                            600, NULL },
+  { "edieresis",                         600, NULL },
+  { "idieresis",                         600, NULL },
+  { "Eth",                               600, NULL },
+  { "ae",                                600, NULL },
+  { "asterisk",                          600, NULL },
+  { "odieresis",                         600, NULL },
+  { "Uacute",                            600, NULL },
+  { "ugrave",                            600, NULL },
+  { "nine",                              600, NULL },
+  { "five",                              600, NULL },
+  { "udieresis",                         600, NULL },
+  { "Zcaron",                            600, NULL },
+  { "threequarters",                     600, NULL },
+  { "guillemotright",                    600, NULL },
+  { "ydieresis",                         600, NULL },
+  { "Ccedilla",                          600, NULL },
+  { "tilde",                             600, NULL },
+  { "at",                                600, NULL },
+  { "eacute",                            600, NULL },
+  { "Gcaron",                            600, NULL },
+  { "underscore",                        600, NULL },
+  { "multiply",                          600, NULL },
+  { "zero",                              600, NULL },
+  { "eth",                               600, NULL },
+  { "Scedilla",                          600, NULL },
+  { "Ograve",                            600, NULL },
+  { "uacute",                            600, NULL },
+  { "braceleft",                         600, NULL },
+  { "Thorn",                             600, NULL },
+  { "zcaron",                            600, NULL },
+  { "ccedilla",                          600, NULL },
+  { "gcaron",                            600, NULL },
+  { "scedilla",                          600, NULL },
+  { "Ocircumflex",                       600, NULL },
+  { "Oacute",                            600, NULL },
+  { "arrowdown",                         600, NULL },
+  { "ogonek",                            600, NULL },
+  { "ograve",                            600, NULL },
+  { "thorn",                             600, NULL },
+  { "degree",                            600, NULL },
+  { "registered",                        600, NULL },
+  { "Aring",                             600, NULL },
+  { "percent",                           600, NULL },
+  { "six",                               600, NULL },
+  { "paragraph",                         600, NULL },
+  { "two",                               600, NULL },
+  { "Igrave",                            600, NULL },
+  { "ocircumflex",                       600, NULL },
+  { "oacute",                            600, NULL },
+  { "asciicircum",                       600, NULL },
+  { "square",                            600, NULL },
+  { "aring",                             600, NULL },
+  { "grave",                             600, NULL },
+  { "bracketright",                      600, NULL },
+  { "Iacute",                            600, NULL },
+  { "ampersand",                         600, NULL },
+  { "igrave",                            600, NULL },
+  { "return",                            600, NULL },
+  { "plus",                              600, NULL },
+  { "quotesinglbase",                    600, NULL },
+  { "Yacute",                            600, NULL },
+  { "threesuperior",                     600, NULL },
+  { "acute",                             600, NULL },
+  { "notegraphic",                       600, NULL },
+  { "section",                           600, NULL },
+  { "arrowleft",                         600, NULL },
+  { "dieresis",                          600, NULL },
+  { "iacute",                            600, NULL },
+  { "quotedblbase",                      600, NULL },
+  { "up",                                600, NULL },
+  { "florin",                            600, NULL },
+  { "yacute",                            600, NULL },
+  { "fi",                                600, NULL },
+  { "fl",                                600, NULL },
+  { "Acircumflex",                       600, NULL },
+  { "Icircumflex",                       600, NULL },
+  { "guillemotleft",                     600, NULL },
+  { "germandbls",                        600, NULL },
+  { "seven",                             600, NULL },
+  { "prescription",                      600, NULL },
+  { "indent",                            600, NULL },
+  { "dectab",                            600, NULL },
+  { "ordmasculine",                      600, NULL },
+  { "dotlessi",                          600, NULL },
+  { "sterling",                          600, NULL },
+  { "acircumflex",                       600, NULL },
+  { "IJ",                                600, NULL },
+  { "overscore",                         600, NULL },
+  { "icircumflex",                       600, NULL },
+  { "braceright",                        600, NULL },
+  { "graybox",                           600, NULL },
+  { "quotedblright",                     600, NULL },
+  { "center",                            600, NULL },
+  { "stop",                              600, NULL },
+  { "cent",                              600, NULL },
+  { "currency",                          600, NULL },
+  { "logicalnot",                        600, NULL },
+  { "merge",                             600, NULL },
+  { "Idot",                              600, NULL },
+  { "Atilde",                            600, NULL },
+  { "breve",                             600, NULL },
+  { "bar",                               600, NULL },
+  { "fraction",                          600, NULL },
+  { "less",                              600, NULL },
+  { "down",                              600, NULL },
+  { "guilsinglleft",                     600, NULL },
+  { "exclam",                            600, NULL },
+  { "period",                            600, NULL },
+  { "format",                            600, NULL },
+  { "arrowright",                        600, NULL },
+  { "greater",                           600, NULL },
+  { "ij",                                600, NULL },
+  { "atilde",                            600, NULL },
+  { "brokenbar",                         600, NULL },
+  { "arrowboth",                         600, NULL },
+  { "quoteleft",                         600, NULL },
+  { "onesuperior",                       600, NULL }
+};
+
+static BuiltinFontWidth courierObliqueWidthsTab[] = {
+  { "Ntilde",                            600, NULL },
+  { "comma",                             600, NULL },
+  { "cedilla",                           600, NULL },
+  { "plusminus",                         600, NULL },
+  { "arrowup",                           600, NULL },
+  { "circumflex",                        600, NULL },
+  { "dotaccent",                         600, NULL },
+  { "LL",                                600, NULL },
+  { "asciitilde",                        600, NULL },
+  { "colon",                             600, NULL },
+  { "onehalf",                           600, NULL },
+  { "dollar",                            600, NULL },
+  { "ntilde",                            600, NULL },
+  { "left",                              600, NULL },
+  { "minus",                             600, NULL },
+  { "yen",                               600, NULL },
+  { "space",                             600, NULL },
+  { "questiondown",                      600, NULL },
+  { "emdash",                            600, NULL },
+  { "Agrave",                            600, NULL },
+  { "three",                             600, NULL },
+  { "numbersign",                        600, NULL },
+  { "A",                                 600, NULL },
+  { "B",                                 600, NULL },
+  { "C",                                 600, NULL },
+  { "D",                                 600, NULL },
+  { "E",                                 600, NULL },
+  { "onequarter",                        600, NULL },
+  { "F",                                 600, NULL },
+  { "G",                                 600, NULL },
+  { "H",                                 600, NULL },
+  { "I",                                 600, NULL },
+  { "J",                                 600, NULL },
+  { "K",                                 600, NULL },
+  { "backslash",                         600, NULL },
+  { "L",                                 600, NULL },
+  { "periodcentered",                    600, NULL },
+  { "M",                                 600, NULL },
+  { "N",                                 600, NULL },
+  { "O",                                 600, NULL },
+  { "P",                                 600, NULL },
+  { "Q",                                 600, NULL },
+  { "R",                                 600, NULL },
+  { "Aacute",                            600, NULL },
+  { "caron",                             600, NULL },
+  { "S",                                 600, NULL },
+  { "T",                                 600, NULL },
+  { "U",                                 600, NULL },
+  { "agrave",                            600, NULL },
+  { "V",                                 600, NULL },
+  { "tab",                               600, NULL },
+  { "W",                                 600, NULL },
+  { "ll",                                600, NULL },
+  { "X",                                 600, NULL },
+  { "question",                          600, NULL },
+  { "equal",                             600, NULL },
+  { "Y",                                 600, NULL },
+  { "Z",                                 600, NULL },
+  { "four",                              600, NULL },
+  { "a",                                 600, NULL },
+  { "b",                                 600, NULL },
+  { "c",                                 600, NULL },
+  { "d",                                 600, NULL },
+  { "e",                                 600, NULL },
+  { "f",                                 600, NULL },
+  { "g",                                 600, NULL },
+  { "bullet",                            600, NULL },
+  { "h",                                 600, NULL },
+  { "i",                                 600, NULL },
+  { "Oslash",                            600, NULL },
+  { "dagger",                            600, NULL },
+  { "j",                                 600, NULL },
+  { "k",                                 600, NULL },
+  { "l",                                 600, NULL },
+  { "m",                                 600, NULL },
+  { "n",                                 600, NULL },
+  { "o",                                 600, NULL },
+  { "ordfeminine",                       600, NULL },
+  { "ring",                              600, NULL },
+  { "p",                                 600, NULL },
+  { "q",                                 600, NULL },
+  { "r",                                 600, NULL },
+  { "twosuperior",                       600, NULL },
+  { "largebullet",                       600, NULL },
+  { "aacute",                            600, NULL },
+  { "s",                                 600, NULL },
+  { "OE",                                600, NULL },
+  { "t",                                 600, NULL },
+  { "divide",                            600, NULL },
+  { "u",                                 600, NULL },
+  { "v",                                 600, NULL },
+  { "w",                                 600, NULL },
+  { "x",                                 600, NULL },
+  { "y",                                 600, NULL },
+  { "z",                                 600, NULL },
+  { "hungarumlaut",                      600, NULL },
+  { "quotedbl",                          600, NULL },
+  { "mu",                                600, NULL },
+  { "Scaron",                            600, NULL },
+  { "Lslash",                            600, NULL },
+  { "semicolon",                         600, NULL },
+  { "oslash",                            600, NULL },
+  { "parenright",                        600, NULL },
+  { "Ecircumflex",                       600, NULL },
+  { "trademark",                         600, NULL },
+  { "daggerdbl",                         600, NULL },
+  { "macron",                            600, NULL },
+  { "Otilde",                            600, NULL },
+  { "ellipsis",                          600, NULL },
+  { "scaron",                            600, NULL },
+  { "AE",                                600, NULL },
+  { "Ucircumflex",                       600, NULL },
+  { "lslash",                            600, NULL },
+  { "lira",                              600, NULL },
+  { "quotedblleft",                      600, NULL },
+  { "guilsinglright",                    600, NULL },
+  { "hyphen",                            600, NULL },
+  { "quotesingle",                       600, NULL },
+  { "eight",                             600, NULL },
+  { "exclamdown",                        600, NULL },
+  { "endash",                            600, NULL },
+  { "oe",                                600, NULL },
+  { "ecircumflex",                       600, NULL },
+  { "copyright",                         600, NULL },
+  { "Adieresis",                         600, NULL },
+  { "Egrave",                            600, NULL },
+  { "slash",                             600, NULL },
+  { "Edieresis",                         600, NULL },
+  { "otilde",                            600, NULL },
+  { "Idieresis",                         600, NULL },
+  { "parenleft",                         600, NULL },
+  { "one",                               600, NULL },
+  { "ucircumflex",                       600, NULL },
+  { "Odieresis",                         600, NULL },
+  { "bracketleft",                       600, NULL },
+  { "Ugrave",                            600, NULL },
+  { "quoteright",                        600, NULL },
+  { "Udieresis",                         600, NULL },
+  { "perthousand",                       600, NULL },
+  { "Ydieresis",                         600, NULL },
+  { "Eacute",                            600, NULL },
+  { "adieresis",                         600, NULL },
+  { "egrave",                            600, NULL },
+  { "edieresis",                         600, NULL },
+  { "idieresis",                         600, NULL },
+  { "Eth",                               600, NULL },
+  { "ae",                                600, NULL },
+  { "asterisk",                          600, NULL },
+  { "odieresis",                         600, NULL },
+  { "Uacute",                            600, NULL },
+  { "ugrave",                            600, NULL },
+  { "nine",                              600, NULL },
+  { "five",                              600, NULL },
+  { "udieresis",                         600, NULL },
+  { "Zcaron",                            600, NULL },
+  { "threequarters",                     600, NULL },
+  { "guillemotright",                    600, NULL },
+  { "ydieresis",                         600, NULL },
+  { "Ccedilla",                          600, NULL },
+  { "tilde",                             600, NULL },
+  { "at",                                600, NULL },
+  { "eacute",                            600, NULL },
+  { "Gcaron",                            600, NULL },
+  { "underscore",                        600, NULL },
+  { "multiply",                          600, NULL },
+  { "zero",                              600, NULL },
+  { "eth",                               600, NULL },
+  { "Scedilla",                          600, NULL },
+  { "Ograve",                            600, NULL },
+  { "uacute",                            600, NULL },
+  { "braceleft",                         600, NULL },
+  { "Thorn",                             600, NULL },
+  { "zcaron",                            600, NULL },
+  { "ccedilla",                          600, NULL },
+  { "gcaron",                            600, NULL },
+  { "scedilla",                          600, NULL },
+  { "Ocircumflex",                       600, NULL },
+  { "Oacute",                            600, NULL },
+  { "arrowdown",                         600, NULL },
+  { "ogonek",                            600, NULL },
+  { "ograve",                            600, NULL },
+  { "thorn",                             600, NULL },
+  { "degree",                            600, NULL },
+  { "registered",                        600, NULL },
+  { "Aring",                             600, NULL },
+  { "percent",                           600, NULL },
+  { "six",                               600, NULL },
+  { "paragraph",                         600, NULL },
+  { "two",                               600, NULL },
+  { "Igrave",                            600, NULL },
+  { "ocircumflex",                       600, NULL },
+  { "oacute",                            600, NULL },
+  { "asciicircum",                       600, NULL },
+  { "square",                            600, NULL },
+  { "aring",                             600, NULL },
+  { "grave",                             600, NULL },
+  { "bracketright",                      600, NULL },
+  { "Iacute",                            600, NULL },
+  { "ampersand",                         600, NULL },
+  { "igrave",                            600, NULL },
+  { "return",                            600, NULL },
+  { "plus",                              600, NULL },
+  { "quotesinglbase",                    600, NULL },
+  { "Yacute",                            600, NULL },
+  { "threesuperior",                     600, NULL },
+  { "acute",                             600, NULL },
+  { "notegraphic",                       600, NULL },
+  { "section",                           600, NULL },
+  { "arrowleft",                         600, NULL },
+  { "dieresis",                          600, NULL },
+  { "iacute",                            600, NULL },
+  { "quotedblbase",                      600, NULL },
+  { "up",                                600, NULL },
+  { "florin",                            600, NULL },
+  { "yacute",                            600, NULL },
+  { "fi",                                600, NULL },
+  { "fl",                                600, NULL },
+  { "Acircumflex",                       600, NULL },
+  { "Icircumflex",                       600, NULL },
+  { "guillemotleft",                     600, NULL },
+  { "germandbls",                        600, NULL },
+  { "seven",                             600, NULL },
+  { "prescription",                      600, NULL },
+  { "indent",                            600, NULL },
+  { "dectab",                            600, NULL },
+  { "ordmasculine",                      600, NULL },
+  { "dotlessi",                          600, NULL },
+  { "sterling",                          600, NULL },
+  { "acircumflex",                       600, NULL },
+  { "IJ",                                600, NULL },
+  { "overscore",                         600, NULL },
+  { "icircumflex",                       600, NULL },
+  { "braceright",                        600, NULL },
+  { "graybox",                           600, NULL },
+  { "quotedblright",                     600, NULL },
+  { "center",                            600, NULL },
+  { "stop",                              600, NULL },
+  { "cent",                              600, NULL },
+  { "currency",                          600, NULL },
+  { "logicalnot",                        600, NULL },
+  { "merge",                             600, NULL },
+  { "Idot",                              600, NULL },
+  { "Atilde",                            600, NULL },
+  { "breve",                             600, NULL },
+  { "bar",                               600, NULL },
+  { "fraction",                          600, NULL },
+  { "less",                              600, NULL },
+  { "down",                              600, NULL },
+  { "guilsinglleft",                     600, NULL },
+  { "exclam",                            600, NULL },
+  { "period",                            600, NULL },
+  { "format",                            600, NULL },
+  { "arrowright",                        600, NULL },
+  { "greater",                           600, NULL },
+  { "ij",                                600, NULL },
+  { "atilde",                            600, NULL },
+  { "brokenbar",                         600, NULL },
+  { "arrowboth",                         600, NULL },
+  { "quoteleft",                         600, NULL },
+  { "onesuperior",                       600, NULL }
+};
+
+static BuiltinFontWidth helveticaWidthsTab[] = {
+  { "Ntilde",                            722, NULL },
+  { "comma",                             278, NULL },
+  { "cedilla",                           333, NULL },
+  { "plusminus",                         584, NULL },
+  { "circumflex",                        333, NULL },
+  { "dotaccent",                         333, NULL },
+  { "asciitilde",                        584, NULL },
+  { "colon",                             278, NULL },
+  { "onehalf",                           834, NULL },
+  { "dollar",                            556, NULL },
+  { "ntilde",                            556, NULL },
+  { "minus",                             584, NULL },
+  { "yen",                               556, NULL },
+  { "space",                             278, NULL },
+  { "questiondown",                      611, NULL },
+  { "emdash",                           1000, NULL },
+  { "Agrave",                            667, NULL },
+  { "three",                             556, NULL },
+  { "numbersign",                        556, NULL },
+  { "A",                                 667, NULL },
+  { "B",                                 667, NULL },
+  { "C",                                 722, NULL },
+  { "D",                                 722, NULL },
+  { "E",                                 667, NULL },
+  { "onequarter",                        834, NULL },
+  { "F",                                 611, NULL },
+  { "G",                                 778, NULL },
+  { "H",                                 722, NULL },
+  { "I",                                 278, NULL },
+  { "J",                                 500, NULL },
+  { "K",                                 667, NULL },
+  { "backslash",                         278, NULL },
+  { "L",                                 556, NULL },
+  { "periodcentered",                    278, NULL },
+  { "M",                                 833, NULL },
+  { "N",                                 722, NULL },
+  { "O",                                 778, NULL },
+  { "P",                                 667, NULL },
+  { "Q",                                 778, NULL },
+  { "R",                                 722, NULL },
+  { "Aacute",                            667, NULL },
+  { "caron",                             333, NULL },
+  { "S",                                 667, NULL },
+  { "T",                                 611, NULL },
+  { "U",                                 722, NULL },
+  { "agrave",                            556, NULL },
+  { "V",                                 667, NULL },
+  { "W",                                 944, NULL },
+  { "X",                                 667, NULL },
+  { "question",                          556, NULL },
+  { "equal",                             584, NULL },
+  { "Y",                                 667, NULL },
+  { "Z",                                 611, NULL },
+  { "four",                              556, NULL },
+  { "a",                                 556, NULL },
+  { "b",                                 556, NULL },
+  { "c",                                 500, NULL },
+  { "d",                                 556, NULL },
+  { "e",                                 556, NULL },
+  { "f",                                 278, NULL },
+  { "g",                                 556, NULL },
+  { "bullet",                            350, NULL },
+  { "h",                                 556, NULL },
+  { "i",                                 222, NULL },
+  { "Oslash",                            778, NULL },
+  { "dagger",                            556, NULL },
+  { "j",                                 222, NULL },
+  { "k",                                 500, NULL },
+  { "l",                                 222, NULL },
+  { "m",                                 833, NULL },
+  { "n",                                 556, NULL },
+  { "o",                                 556, NULL },
+  { "ordfeminine",                       370, NULL },
+  { "ring",                              333, NULL },
+  { "p",                                 556, NULL },
+  { "q",                                 556, NULL },
+  { "r",                                 333, NULL },
+  { "twosuperior",                       333, NULL },
+  { "aacute",                            556, NULL },
+  { "s",                                 500, NULL },
+  { "OE",                               1000, NULL },
+  { "t",                                 278, NULL },
+  { "divide",                            584, NULL },
+  { "u",                                 556, NULL },
+  { "v",                                 500, NULL },
+  { "w",                                 722, NULL },
+  { "x",                                 500, NULL },
+  { "y",                                 500, NULL },
+  { "z",                                 500, NULL },
+  { "hungarumlaut",                      333, NULL },
+  { "quotedbl",                          355, NULL },
+  { "mu",                                556, NULL },
+  { "Scaron",                            667, NULL },
+  { "Lslash",                            556, NULL },
+  { "semicolon",                         278, NULL },
+  { "oslash",                            611, NULL },
+  { "parenright",                        333, NULL },
+  { "Ecircumflex",                       667, NULL },
+  { "trademark",                        1000, NULL },
+  { "daggerdbl",                         556, NULL },
+  { "macron",                            333, NULL },
+  { "Otilde",                            778, NULL },
+  { "ellipsis",                         1000, NULL },
+  { "scaron",                            500, NULL },
+  { "AE",                               1000, NULL },
+  { "Ucircumflex",                       722, NULL },
+  { "lslash",                            222, NULL },
+  { "quotedblleft",                      333, NULL },
+  { "guilsinglright",                    333, NULL },
+  { "hyphen",                            333, NULL },
+  { "quotesingle",                       191, NULL },
+  { "eight",                             556, NULL },
+  { "exclamdown",                        333, NULL },
+  { "endash",                            556, NULL },
+  { "oe",                                944, NULL },
+  { "ecircumflex",                       556, NULL },
+  { "copyright",                         737, NULL },
+  { "Adieresis",                         667, NULL },
+  { "Egrave",                            667, NULL },
+  { "slash",                             278, NULL },
+  { "Edieresis",                         667, NULL },
+  { "otilde",                            556, NULL },
+  { "Idieresis",                         278, NULL },
+  { "parenleft",                         333, NULL },
+  { "one",                               556, NULL },
+  { "ucircumflex",                       556, NULL },
+  { "Odieresis",                         778, NULL },
+  { "bracketleft",                       278, NULL },
+  { "Ugrave",                            722, NULL },
+  { "quoteright",                        222, NULL },
+  { "Udieresis",                         722, NULL },
+  { "perthousand",                      1000, NULL },
+  { "Ydieresis",                         667, NULL },
+  { "Eacute",                            667, NULL },
+  { "adieresis",                         556, NULL },
+  { "egrave",                            556, NULL },
+  { "edieresis",                         556, NULL },
+  { "idieresis",                         278, NULL },
+  { "Eth",                               722, NULL },
+  { "ae",                                889, NULL },
+  { "asterisk",                          389, NULL },
+  { "odieresis",                         556, NULL },
+  { "Uacute",                            722, NULL },
+  { "ugrave",                            556, NULL },
+  { "nine",                              556, NULL },
+  { "five",                              556, NULL },
+  { "udieresis",                         556, NULL },
+  { "Zcaron",                            611, NULL },
+  { "threequarters",                     834, NULL },
+  { "guillemotright",                    556, NULL },
+  { "ydieresis",                         500, NULL },
+  { "Ccedilla",                          722, NULL },
+  { "tilde",                             333, NULL },
+  { "at",                               1015, NULL },
+  { "eacute",                            556, NULL },
+  { "underscore",                        556, NULL },
+  { "multiply",                          584, NULL },
+  { "zero",                              556, NULL },
+  { "eth",                               556, NULL },
+  { "Ograve",                            778, NULL },
+  { "uacute",                            556, NULL },
+  { "braceleft",                         334, NULL },
+  { "Thorn",                             667, NULL },
+  { "zcaron",                            500, NULL },
+  { "ccedilla",                          500, NULL },
+  { "Ocircumflex",                       778, NULL },
+  { "Oacute",                            778, NULL },
+  { "ogonek",                            333, NULL },
+  { "ograve",                            556, NULL },
+  { "thorn",                             556, NULL },
+  { "degree",                            400, NULL },
+  { "registered",                        737, NULL },
+  { "Aring",                             667, NULL },
+  { "percent",                           889, NULL },
+  { "six",                               556, NULL },
+  { "paragraph",                         537, NULL },
+  { "two",                               556, NULL },
+  { "Igrave",                            278, NULL },
+  { "ocircumflex",                       556, NULL },
+  { "oacute",                            556, NULL },
+  { "asciicircum",                       469, NULL },
+  { "aring",                             556, NULL },
+  { "grave",                             333, NULL },
+  { "bracketright",                      278, NULL },
+  { "Iacute",                            278, NULL },
+  { "ampersand",                         667, NULL },
+  { "igrave",                            278, NULL },
+  { "plus",                              584, NULL },
+  { "quotesinglbase",                    222, NULL },
+  { "Yacute",                            667, NULL },
+  { "threesuperior",                     333, NULL },
+  { "acute",                             333, NULL },
+  { "section",                           556, NULL },
+  { "dieresis",                          333, NULL },
+  { "iacute",                            278, NULL },
+  { "quotedblbase",                      333, NULL },
+  { "florin",                            556, NULL },
+  { "yacute",                            500, NULL },
+  { "fi",                                500, NULL },
+  { "fl",                                500, NULL },
+  { "Acircumflex",                       667, NULL },
+  { "Icircumflex",                       278, NULL },
+  { "guillemotleft",                     556, NULL },
+  { "germandbls",                        611, NULL },
+  { "seven",                             556, NULL },
+  { "ordmasculine",                      365, NULL },
+  { "dotlessi",                          278, NULL },
+  { "sterling",                          556, NULL },
+  { "acircumflex",                       556, NULL },
+  { "icircumflex",                       278, NULL },
+  { "braceright",                        334, NULL },
+  { "quotedblright",                     333, NULL },
+  { "cent",                              556, NULL },
+  { "currency",                          556, NULL },
+  { "logicalnot",                        584, NULL },
+  { "Atilde",                            667, NULL },
+  { "breve",                             333, NULL },
+  { "bar",                               260, NULL },
+  { "fraction",                          167, NULL },
+  { "less",                              584, NULL },
+  { "guilsinglleft",                     333, NULL },
+  { "exclam",                            278, NULL },
+  { "period",                            278, NULL },
+  { "greater",                           584, NULL },
+  { "atilde",                            556, NULL },
+  { "brokenbar",                         260, NULL },
+  { "quoteleft",                         222, NULL },
+  { "onesuperior",                       333, NULL }
+};
+
+static BuiltinFontWidth helveticaBoldWidthsTab[] = {
+  { "Ntilde",                            722, NULL },
+  { "comma",                             278, NULL },
+  { "cedilla",                           333, NULL },
+  { "plusminus",                         584, NULL },
+  { "circumflex",                        333, NULL },
+  { "dotaccent",                         333, NULL },
+  { "asciitilde",                        584, NULL },
+  { "colon",                             333, NULL },
+  { "onehalf",                           834, NULL },
+  { "dollar",                            556, NULL },
+  { "ntilde",                            611, NULL },
+  { "minus",                             584, NULL },
+  { "yen",                               556, NULL },
+  { "space",                             278, NULL },
+  { "questiondown",                      611, NULL },
+  { "emdash",                           1000, NULL },
+  { "Agrave",                            722, NULL },
+  { "three",                             556, NULL },
+  { "numbersign",                        556, NULL },
+  { "A",                                 722, NULL },
+  { "B",                                 722, NULL },
+  { "C",                                 722, NULL },
+  { "D",                                 722, NULL },
+  { "E",                                 667, NULL },
+  { "onequarter",                        834, NULL },
+  { "F",                                 611, NULL },
+  { "G",                                 778, NULL },
+  { "H",                                 722, NULL },
+  { "I",                                 278, NULL },
+  { "J",                                 556, NULL },
+  { "K",                                 722, NULL },
+  { "backslash",                         278, NULL },
+  { "L",                                 611, NULL },
+  { "periodcentered",                    278, NULL },
+  { "M",                                 833, NULL },
+  { "N",                                 722, NULL },
+  { "O",                                 778, NULL },
+  { "P",                                 667, NULL },
+  { "Q",                                 778, NULL },
+  { "R",                                 722, NULL },
+  { "Aacute",                            722, NULL },
+  { "caron",                             333, NULL },
+  { "S",                                 667, NULL },
+  { "T",                                 611, NULL },
+  { "U",                                 722, NULL },
+  { "agrave",                            556, NULL },
+  { "V",                                 667, NULL },
+  { "W",                                 944, NULL },
+  { "X",                                 667, NULL },
+  { "question",                          611, NULL },
+  { "equal",                             584, NULL },
+  { "Y",                                 667, NULL },
+  { "Z",                                 611, NULL },
+  { "four",                              556, NULL },
+  { "a",                                 556, NULL },
+  { "b",                                 611, NULL },
+  { "c",                                 556, NULL },
+  { "d",                                 611, NULL },
+  { "e",                                 556, NULL },
+  { "f",                                 333, NULL },
+  { "g",                                 611, NULL },
+  { "bullet",                            350, NULL },
+  { "h",                                 611, NULL },
+  { "i",                                 278, NULL },
+  { "Oslash",                            778, NULL },
+  { "dagger",                            556, NULL },
+  { "j",                                 278, NULL },
+  { "k",                                 556, NULL },
+  { "l",                                 278, NULL },
+  { "m",                                 889, NULL },
+  { "n",                                 611, NULL },
+  { "o",                                 611, NULL },
+  { "ordfeminine",                       370, NULL },
+  { "ring",                              333, NULL },
+  { "p",                                 611, NULL },
+  { "q",                                 611, NULL },
+  { "r",                                 389, NULL },
+  { "twosuperior",                       333, NULL },
+  { "aacute",                            556, NULL },
+  { "s",                                 556, NULL },
+  { "OE",                               1000, NULL },
+  { "t",                                 333, NULL },
+  { "divide",                            584, NULL },
+  { "u",                                 611, NULL },
+  { "v",                                 556, NULL },
+  { "w",                                 778, NULL },
+  { "x",                                 556, NULL },
+  { "y",                                 556, NULL },
+  { "z",                                 500, NULL },
+  { "hungarumlaut",                      333, NULL },
+  { "quotedbl",                          474, NULL },
+  { "mu",                                611, NULL },
+  { "Scaron",                            667, NULL },
+  { "Lslash",                            611, NULL },
+  { "semicolon",                         333, NULL },
+  { "oslash",                            611, NULL },
+  { "parenright",                        333, NULL },
+  { "Ecircumflex",                       667, NULL },
+  { "trademark",                        1000, NULL },
+  { "daggerdbl",                         556, NULL },
+  { "macron",                            333, NULL },
+  { "Otilde",                            778, NULL },
+  { "ellipsis",                         1000, NULL },
+  { "scaron",                            556, NULL },
+  { "AE",                               1000, NULL },
+  { "Ucircumflex",                       722, NULL },
+  { "lslash",                            278, NULL },
+  { "quotedblleft",                      500, NULL },
+  { "guilsinglright",                    333, NULL },
+  { "hyphen",                            333, NULL },
+  { "quotesingle",                       238, NULL },
+  { "eight",                             556, NULL },
+  { "exclamdown",                        333, NULL },
+  { "endash",                            556, NULL },
+  { "oe",                                944, NULL },
+  { "ecircumflex",                       556, NULL },
+  { "copyright",                         737, NULL },
+  { "Adieresis",                         722, NULL },
+  { "Egrave",                            667, NULL },
+  { "slash",                             278, NULL },
+  { "Edieresis",                         667, NULL },
+  { "otilde",                            611, NULL },
+  { "Idieresis",                         278, NULL },
+  { "parenleft",                         333, NULL },
+  { "one",                               556, NULL },
+  { "ucircumflex",                       611, NULL },
+  { "Odieresis",                         778, NULL },
+  { "bracketleft",                       333, NULL },
+  { "Ugrave",                            722, NULL },
+  { "quoteright",                        278, NULL },
+  { "Udieresis",                         722, NULL },
+  { "perthousand",                      1000, NULL },
+  { "Ydieresis",                         667, NULL },
+  { "Eacute",                            667, NULL },
+  { "adieresis",                         556, NULL },
+  { "egrave",                            556, NULL },
+  { "edieresis",                         556, NULL },
+  { "idieresis",                         278, NULL },
+  { "Eth",                               722, NULL },
+  { "ae",                                889, NULL },
+  { "asterisk",                          389, NULL },
+  { "odieresis",                         611, NULL },
+  { "Uacute",                            722, NULL },
+  { "ugrave",                            611, NULL },
+  { "nine",                              556, NULL },
+  { "five",                              556, NULL },
+  { "udieresis",                         611, NULL },
+  { "Zcaron",                            611, NULL },
+  { "threequarters",                     834, NULL },
+  { "guillemotright",                    556, NULL },
+  { "ydieresis",                         556, NULL },
+  { "Ccedilla",                          722, NULL },
+  { "tilde",                             333, NULL },
+  { "at",                                975, NULL },
+  { "eacute",                            556, NULL },
+  { "underscore",                        556, NULL },
+  { "multiply",                          584, NULL },
+  { "zero",                              556, NULL },
+  { "eth",                               611, NULL },
+  { "Ograve",                            778, NULL },
+  { "uacute",                            611, NULL },
+  { "braceleft",                         389, NULL },
+  { "Thorn",                             667, NULL },
+  { "zcaron",                            500, NULL },
+  { "ccedilla",                          556, NULL },
+  { "Ocircumflex",                       778, NULL },
+  { "Oacute",                            778, NULL },
+  { "ogonek",                            333, NULL },
+  { "ograve",                            611, NULL },
+  { "thorn",                             611, NULL },
+  { "degree",                            400, NULL },
+  { "registered",                        737, NULL },
+  { "Aring",                             722, NULL },
+  { "percent",                           889, NULL },
+  { "six",                               556, NULL },
+  { "paragraph",                         556, NULL },
+  { "two",                               556, NULL },
+  { "Igrave",                            278, NULL },
+  { "ocircumflex",                       611, NULL },
+  { "oacute",                            611, NULL },
+  { "asciicircum",                       584, NULL },
+  { "aring",                             556, NULL },
+  { "grave",                             333, NULL },
+  { "bracketright",                      333, NULL },
+  { "Iacute",                            278, NULL },
+  { "ampersand",                         722, NULL },
+  { "igrave",                            278, NULL },
+  { "plus",                              584, NULL },
+  { "quotesinglbase",                    278, NULL },
+  { "Yacute",                            667, NULL },
+  { "threesuperior",                     333, NULL },
+  { "acute",                             333, NULL },
+  { "section",                           556, NULL },
+  { "dieresis",                          333, NULL },
+  { "iacute",                            278, NULL },
+  { "quotedblbase",                      500, NULL },
+  { "florin",                            556, NULL },
+  { "yacute",                            556, NULL },
+  { "fi",                                611, NULL },
+  { "fl",                                611, NULL },
+  { "Acircumflex",                       722, NULL },
+  { "Icircumflex",                       278, NULL },
+  { "guillemotleft",                     556, NULL },
+  { "germandbls",                        611, NULL },
+  { "seven",                             556, NULL },
+  { "ordmasculine",                      365, NULL },
+  { "dotlessi",                          278, NULL },
+  { "sterling",                          556, NULL },
+  { "acircumflex",                       556, NULL },
+  { "icircumflex",                       278, NULL },
+  { "braceright",                        389, NULL },
+  { "quotedblright",                     500, NULL },
+  { "cent",                              556, NULL },
+  { "currency",                          556, NULL },
+  { "logicalnot",                        584, NULL },
+  { "Atilde",                            722, NULL },
+  { "breve",                             333, NULL },
+  { "bar",                               280, NULL },
+  { "fraction",                          167, NULL },
+  { "less",                              584, NULL },
+  { "guilsinglleft",                     333, NULL },
+  { "exclam",                            333, NULL },
+  { "period",                            278, NULL },
+  { "greater",                           584, NULL },
+  { "atilde",                            556, NULL },
+  { "brokenbar",                         280, NULL },
+  { "quoteleft",                         278, NULL },
+  { "onesuperior",                       333, NULL }
+};
+
+static BuiltinFontWidth helveticaBoldObliqueWidthsTab[] = {
+  { "Ntilde",                            722, NULL },
+  { "comma",                             278, NULL },
+  { "cedilla",                           333, NULL },
+  { "plusminus",                         584, NULL },
+  { "circumflex",                        333, NULL },
+  { "dotaccent",                         333, NULL },
+  { "asciitilde",                        584, NULL },
+  { "colon",                             333, NULL },
+  { "onehalf",                           834, NULL },
+  { "dollar",                            556, NULL },
+  { "ntilde",                            611, NULL },
+  { "minus",                             584, NULL },
+  { "yen",                               556, NULL },
+  { "space",                             278, NULL },
+  { "questiondown",                      611, NULL },
+  { "emdash",                           1000, NULL },
+  { "Agrave",                            722, NULL },
+  { "three",                             556, NULL },
+  { "numbersign",                        556, NULL },
+  { "A",                                 722, NULL },
+  { "B",                                 722, NULL },
+  { "C",                                 722, NULL },
+  { "D",                                 722, NULL },
+  { "E",                                 667, NULL },
+  { "onequarter",                        834, NULL },
+  { "F",                                 611, NULL },
+  { "G",                                 778, NULL },
+  { "H",                                 722, NULL },
+  { "I",                                 278, NULL },
+  { "J",                                 556, NULL },
+  { "K",                                 722, NULL },
+  { "backslash",                         278, NULL },
+  { "L",                                 611, NULL },
+  { "periodcentered",                    278, NULL },
+  { "M",                                 833, NULL },
+  { "N",                                 722, NULL },
+  { "O",                                 778, NULL },
+  { "P",                                 667, NULL },
+  { "Q",                                 778, NULL },
+  { "R",                                 722, NULL },
+  { "Aacute",                            722, NULL },
+  { "caron",                             333, NULL },
+  { "S",                                 667, NULL },
+  { "T",                                 611, NULL },
+  { "U",                                 722, NULL },
+  { "agrave",                            556, NULL },
+  { "V",                                 667, NULL },
+  { "W",                                 944, NULL },
+  { "X",                                 667, NULL },
+  { "question",                          611, NULL },
+  { "equal",                             584, NULL },
+  { "Y",                                 667, NULL },
+  { "Z",                                 611, NULL },
+  { "four",                              556, NULL },
+  { "a",                                 556, NULL },
+  { "b",                                 611, NULL },
+  { "c",                                 556, NULL },
+  { "d",                                 611, NULL },
+  { "e",                                 556, NULL },
+  { "f",                                 333, NULL },
+  { "g",                                 611, NULL },
+  { "bullet",                            350, NULL },
+  { "h",                                 611, NULL },
+  { "i",                                 278, NULL },
+  { "Oslash",                            778, NULL },
+  { "dagger",                            556, NULL },
+  { "j",                                 278, NULL },
+  { "k",                                 556, NULL },
+  { "l",                                 278, NULL },
+  { "m",                                 889, NULL },
+  { "n",                                 611, NULL },
+  { "o",                                 611, NULL },
+  { "ordfeminine",                       370, NULL },
+  { "ring",                              333, NULL },
+  { "p",                                 611, NULL },
+  { "q",                                 611, NULL },
+  { "r",                                 389, NULL },
+  { "twosuperior",                       333, NULL },
+  { "aacute",                            556, NULL },
+  { "s",                                 556, NULL },
+  { "OE",                               1000, NULL },
+  { "t",                                 333, NULL },
+  { "divide",                            584, NULL },
+  { "u",                                 611, NULL },
+  { "v",                                 556, NULL },
+  { "w",                                 778, NULL },
+  { "x",                                 556, NULL },
+  { "y",                                 556, NULL },
+  { "z",                                 500, NULL },
+  { "hungarumlaut",                      333, NULL },
+  { "quotedbl",                          474, NULL },
+  { "mu",                                611, NULL },
+  { "Scaron",                            667, NULL },
+  { "Lslash",                            611, NULL },
+  { "semicolon",                         333, NULL },
+  { "oslash",                            611, NULL },
+  { "parenright",                        333, NULL },
+  { "Ecircumflex",                       667, NULL },
+  { "trademark",                        1000, NULL },
+  { "daggerdbl",                         556, NULL },
+  { "macron",                            333, NULL },
+  { "Otilde",                            778, NULL },
+  { "ellipsis",                         1000, NULL },
+  { "scaron",                            556, NULL },
+  { "AE",                               1000, NULL },
+  { "Ucircumflex",                       722, NULL },
+  { "lslash",                            278, NULL },
+  { "quotedblleft",                      500, NULL },
+  { "guilsinglright",                    333, NULL },
+  { "hyphen",                            333, NULL },
+  { "quotesingle",                       238, NULL },
+  { "eight",                             556, NULL },
+  { "exclamdown",                        333, NULL },
+  { "endash",                            556, NULL },
+  { "oe",                                944, NULL },
+  { "ecircumflex",                       556, NULL },
+  { "copyright",                         737, NULL },
+  { "Adieresis",                         722, NULL },
+  { "Egrave",                            667, NULL },
+  { "slash",                             278, NULL },
+  { "Edieresis",                         667, NULL },
+  { "otilde",                            611, NULL },
+  { "Idieresis",                         278, NULL },
+  { "parenleft",                         333, NULL },
+  { "one",                               556, NULL },
+  { "ucircumflex",                       611, NULL },
+  { "Odieresis",                         778, NULL },
+  { "bracketleft",                       333, NULL },
+  { "Ugrave",                            722, NULL },
+  { "quoteright",                        278, NULL },
+  { "Udieresis",                         722, NULL },
+  { "perthousand",                      1000, NULL },
+  { "Ydieresis",                         667, NULL },
+  { "Eacute",                            667, NULL },
+  { "adieresis",                         556, NULL },
+  { "egrave",                            556, NULL },
+  { "edieresis",                         556, NULL },
+  { "idieresis",                         278, NULL },
+  { "Eth",                               722, NULL },
+  { "ae",                                889, NULL },
+  { "asterisk",                          389, NULL },
+  { "odieresis",                         611, NULL },
+  { "Uacute",                            722, NULL },
+  { "ugrave",                            611, NULL },
+  { "nine",                              556, NULL },
+  { "five",                              556, NULL },
+  { "udieresis",                         611, NULL },
+  { "Zcaron",                            611, NULL },
+  { "threequarters",                     834, NULL },
+  { "guillemotright",                    556, NULL },
+  { "ydieresis",                         556, NULL },
+  { "Ccedilla",                          722, NULL },
+  { "tilde",                             333, NULL },
+  { "at",                                975, NULL },
+  { "eacute",                            556, NULL },
+  { "underscore",                        556, NULL },
+  { "multiply",                          584, NULL },
+  { "zero",                              556, NULL },
+  { "eth",                               611, NULL },
+  { "Ograve",                            778, NULL },
+  { "uacute",                            611, NULL },
+  { "braceleft",                         389, NULL },
+  { "Thorn",                             667, NULL },
+  { "zcaron",                            500, NULL },
+  { "ccedilla",                          556, NULL },
+  { "Ocircumflex",                       778, NULL },
+  { "Oacute",                            778, NULL },
+  { "ogonek",                            333, NULL },
+  { "ograve",                            611, NULL },
+  { "thorn",                             611, NULL },
+  { "degree",                            400, NULL },
+  { "registered",                        737, NULL },
+  { "Aring",                             722, NULL },
+  { "percent",                           889, NULL },
+  { "six",                               556, NULL },
+  { "paragraph",                         556, NULL },
+  { "two",                               556, NULL },
+  { "Igrave",                            278, NULL },
+  { "ocircumflex",                       611, NULL },
+  { "oacute",                            611, NULL },
+  { "asciicircum",                       584, NULL },
+  { "aring",                             556, NULL },
+  { "grave",                             333, NULL },
+  { "bracketright",                      333, NULL },
+  { "Iacute",                            278, NULL },
+  { "ampersand",                         722, NULL },
+  { "igrave",                            278, NULL },
+  { "plus",                              584, NULL },
+  { "quotesinglbase",                    278, NULL },
+  { "Yacute",                            667, NULL },
+  { "threesuperior",                     333, NULL },
+  { "acute",                             333, NULL },
+  { "section",                           556, NULL },
+  { "dieresis",                          333, NULL },
+  { "iacute",                            278, NULL },
+  { "quotedblbase",                      500, NULL },
+  { "florin",                            556, NULL },
+  { "yacute",                            556, NULL },
+  { "fi",                                611, NULL },
+  { "fl",                                611, NULL },
+  { "Acircumflex",                       722, NULL },
+  { "Icircumflex",                       278, NULL },
+  { "guillemotleft",                     556, NULL },
+  { "germandbls",                        611, NULL },
+  { "seven",                             556, NULL },
+  { "ordmasculine",                      365, NULL },
+  { "dotlessi",                          278, NULL },
+  { "sterling",                          556, NULL },
+  { "acircumflex",                       556, NULL },
+  { "icircumflex",                       278, NULL },
+  { "braceright",                        389, NULL },
+  { "quotedblright",                     500, NULL },
+  { "cent",                              556, NULL },
+  { "currency",                          556, NULL },
+  { "logicalnot",                        584, NULL },
+  { "Atilde",                            722, NULL },
+  { "breve",                             333, NULL },
+  { "bar",                               280, NULL },
+  { "fraction",                          167, NULL },
+  { "less",                              584, NULL },
+  { "guilsinglleft",                     333, NULL },
+  { "exclam",                            333, NULL },
+  { "period",                            278, NULL },
+  { "greater",                           584, NULL },
+  { "atilde",                            556, NULL },
+  { "brokenbar",                         280, NULL },
+  { "quoteleft",                         278, NULL },
+  { "onesuperior",                       333, NULL }
+};
+
+static BuiltinFontWidth helveticaObliqueWidthsTab[] = {
+  { "Ntilde",                            722, NULL },
+  { "comma",                             278, NULL },
+  { "cedilla",                           333, NULL },
+  { "plusminus",                         584, NULL },
+  { "circumflex",                        333, NULL },
+  { "dotaccent",                         333, NULL },
+  { "asciitilde",                        584, NULL },
+  { "colon",                             278, NULL },
+  { "onehalf",                           834, NULL },
+  { "dollar",                            556, NULL },
+  { "ntilde",                            556, NULL },
+  { "minus",                             584, NULL },
+  { "yen",                               556, NULL },
+  { "space",                             278, NULL },
+  { "questiondown",                      611, NULL },
+  { "emdash",                           1000, NULL },
+  { "Agrave",                            667, NULL },
+  { "three",                             556, NULL },
+  { "numbersign",                        556, NULL },
+  { "A",                                 667, NULL },
+  { "B",                                 667, NULL },
+  { "C",                                 722, NULL },
+  { "D",                                 722, NULL },
+  { "E",                                 667, NULL },
+  { "onequarter",                        834, NULL },
+  { "F",                                 611, NULL },
+  { "G",                                 778, NULL },
+  { "H",                                 722, NULL },
+  { "I",                                 278, NULL },
+  { "J",                                 500, NULL },
+  { "K",                                 667, NULL },
+  { "backslash",                         278, NULL },
+  { "L",                                 556, NULL },
+  { "periodcentered",                    278, NULL },
+  { "M",                                 833, NULL },
+  { "N",                                 722, NULL },
+  { "O",                                 778, NULL },
+  { "P",                                 667, NULL },
+  { "Q",                                 778, NULL },
+  { "R",                                 722, NULL },
+  { "Aacute",                            667, NULL },
+  { "caron",                             333, NULL },
+  { "S",                                 667, NULL },
+  { "T",                                 611, NULL },
+  { "U",                                 722, NULL },
+  { "agrave",                            556, NULL },
+  { "V",                                 667, NULL },
+  { "W",                                 944, NULL },
+  { "X",                                 667, NULL },
+  { "question",                          556, NULL },
+  { "equal",                             584, NULL },
+  { "Y",                                 667, NULL },
+  { "Z",                                 611, NULL },
+  { "four",                              556, NULL },
+  { "a",                                 556, NULL },
+  { "b",                                 556, NULL },
+  { "c",                                 500, NULL },
+  { "d",                                 556, NULL },
+  { "e",                                 556, NULL },
+  { "f",                                 278, NULL },
+  { "g",                                 556, NULL },
+  { "bullet",                            350, NULL },
+  { "h",                                 556, NULL },
+  { "i",                                 222, NULL },
+  { "Oslash",                            778, NULL },
+  { "dagger",                            556, NULL },
+  { "j",                                 222, NULL },
+  { "k",                                 500, NULL },
+  { "l",                                 222, NULL },
+  { "m",                                 833, NULL },
+  { "n",                                 556, NULL },
+  { "o",                                 556, NULL },
+  { "ordfeminine",                       370, NULL },
+  { "ring",                              333, NULL },
+  { "p",                                 556, NULL },
+  { "q",                                 556, NULL },
+  { "r",                                 333, NULL },
+  { "twosuperior",                       333, NULL },
+  { "aacute",                            556, NULL },
+  { "s",                                 500, NULL },
+  { "OE",                               1000, NULL },
+  { "t",                                 278, NULL },
+  { "divide",                            584, NULL },
+  { "u",                                 556, NULL },
+  { "v",                                 500, NULL },
+  { "w",                                 722, NULL },
+  { "x",                                 500, NULL },
+  { "y",                                 500, NULL },
+  { "z",                                 500, NULL },
+  { "hungarumlaut",                      333, NULL },
+  { "quotedbl",                          355, NULL },
+  { "mu",                                556, NULL },
+  { "Scaron",                            667, NULL },
+  { "Lslash",                            556, NULL },
+  { "semicolon",                         278, NULL },
+  { "oslash",                            611, NULL },
+  { "parenright",                        333, NULL },
+  { "Ecircumflex",                       667, NULL },
+  { "trademark",                        1000, NULL },
+  { "daggerdbl",                         556, NULL },
+  { "macron",                            333, NULL },
+  { "Otilde",                            778, NULL },
+  { "ellipsis",                         1000, NULL },
+  { "scaron",                            500, NULL },
+  { "AE",                               1000, NULL },
+  { "Ucircumflex",                       722, NULL },
+  { "lslash",                            222, NULL },
+  { "quotedblleft",                      333, NULL },
+  { "guilsinglright",                    333, NULL },
+  { "hyphen",                            333, NULL },
+  { "quotesingle",                       191, NULL },
+  { "eight",                             556, NULL },
+  { "exclamdown",                        333, NULL },
+  { "endash",                            556, NULL },
+  { "oe",                                944, NULL },
+  { "ecircumflex",                       556, NULL },
+  { "copyright",                         737, NULL },
+  { "Adieresis",                         667, NULL },
+  { "Egrave",                            667, NULL },
+  { "slash",                             278, NULL },
+  { "Edieresis",                         667, NULL },
+  { "otilde",                            556, NULL },
+  { "Idieresis",                         278, NULL },
+  { "parenleft",                         333, NULL },
+  { "one",                               556, NULL },
+  { "ucircumflex",                       556, NULL },
+  { "Odieresis",                         778, NULL },
+  { "bracketleft",                       278, NULL },
+  { "Ugrave",                            722, NULL },
+  { "quoteright",                        222, NULL },
+  { "Udieresis",                         722, NULL },
+  { "perthousand",                      1000, NULL },
+  { "Ydieresis",                         667, NULL },
+  { "Eacute",                            667, NULL },
+  { "adieresis",                         556, NULL },
+  { "egrave",                            556, NULL },
+  { "edieresis",                         556, NULL },
+  { "idieresis",                         278, NULL },
+  { "Eth",                               722, NULL },
+  { "ae",                                889, NULL },
+  { "asterisk",                          389, NULL },
+  { "odieresis",                         556, NULL },
+  { "Uacute",                            722, NULL },
+  { "ugrave",                            556, NULL },
+  { "nine",                              556, NULL },
+  { "five",                              556, NULL },
+  { "udieresis",                         556, NULL },
+  { "Zcaron",                            611, NULL },
+  { "threequarters",                     834, NULL },
+  { "guillemotright",                    556, NULL },
+  { "ydieresis",                         500, NULL },
+  { "Ccedilla",                          722, NULL },
+  { "tilde",                             333, NULL },
+  { "at",                               1015, NULL },
+  { "eacute",                            556, NULL },
+  { "underscore",                        556, NULL },
+  { "multiply",                          584, NULL },
+  { "zero",                              556, NULL },
+  { "eth",                               556, NULL },
+  { "Ograve",                            778, NULL },
+  { "uacute",                            556, NULL },
+  { "braceleft",                         334, NULL },
+  { "Thorn",                             667, NULL },
+  { "zcaron",                            500, NULL },
+  { "ccedilla",                          500, NULL },
+  { "Ocircumflex",                       778, NULL },
+  { "Oacute",                            778, NULL },
+  { "ogonek",                            333, NULL },
+  { "ograve",                            556, NULL },
+  { "thorn",                             556, NULL },
+  { "degree",                            400, NULL },
+  { "registered",                        737, NULL },
+  { "Aring",                             667, NULL },
+  { "percent",                           889, NULL },
+  { "six",                               556, NULL },
+  { "paragraph",                         537, NULL },
+  { "two",                               556, NULL },
+  { "Igrave",                            278, NULL },
+  { "ocircumflex",                       556, NULL },
+  { "oacute",                            556, NULL },
+  { "asciicircum",                       469, NULL },
+  { "aring",                             556, NULL },
+  { "grave",                             333, NULL },
+  { "bracketright",                      278, NULL },
+  { "Iacute",                            278, NULL },
+  { "ampersand",                         667, NULL },
+  { "igrave",                            278, NULL },
+  { "plus",                              584, NULL },
+  { "quotesinglbase",                    222, NULL },
+  { "Yacute",                            667, NULL },
+  { "threesuperior",                     333, NULL },
+  { "acute",                             333, NULL },
+  { "section",                           556, NULL },
+  { "dieresis",                          333, NULL },
+  { "iacute",                            278, NULL },
+  { "quotedblbase",                      333, NULL },
+  { "florin",                            556, NULL },
+  { "yacute",                            500, NULL },
+  { "fi",                                500, NULL },
+  { "fl",                                500, NULL },
+  { "Acircumflex",                       667, NULL },
+  { "Icircumflex",                       278, NULL },
+  { "guillemotleft",                     556, NULL },
+  { "germandbls",                        611, NULL },
+  { "seven",                             556, NULL },
+  { "ordmasculine",                      365, NULL },
+  { "dotlessi",                          278, NULL },
+  { "sterling",                          556, NULL },
+  { "acircumflex",                       556, NULL },
+  { "icircumflex",                       278, NULL },
+  { "braceright",                        334, NULL },
+  { "quotedblright",                     333, NULL },
+  { "cent",                              556, NULL },
+  { "currency",                          556, NULL },
+  { "logicalnot",                        584, NULL },
+  { "Atilde",                            667, NULL },
+  { "breve",                             333, NULL },
+  { "bar",                               260, NULL },
+  { "fraction",                          167, NULL },
+  { "less",                              584, NULL },
+  { "guilsinglleft",                     333, NULL },
+  { "exclam",                            278, NULL },
+  { "period",                            278, NULL },
+  { "greater",                           584, NULL },
+  { "atilde",                            556, NULL },
+  { "brokenbar",                         260, NULL },
+  { "quoteleft",                         222, NULL },
+  { "onesuperior",                       333, NULL }
+};
+
+static BuiltinFontWidth symbolWidthsTab[] = {
+  { "bracketleftex",                     384, NULL },
+  { "alpha",                             631, NULL },
+  { "union",                             768, NULL },
+  { "infinity",                          713, NULL },
+  { "comma",                             250, NULL },
+  { "copyrightsans",                     790, NULL },
+  { "plusminus",                         549, NULL },
+  { "arrowup",                           603, NULL },
+  { "apple",                             790, NULL },
+  { "parenleftbt",                       384, NULL },
+  { "notelement",                        713, NULL },
+  { "colon",                             278, NULL },
+  { "beta",                              549, NULL },
+  { "braceleftbt",                       494, NULL },
+  { "Lambda",                            686, NULL },
+  { "Phi",                               763, NULL },
+  { "minus",                             549, NULL },
+  { "space",                             250, NULL },
+  { "Sigma",                             592, NULL },
+  { "approxequal",                       549, NULL },
+  { "minute",                            247, NULL },
+  { "circleplus",                        768, NULL },
+  { "Omicron",                           722, NULL },
+  { "three",                             500, NULL },
+  { "numbersign",                        500, NULL },
+  { "lambda",                            549, NULL },
+  { "phi",                               521, NULL },
+  { "aleph",                             823, NULL },
+  { "Tau",                               611, NULL },
+  { "spade",                             753, NULL },
+  { "logicaland",                        603, NULL },
+  { "sigma",                             603, NULL },
+  { "propersuperset",                    713, NULL },
+  { "omicron",                           549, NULL },
+  { "question",                          444, NULL },
+  { "equal",                             549, NULL },
+  { "Epsilon",                           611, NULL },
+  { "emptyset",                          823, NULL },
+  { "diamond",                           753, NULL },
+  { "four",                              500, NULL },
+  { "Mu",                                889, NULL },
+  { "parenlefttp",                       384, NULL },
+  { "club",                              753, NULL },
+  { "bullet",                            460, NULL },
+  { "Omega",                             768, NULL },
+  { "tau",                               439, NULL },
+  { "Upsilon",                           690, NULL },
+  { "bracelefttp",                       494, NULL },
+  { "heart",                             753, NULL },
+  { "divide",                            549, NULL },
+  { "epsilon",                           439, NULL },
+  { "logicalor",                         603, NULL },
+  { "parenleftex",                       384, NULL },
+  { "greaterequal",                      549, NULL },
+  { "mu",                                576, NULL },
+  { "Nu",                                722, NULL },
+  { "therefore",                         863, NULL },
+  { "notsubset",                         713, NULL },
+  { "omega",                             686, NULL },
+  { "semicolon",                         278, NULL },
+  { "element",                           713, NULL },
+  { "upsilon",                           576, NULL },
+  { "existential",                       549, NULL },
+  { "integralbt",                        686, NULL },
+  { "lessequal",                         549, NULL },
+  { "phi1",                              603, NULL },
+  { "lozenge",                           494, NULL },
+  { "trademarkserif",                    890, NULL },
+  { "parenright",                        333, NULL },
+  { "reflexsuperset",                    713, NULL },
+  { "sigma1",                            439, NULL },
+  { "nu",                                521, NULL },
+  { "Gamma",                             603, NULL },
+  { "angleright",                        329, NULL },
+  { "ellipsis",                         1000, NULL },
+  { "Rho",                               556, NULL },
+  { "parenrightbt",                      384, NULL },
+  { "radicalex",                         500, NULL },
+  { "eight",                             500, NULL },
+  { "angleleft",                         329, NULL },
+  { "arrowdbldown",                      603, NULL },
+  { "congruent",                         549, NULL },
+  { "Theta",                             741, NULL },
+  { "intersection",                      768, NULL },
+  { "Pi",                                768, NULL },
+  { "slash",                             278, NULL },
+  { "registerserif",                     790, NULL },
+  { "parenleft",                         333, NULL },
+  { "one",                               500, NULL },
+  { "gamma",                             411, NULL },
+  { "bracketleft",                       333, NULL },
+  { "rho",                               549, NULL },
+  { "circlemultiply",                    768, NULL },
+  { "Chi",                               722, NULL },
+  { "theta",                             521, NULL },
+  { "pi",                                549, NULL },
+  { "integraltp",                        686, NULL },
+  { "Eta",                               722, NULL },
+  { "product",                           823, NULL },
+  { "nine",                              500, NULL },
+  { "five",                              500, NULL },
+  { "propersubset",                      713, NULL },
+  { "bracketrightbt",                    384, NULL },
+  { "trademarksans",                     786, NULL },
+  { "dotmath",                           250, NULL },
+  { "integralex",                        686, NULL },
+  { "chi",                               549, NULL },
+  { "parenrighttp",                      384, NULL },
+  { "eta",                               603, NULL },
+  { "underscore",                        500, NULL },
+  { "multiply",                          549, NULL },
+  { "zero",                              500, NULL },
+  { "partialdiff",                       494, NULL },
+  { "angle",                             768, NULL },
+  { "arrowdblleft",                      987, NULL },
+  { "braceleft",                         480, NULL },
+  { "parenrightex",                      384, NULL },
+  { "Rfraktur",                          795, NULL },
+  { "Zeta",                              611, NULL },
+  { "braceex",                           494, NULL },
+  { "arrowdblup",                        603, NULL },
+  { "arrowdown",                         603, NULL },
+  { "Ifraktur",                          686, NULL },
+  { "degree",                            400, NULL },
+  { "Iota",                              333, NULL },
+  { "perpendicular",                     658, NULL },
+  { "radical",                           549, NULL },
+  { "asteriskmath",                      500, NULL },
+  { "percent",                           833, NULL },
+  { "zeta",                              494, NULL },
+  { "six",                               500, NULL },
+  { "two",                               500, NULL },
+  { "weierstrass",                       987, NULL },
+  { "summation",                         713, NULL },
+  { "bracketrighttp",                    384, NULL },
+  { "carriagereturn",                    658, NULL },
+  { "suchthat",                          439, NULL },
+  { "arrowvertex",                       603, NULL },
+  { "Delta",                             612, NULL },
+  { "iota",                              329, NULL },
+  { "arrowhorizex",                     1000, NULL },
+  { "bracketrightex",                    384, NULL },
+  { "bracketright",                      333, NULL },
+  { "ampersand",                         778, NULL },
+  { "plus",                              549, NULL },
+  { "proportional",                      713, NULL },
+  { "delta",                             494, NULL },
+  { "copyrightserif",                    790, NULL },
+  { "bracerightmid",                     494, NULL },
+  { "arrowleft",                         987, NULL },
+  { "second",                            411, NULL },
+  { "arrowdblboth",                     1042, NULL },
+  { "florin",                            500, NULL },
+  { "Psi",                               795, NULL },
+  { "bracerightbt",                      494, NULL },
+  { "bracketleftbt",                     384, NULL },
+  { "seven",                             500, NULL },
+  { "braceleftmid",                      494, NULL },
+  { "notequal",                          549, NULL },
+  { "psi",                               686, NULL },
+  { "equivalence",                       549, NULL },
+  { "universal",                         713, NULL },
+  { "arrowdblright",                     987, NULL },
+  { "braceright",                        480, NULL },
+  { "reflexsubset",                      713, NULL },
+  { "Xi",                                645, NULL },
+  { "theta1",                            631, NULL },
+  { "logicalnot",                        713, NULL },
+  { "Kappa",                             722, NULL },
+  { "similar",                           549, NULL },
+  { "bar",                               200, NULL },
+  { "fraction",                          167, NULL },
+  { "less",                              549, NULL },
+  { "registersans",                      790, NULL },
+  { "omega1",                            713, NULL },
+  { "exclam",                            333, NULL },
+  { "Upsilon1",                          620, NULL },
+  { "bracerighttp",                      494, NULL },
+  { "xi",                                493, NULL },
+  { "period",                            250, NULL },
+  { "Alpha",                             722, NULL },
+  { "arrowright",                        987, NULL },
+  { "greater",                           549, NULL },
+  { "bracketlefttp",                     384, NULL },
+  { "kappa",                             549, NULL },
+  { "gradient",                          713, NULL },
+  { "integral",                          274, NULL },
+  { "arrowboth",                        1042, NULL },
+  { "Beta",                              667, NULL }
+};
+
+static BuiltinFontWidth timesBoldWidthsTab[] = {
+  { "Ntilde",                            722, NULL },
+  { "comma",                             250, NULL },
+  { "cedilla",                           333, NULL },
+  { "plusminus",                         570, NULL },
+  { "circumflex",                        333, NULL },
+  { "dotaccent",                         333, NULL },
+  { "asciitilde",                        520, NULL },
+  { "colon",                             333, NULL },
+  { "onehalf",                           750, NULL },
+  { "dollar",                            500, NULL },
+  { "ntilde",                            556, NULL },
+  { "minus",                             570, NULL },
+  { "yen",                               500, NULL },
+  { "space",                             250, NULL },
+  { "questiondown",                      500, NULL },
+  { "emdash",                           1000, NULL },
+  { "Agrave",                            722, NULL },
+  { "three",                             500, NULL },
+  { "numbersign",                        500, NULL },
+  { "A",                                 722, NULL },
+  { "B",                                 667, NULL },
+  { "C",                                 722, NULL },
+  { "D",                                 722, NULL },
+  { "E",                                 667, NULL },
+  { "onequarter",                        750, NULL },
+  { "F",                                 611, NULL },
+  { "G",                                 778, NULL },
+  { "H",                                 778, NULL },
+  { "I",                                 389, NULL },
+  { "J",                                 500, NULL },
+  { "K",                                 778, NULL },
+  { "backslash",                         278, NULL },
+  { "L",                                 667, NULL },
+  { "periodcentered",                    250, NULL },
+  { "M",                                 944, NULL },
+  { "N",                                 722, NULL },
+  { "O",                                 778, NULL },
+  { "P",                                 611, NULL },
+  { "Q",                                 778, NULL },
+  { "R",                                 722, NULL },
+  { "Aacute",                            722, NULL },
+  { "caron",                             333, NULL },
+  { "S",                                 556, NULL },
+  { "T",                                 667, NULL },
+  { "U",                                 722, NULL },
+  { "agrave",                            500, NULL },
+  { "V",                                 722, NULL },
+  { "W",                                1000, NULL },
+  { "X",                                 722, NULL },
+  { "question",                          500, NULL },
+  { "equal",                             570, NULL },
+  { "Y",                                 722, NULL },
+  { "Z",                                 667, NULL },
+  { "four",                              500, NULL },
+  { "a",                                 500, NULL },
+  { "b",                                 556, NULL },
+  { "c",                                 444, NULL },
+  { "d",                                 556, NULL },
+  { "e",                                 444, NULL },
+  { "f",                                 333, NULL },
+  { "g",                                 500, NULL },
+  { "bullet",                            350, NULL },
+  { "h",                                 556, NULL },
+  { "i",                                 278, NULL },
+  { "Oslash",                            778, NULL },
+  { "dagger",                            500, NULL },
+  { "j",                                 333, NULL },
+  { "k",                                 556, NULL },
+  { "l",                                 278, NULL },
+  { "m",                                 833, NULL },
+  { "n",                                 556, NULL },
+  { "o",                                 500, NULL },
+  { "ordfeminine",                       300, NULL },
+  { "ring",                              333, NULL },
+  { "p",                                 556, NULL },
+  { "q",                                 556, NULL },
+  { "r",                                 444, NULL },
+  { "twosuperior",                       300, NULL },
+  { "aacute",                            500, NULL },
+  { "s",                                 389, NULL },
+  { "OE",                               1000, NULL },
+  { "t",                                 333, NULL },
+  { "divide",                            570, NULL },
+  { "u",                                 556, NULL },
+  { "v",                                 500, NULL },
+  { "w",                                 722, NULL },
+  { "x",                                 500, NULL },
+  { "y",                                 500, NULL },
+  { "z",                                 444, NULL },
+  { "hungarumlaut",                      333, NULL },
+  { "quotedbl",                          555, NULL },
+  { "mu",                                556, NULL },
+  { "Scaron",                            556, NULL },
+  { "Lslash",                            667, NULL },
+  { "semicolon",                         333, NULL },
+  { "oslash",                            500, NULL },
+  { "parenright",                        333, NULL },
+  { "Ecircumflex",                       667, NULL },
+  { "trademark",                        1000, NULL },
+  { "daggerdbl",                         500, NULL },
+  { "macron",                            333, NULL },
+  { "Otilde",                            778, NULL },
+  { "ellipsis",                         1000, NULL },
+  { "scaron",                            389, NULL },
+  { "AE",                               1000, NULL },
+  { "Ucircumflex",                       722, NULL },
+  { "lslash",                            278, NULL },
+  { "quotedblleft",                      500, NULL },
+  { "guilsinglright",                    333, NULL },
+  { "hyphen",                            333, NULL },
+  { "quotesingle",                       278, NULL },
+  { "eight",                             500, NULL },
+  { "exclamdown",                        333, NULL },
+  { "endash",                            500, NULL },
+  { "oe",                                722, NULL },
+  { "ecircumflex",                       444, NULL },
+  { "copyright",                         747, NULL },
+  { "Adieresis",                         722, NULL },
+  { "Egrave",                            667, NULL },
+  { "slash",                             278, NULL },
+  { "Edieresis",                         667, NULL },
+  { "otilde",                            500, NULL },
+  { "Idieresis",                         389, NULL },
+  { "parenleft",                         333, NULL },
+  { "one",                               500, NULL },
+  { "ucircumflex",                       556, NULL },
+  { "Odieresis",                         778, NULL },
+  { "bracketleft",                       333, NULL },
+  { "Ugrave",                            722, NULL },
+  { "quoteright",                        333, NULL },
+  { "Udieresis",                         722, NULL },
+  { "perthousand",                      1000, NULL },
+  { "Ydieresis",                         722, NULL },
+  { "Eacute",                            667, NULL },
+  { "adieresis",                         500, NULL },
+  { "egrave",                            444, NULL },
+  { "edieresis",                         444, NULL },
+  { "idieresis",                         278, NULL },
+  { "Eth",                               722, NULL },
+  { "ae",                                722, NULL },
+  { "asterisk",                          500, NULL },
+  { "odieresis",                         500, NULL },
+  { "Uacute",                            722, NULL },
+  { "ugrave",                            556, NULL },
+  { "nine",                              500, NULL },
+  { "five",                              500, NULL },
+  { "udieresis",                         556, NULL },
+  { "Zcaron",                            667, NULL },
+  { "threequarters",                     750, NULL },
+  { "guillemotright",                    500, NULL },
+  { "ydieresis",                         500, NULL },
+  { "Ccedilla",                          722, NULL },
+  { "tilde",                             333, NULL },
+  { "at",                                930, NULL },
+  { "eacute",                            444, NULL },
+  { "underscore",                        500, NULL },
+  { "multiply",                          570, NULL },
+  { "zero",                              500, NULL },
+  { "eth",                               500, NULL },
+  { "Ograve",                            778, NULL },
+  { "uacute",                            556, NULL },
+  { "braceleft",                         394, NULL },
+  { "Thorn",                             611, NULL },
+  { "zcaron",                            444, NULL },
+  { "ccedilla",                          444, NULL },
+  { "Ocircumflex",                       778, NULL },
+  { "Oacute",                            778, NULL },
+  { "ogonek",                            333, NULL },
+  { "ograve",                            500, NULL },
+  { "thorn",                             556, NULL },
+  { "degree",                            400, NULL },
+  { "registered",                        747, NULL },
+  { "Aring",                             722, NULL },
+  { "percent",                          1000, NULL },
+  { "six",                               500, NULL },
+  { "paragraph",                         540, NULL },
+  { "two",                               500, NULL },
+  { "Igrave",                            389, NULL },
+  { "ocircumflex",                       500, NULL },
+  { "oacute",                            500, NULL },
+  { "asciicircum",                       581, NULL },
+  { "aring",                             500, NULL },
+  { "grave",                             333, NULL },
+  { "bracketright",                      333, NULL },
+  { "Iacute",                            389, NULL },
+  { "ampersand",                         833, NULL },
+  { "igrave",                            278, NULL },
+  { "plus",                              570, NULL },
+  { "quotesinglbase",                    333, NULL },
+  { "Yacute",                            722, NULL },
+  { "threesuperior",                     300, NULL },
+  { "acute",                             333, NULL },
+  { "section",                           500, NULL },
+  { "dieresis",                          333, NULL },
+  { "iacute",                            278, NULL },
+  { "quotedblbase",                      500, NULL },
+  { "florin",                            500, NULL },
+  { "yacute",                            500, NULL },
+  { "fi",                                556, NULL },
+  { "fl",                                556, NULL },
+  { "Acircumflex",                       722, NULL },
+  { "Icircumflex",                       389, NULL },
+  { "guillemotleft",                     500, NULL },
+  { "germandbls",                        556, NULL },
+  { "seven",                             500, NULL },
+  { "ordmasculine",                      330, NULL },
+  { "dotlessi",                          278, NULL },
+  { "sterling",                          500, NULL },
+  { "acircumflex",                       500, NULL },
+  { "icircumflex",                       278, NULL },
+  { "braceright",                        394, NULL },
+  { "quotedblright",                     500, NULL },
+  { "cent",                              500, NULL },
+  { "currency",                          500, NULL },
+  { "logicalnot",                        570, NULL },
+  { "Atilde",                            722, NULL },
+  { "breve",                             333, NULL },
+  { "bar",                               220, NULL },
+  { "fraction",                          167, NULL },
+  { "less",                              570, NULL },
+  { "guilsinglleft",                     333, NULL },
+  { "exclam",                            333, NULL },
+  { "period",                            250, NULL },
+  { "greater",                           570, NULL },
+  { "atilde",                            500, NULL },
+  { "brokenbar",                         220, NULL },
+  { "quoteleft",                         333, NULL },
+  { "onesuperior",                       300, NULL }
+};
+
+static BuiltinFontWidth timesBoldItalicWidthsTab[] = {
+  { "Ntilde",                            722, NULL },
+  { "comma",                             250, NULL },
+  { "cedilla",                           333, NULL },
+  { "plusminus",                         570, NULL },
+  { "circumflex",                        333, NULL },
+  { "dotaccent",                         333, NULL },
+  { "asciitilde",                        570, NULL },
+  { "colon",                             333, NULL },
+  { "onehalf",                           750, NULL },
+  { "dollar",                            500, NULL },
+  { "ntilde",                            556, NULL },
+  { "minus",                             606, NULL },
+  { "yen",                               500, NULL },
+  { "space",                             250, NULL },
+  { "questiondown",                      500, NULL },
+  { "emdash",                           1000, NULL },
+  { "Agrave",                            667, NULL },
+  { "three",                             500, NULL },
+  { "numbersign",                        500, NULL },
+  { "A",                                 667, NULL },
+  { "B",                                 667, NULL },
+  { "C",                                 667, NULL },
+  { "D",                                 722, NULL },
+  { "E",                                 667, NULL },
+  { "onequarter",                        750, NULL },
+  { "F",                                 667, NULL },
+  { "G",                                 722, NULL },
+  { "H",                                 778, NULL },
+  { "I",                                 389, NULL },
+  { "J",                                 500, NULL },
+  { "K",                                 667, NULL },
+  { "backslash",                         278, NULL },
+  { "L",                                 611, NULL },
+  { "periodcentered",                    250, NULL },
+  { "M",                                 889, NULL },
+  { "N",                                 722, NULL },
+  { "O",                                 722, NULL },
+  { "P",                                 611, NULL },
+  { "Q",                                 722, NULL },
+  { "R",                                 667, NULL },
+  { "Aacute",                            667, NULL },
+  { "caron",                             333, NULL },
+  { "S",                                 556, NULL },
+  { "T",                                 611, NULL },
+  { "U",                                 722, NULL },
+  { "agrave",                            500, NULL },
+  { "V",                                 667, NULL },
+  { "W",                                 889, NULL },
+  { "X",                                 667, NULL },
+  { "question",                          500, NULL },
+  { "equal",                             570, NULL },
+  { "Y",                                 611, NULL },
+  { "Z",                                 611, NULL },
+  { "four",                              500, NULL },
+  { "a",                                 500, NULL },
+  { "b",                                 500, NULL },
+  { "c",                                 444, NULL },
+  { "d",                                 500, NULL },
+  { "e",                                 444, NULL },
+  { "f",                                 333, NULL },
+  { "g",                                 500, NULL },
+  { "bullet",                            350, NULL },
+  { "h",                                 556, NULL },
+  { "i",                                 278, NULL },
+  { "Oslash",                            722, NULL },
+  { "dagger",                            500, NULL },
+  { "j",                                 278, NULL },
+  { "k",                                 500, NULL },
+  { "l",                                 278, NULL },
+  { "m",                                 778, NULL },
+  { "n",                                 556, NULL },
+  { "o",                                 500, NULL },
+  { "ordfeminine",                       266, NULL },
+  { "ring",                              333, NULL },
+  { "p",                                 500, NULL },
+  { "q",                                 500, NULL },
+  { "r",                                 389, NULL },
+  { "twosuperior",                       300, NULL },
+  { "aacute",                            500, NULL },
+  { "s",                                 389, NULL },
+  { "OE",                                944, NULL },
+  { "t",                                 278, NULL },
+  { "divide",                            570, NULL },
+  { "u",                                 556, NULL },
+  { "v",                                 444, NULL },
+  { "w",                                 667, NULL },
+  { "x",                                 500, NULL },
+  { "y",                                 444, NULL },
+  { "z",                                 389, NULL },
+  { "hungarumlaut",                      333, NULL },
+  { "quotedbl",                          555, NULL },
+  { "mu",                                576, NULL },
+  { "Scaron",                            556, NULL },
+  { "Lslash",                            611, NULL },
+  { "semicolon",                         333, NULL },
+  { "oslash",                            500, NULL },
+  { "parenright",                        333, NULL },
+  { "Ecircumflex",                       667, NULL },
+  { "trademark",                        1000, NULL },
+  { "daggerdbl",                         500, NULL },
+  { "macron",                            333, NULL },
+  { "Otilde",                            722, NULL },
+  { "ellipsis",                         1000, NULL },
+  { "scaron",                            389, NULL },
+  { "AE",                                944, NULL },
+  { "Ucircumflex",                       722, NULL },
+  { "lslash",                            278, NULL },
+  { "quotedblleft",                      500, NULL },
+  { "guilsinglright",                    333, NULL },
+  { "hyphen",                            333, NULL },
+  { "quotesingle",                       278, NULL },
+  { "eight",                             500, NULL },
+  { "exclamdown",                        389, NULL },
+  { "endash",                            500, NULL },
+  { "oe",                                722, NULL },
+  { "ecircumflex",                       444, NULL },
+  { "copyright",                         747, NULL },
+  { "Adieresis",                         667, NULL },
+  { "Egrave",                            667, NULL },
+  { "slash",                             278, NULL },
+  { "Edieresis",                         667, NULL },
+  { "otilde",                            500, NULL },
+  { "Idieresis",                         389, NULL },
+  { "parenleft",                         333, NULL },
+  { "one",                               500, NULL },
+  { "ucircumflex",                       556, NULL },
+  { "Odieresis",                         722, NULL },
+  { "bracketleft",                       333, NULL },
+  { "Ugrave",                            722, NULL },
+  { "quoteright",                        333, NULL },
+  { "Udieresis",                         722, NULL },
+  { "perthousand",                      1000, NULL },
+  { "Ydieresis",                         611, NULL },
+  { "Eacute",                            667, NULL },
+  { "adieresis",                         500, NULL },
+  { "egrave",                            444, NULL },
+  { "edieresis",                         444, NULL },
+  { "idieresis",                         278, NULL },
+  { "Eth",                               722, NULL },
+  { "ae",                                722, NULL },
+  { "asterisk",                          500, NULL },
+  { "odieresis",                         500, NULL },
+  { "Uacute",                            722, NULL },
+  { "ugrave",                            556, NULL },
+  { "nine",                              500, NULL },
+  { "five",                              500, NULL },
+  { "udieresis",                         556, NULL },
+  { "Zcaron",                            611, NULL },
+  { "threequarters",                     750, NULL },
+  { "guillemotright",                    500, NULL },
+  { "ydieresis",                         444, NULL },
+  { "Ccedilla",                          667, NULL },
+  { "tilde",                             333, NULL },
+  { "at",                                832, NULL },
+  { "eacute",                            444, NULL },
+  { "underscore",                        500, NULL },
+  { "multiply",                          570, NULL },
+  { "zero",                              500, NULL },
+  { "eth",                               500, NULL },
+  { "Ograve",                            722, NULL },
+  { "uacute",                            556, NULL },
+  { "braceleft",                         348, NULL },
+  { "Thorn",                             611, NULL },
+  { "zcaron",                            389, NULL },
+  { "ccedilla",                          444, NULL },
+  { "Ocircumflex",                       722, NULL },
+  { "Oacute",                            722, NULL },
+  { "ogonek",                            333, NULL },
+  { "ograve",                            500, NULL },
+  { "thorn",                             500, NULL },
+  { "degree",                            400, NULL },
+  { "registered",                        747, NULL },
+  { "Aring",                             667, NULL },
+  { "percent",                           833, NULL },
+  { "six",                               500, NULL },
+  { "paragraph",                         500, NULL },
+  { "two",                               500, NULL },
+  { "Igrave",                            389, NULL },
+  { "ocircumflex",                       500, NULL },
+  { "oacute",                            500, NULL },
+  { "asciicircum",                       570, NULL },
+  { "aring",                             500, NULL },
+  { "grave",                             333, NULL },
+  { "bracketright",                      333, NULL },
+  { "Iacute",                            389, NULL },
+  { "ampersand",                         778, NULL },
+  { "igrave",                            278, NULL },
+  { "plus",                              570, NULL },
+  { "quotesinglbase",                    333, NULL },
+  { "Yacute",                            611, NULL },
+  { "threesuperior",                     300, NULL },
+  { "acute",                             333, NULL },
+  { "section",                           500, NULL },
+  { "dieresis",                          333, NULL },
+  { "iacute",                            278, NULL },
+  { "quotedblbase",                      500, NULL },
+  { "florin",                            500, NULL },
+  { "yacute",                            444, NULL },
+  { "fi",                                556, NULL },
+  { "fl",                                556, NULL },
+  { "Acircumflex",                       667, NULL },
+  { "Icircumflex",                       389, NULL },
+  { "guillemotleft",                     500, NULL },
+  { "germandbls",                        500, NULL },
+  { "seven",                             500, NULL },
+  { "ordmasculine",                      300, NULL },
+  { "dotlessi",                          278, NULL },
+  { "sterling",                          500, NULL },
+  { "acircumflex",                       500, NULL },
+  { "icircumflex",                       278, NULL },
+  { "braceright",                        348, NULL },
+  { "quotedblright",                     500, NULL },
+  { "cent",                              500, NULL },
+  { "currency",                          500, NULL },
+  { "logicalnot",                        606, NULL },
+  { "Atilde",                            667, NULL },
+  { "breve",                             333, NULL },
+  { "bar",                               220, NULL },
+  { "fraction",                          167, NULL },
+  { "less",                              570, NULL },
+  { "guilsinglleft",                     333, NULL },
+  { "exclam",                            389, NULL },
+  { "period",                            250, NULL },
+  { "greater",                           570, NULL },
+  { "atilde",                            500, NULL },
+  { "brokenbar",                         220, NULL },
+  { "quoteleft",                         333, NULL },
+  { "onesuperior",                       300, NULL }
+};
+
+static BuiltinFontWidth timesItalicWidthsTab[] = {
+  { "Ntilde",                            667, NULL },
+  { "comma",                             250, NULL },
+  { "cedilla",                           333, NULL },
+  { "plusminus",                         675, NULL },
+  { "circumflex",                        333, NULL },
+  { "dotaccent",                         333, NULL },
+  { "asciitilde",                        541, NULL },
+  { "colon",                             333, NULL },
+  { "onehalf",                           750, NULL },
+  { "dollar",                            500, NULL },
+  { "ntilde",                            500, NULL },
+  { "minus",                             675, NULL },
+  { "yen",                               500, NULL },
+  { "space",                             250, NULL },
+  { "questiondown",                      500, NULL },
+  { "emdash",                            889, NULL },
+  { "Agrave",                            611, NULL },
+  { "three",                             500, NULL },
+  { "numbersign",                        500, NULL },
+  { "A",                                 611, NULL },
+  { "B",                                 611, NULL },
+  { "C",                                 667, NULL },
+  { "D",                                 722, NULL },
+  { "E",                                 611, NULL },
+  { "onequarter",                        750, NULL },
+  { "F",                                 611, NULL },
+  { "G",                                 722, NULL },
+  { "H",                                 722, NULL },
+  { "I",                                 333, NULL },
+  { "J",                                 444, NULL },
+  { "K",                                 667, NULL },
+  { "backslash",                         278, NULL },
+  { "L",                                 556, NULL },
+  { "periodcentered",                    250, NULL },
+  { "M",                                 833, NULL },
+  { "N",                                 667, NULL },
+  { "O",                                 722, NULL },
+  { "P",                                 611, NULL },
+  { "Q",                                 722, NULL },
+  { "R",                                 611, NULL },
+  { "Aacute",                            611, NULL },
+  { "caron",                             333, NULL },
+  { "S",                                 500, NULL },
+  { "T",                                 556, NULL },
+  { "U",                                 722, NULL },
+  { "agrave",                            500, NULL },
+  { "V",                                 611, NULL },
+  { "W",                                 833, NULL },
+  { "X",                                 611, NULL },
+  { "question",                          500, NULL },
+  { "equal",                             675, NULL },
+  { "Y",                                 556, NULL },
+  { "Z",                                 556, NULL },
+  { "four",                              500, NULL },
+  { "a",                                 500, NULL },
+  { "b",                                 500, NULL },
+  { "c",                                 444, NULL },
+  { "d",                                 500, NULL },
+  { "e",                                 444, NULL },
+  { "f",                                 278, NULL },
+  { "g",                                 500, NULL },
+  { "bullet",                            350, NULL },
+  { "h",                                 500, NULL },
+  { "i",                                 278, NULL },
+  { "Oslash",                            722, NULL },
+  { "dagger",                            500, NULL },
+  { "j",                                 278, NULL },
+  { "k",                                 444, NULL },
+  { "l",                                 278, NULL },
+  { "m",                                 722, NULL },
+  { "n",                                 500, NULL },
+  { "o",                                 500, NULL },
+  { "ordfeminine",                       276, NULL },
+  { "ring",                              333, NULL },
+  { "p",                                 500, NULL },
+  { "q",                                 500, NULL },
+  { "r",                                 389, NULL },
+  { "twosuperior",                       300, NULL },
+  { "aacute",                            500, NULL },
+  { "s",                                 389, NULL },
+  { "OE",                                944, NULL },
+  { "t",                                 278, NULL },
+  { "divide",                            675, NULL },
+  { "u",                                 500, NULL },
+  { "v",                                 444, NULL },
+  { "w",                                 667, NULL },
+  { "x",                                 444, NULL },
+  { "y",                                 444, NULL },
+  { "z",                                 389, NULL },
+  { "hungarumlaut",                      333, NULL },
+  { "quotedbl",                          420, NULL },
+  { "mu",                                500, NULL },
+  { "Scaron",                            500, NULL },
+  { "Lslash",                            556, NULL },
+  { "semicolon",                         333, NULL },
+  { "oslash",                            500, NULL },
+  { "parenright",                        333, NULL },
+  { "Ecircumflex",                       611, NULL },
+  { "trademark",                         980, NULL },
+  { "daggerdbl",                         500, NULL },
+  { "macron",                            333, NULL },
+  { "Otilde",                            722, NULL },
+  { "ellipsis",                          889, NULL },
+  { "scaron",                            389, NULL },
+  { "AE",                                889, NULL },
+  { "Ucircumflex",                       722, NULL },
+  { "lslash",                            278, NULL },
+  { "quotedblleft",                      556, NULL },
+  { "guilsinglright",                    333, NULL },
+  { "hyphen",                            333, NULL },
+  { "quotesingle",                       214, NULL },
+  { "eight",                             500, NULL },
+  { "exclamdown",                        389, NULL },
+  { "endash",                            500, NULL },
+  { "oe",                                667, NULL },
+  { "ecircumflex",                       444, NULL },
+  { "copyright",                         760, NULL },
+  { "Adieresis",                         611, NULL },
+  { "Egrave",                            611, NULL },
+  { "slash",                             278, NULL },
+  { "Edieresis",                         611, NULL },
+  { "otilde",                            500, NULL },
+  { "Idieresis",                         333, NULL },
+  { "parenleft",                         333, NULL },
+  { "one",                               500, NULL },
+  { "ucircumflex",                       500, NULL },
+  { "Odieresis",                         722, NULL },
+  { "bracketleft",                       389, NULL },
+  { "Ugrave",                            722, NULL },
+  { "quoteright",                        333, NULL },
+  { "Udieresis",                         722, NULL },
+  { "perthousand",                      1000, NULL },
+  { "Ydieresis",                         556, NULL },
+  { "Eacute",                            611, NULL },
+  { "adieresis",                         500, NULL },
+  { "egrave",                            444, NULL },
+  { "edieresis",                         444, NULL },
+  { "idieresis",                         278, NULL },
+  { "Eth",                               722, NULL },
+  { "ae",                                667, NULL },
+  { "asterisk",                          500, NULL },
+  { "odieresis",                         500, NULL },
+  { "Uacute",                            722, NULL },
+  { "ugrave",                            500, NULL },
+  { "nine",                              500, NULL },
+  { "five",                              500, NULL },
+  { "udieresis",                         500, NULL },
+  { "Zcaron",                            556, NULL },
+  { "threequarters",                     750, NULL },
+  { "guillemotright",                    500, NULL },
+  { "ydieresis",                         444, NULL },
+  { "Ccedilla",                          667, NULL },
+  { "tilde",                             333, NULL },
+  { "at",                                920, NULL },
+  { "eacute",                            444, NULL },
+  { "underscore",                        500, NULL },
+  { "multiply",                          675, NULL },
+  { "zero",                              500, NULL },
+  { "eth",                               500, NULL },
+  { "Ograve",                            722, NULL },
+  { "uacute",                            500, NULL },
+  { "braceleft",                         400, NULL },
+  { "Thorn",                             611, NULL },
+  { "zcaron",                            389, NULL },
+  { "ccedilla",                          444, NULL },
+  { "Ocircumflex",                       722, NULL },
+  { "Oacute",                            722, NULL },
+  { "ogonek",                            333, NULL },
+  { "ograve",                            500, NULL },
+  { "thorn",                             500, NULL },
+  { "degree",                            400, NULL },
+  { "registered",                        760, NULL },
+  { "Aring",                             611, NULL },
+  { "percent",                           833, NULL },
+  { "six",                               500, NULL },
+  { "paragraph",                         523, NULL },
+  { "two",                               500, NULL },
+  { "Igrave",                            333, NULL },
+  { "ocircumflex",                       500, NULL },
+  { "oacute",                            500, NULL },
+  { "asciicircum",                       422, NULL },
+  { "aring",                             500, NULL },
+  { "grave",                             333, NULL },
+  { "bracketright",                      389, NULL },
+  { "Iacute",                            333, NULL },
+  { "ampersand",                         778, NULL },
+  { "igrave",                            278, NULL },
+  { "plus",                              675, NULL },
+  { "quotesinglbase",                    333, NULL },
+  { "Yacute",                            556, NULL },
+  { "threesuperior",                     300, NULL },
+  { "acute",                             333, NULL },
+  { "section",                           500, NULL },
+  { "dieresis",                          333, NULL },
+  { "iacute",                            278, NULL },
+  { "quotedblbase",                      556, NULL },
+  { "florin",                            500, NULL },
+  { "yacute",                            444, NULL },
+  { "fi",                                500, NULL },
+  { "fl",                                500, NULL },
+  { "Acircumflex",                       611, NULL },
+  { "Icircumflex",                       333, NULL },
+  { "guillemotleft",                     500, NULL },
+  { "germandbls",                        500, NULL },
+  { "seven",                             500, NULL },
+  { "ordmasculine",                      310, NULL },
+  { "dotlessi",                          278, NULL },
+  { "sterling",                          500, NULL },
+  { "acircumflex",                       500, NULL },
+  { "icircumflex",                       278, NULL },
+  { "braceright",                        400, NULL },
+  { "quotedblright",                     556, NULL },
+  { "cent",                              500, NULL },
+  { "currency",                          500, NULL },
+  { "logicalnot",                        675, NULL },
+  { "Atilde",                            611, NULL },
+  { "breve",                             333, NULL },
+  { "bar",                               275, NULL },
+  { "fraction",                          167, NULL },
+  { "less",                              675, NULL },
+  { "guilsinglleft",                     333, NULL },
+  { "exclam",                            333, NULL },
+  { "period",                            250, NULL },
+  { "greater",                           675, NULL },
+  { "atilde",                            500, NULL },
+  { "brokenbar",                         275, NULL },
+  { "quoteleft",                         333, NULL },
+  { "onesuperior",                       300, NULL }
+};
+
+static BuiltinFontWidth timesRomanWidthsTab[] = {
+  { "Ntilde",                            722, NULL },
+  { "comma",                             250, NULL },
+  { "cedilla",                           333, NULL },
+  { "plusminus",                         564, NULL },
+  { "circumflex",                        333, NULL },
+  { "dotaccent",                         333, NULL },
+  { "asciitilde",                        541, NULL },
+  { "colon",                             278, NULL },
+  { "onehalf",                           750, NULL },
+  { "dollar",                            500, NULL },
+  { "ntilde",                            500, NULL },
+  { "minus",                             564, NULL },
+  { "yen",                               500, NULL },
+  { "space",                             250, NULL },
+  { "questiondown",                      444, NULL },
+  { "emdash",                           1000, NULL },
+  { "Agrave",                            722, NULL },
+  { "three",                             500, NULL },
+  { "numbersign",                        500, NULL },
+  { "A",                                 722, NULL },
+  { "B",                                 667, NULL },
+  { "C",                                 667, NULL },
+  { "D",                                 722, NULL },
+  { "E",                                 611, NULL },
+  { "onequarter",                        750, NULL },
+  { "F",                                 556, NULL },
+  { "G",                                 722, NULL },
+  { "H",                                 722, NULL },
+  { "I",                                 333, NULL },
+  { "J",                                 389, NULL },
+  { "K",                                 722, NULL },
+  { "backslash",                         278, NULL },
+  { "L",                                 611, NULL },
+  { "periodcentered",                    250, NULL },
+  { "M",                                 889, NULL },
+  { "N",                                 722, NULL },
+  { "O",                                 722, NULL },
+  { "P",                                 556, NULL },
+  { "Q",                                 722, NULL },
+  { "R",                                 667, NULL },
+  { "Aacute",                            722, NULL },
+  { "caron",                             333, NULL },
+  { "S",                                 556, NULL },
+  { "T",                                 611, NULL },
+  { "U",                                 722, NULL },
+  { "agrave",                            444, NULL },
+  { "V",                                 722, NULL },
+  { "W",                                 944, NULL },
+  { "X",                                 722, NULL },
+  { "question",                          444, NULL },
+  { "equal",                             564, NULL },
+  { "Y",                                 722, NULL },
+  { "Z",                                 611, NULL },
+  { "four",                              500, NULL },
+  { "a",                                 444, NULL },
+  { "b",                                 500, NULL },
+  { "c",                                 444, NULL },
+  { "d",                                 500, NULL },
+  { "e",                                 444, NULL },
+  { "f",                                 333, NULL },
+  { "g",                                 500, NULL },
+  { "bullet",                            350, NULL },
+  { "h",                                 500, NULL },
+  { "i",                                 278, NULL },
+  { "Oslash",                            722, NULL },
+  { "dagger",                            500, NULL },
+  { "j",                                 278, NULL },
+  { "k",                                 500, NULL },
+  { "l",                                 278, NULL },
+  { "m",                                 778, NULL },
+  { "n",                                 500, NULL },
+  { "o",                                 500, NULL },
+  { "ordfeminine",                       276, NULL },
+  { "ring",                              333, NULL },
+  { "p",                                 500, NULL },
+  { "q",                                 500, NULL },
+  { "r",                                 333, NULL },
+  { "twosuperior",                       300, NULL },
+  { "aacute",                            444, NULL },
+  { "s",                                 389, NULL },
+  { "OE",                                889, NULL },
+  { "t",                                 278, NULL },
+  { "divide",                            564, NULL },
+  { "u",                                 500, NULL },
+  { "v",                                 500, NULL },
+  { "w",                                 722, NULL },
+  { "x",                                 500, NULL },
+  { "y",                                 500, NULL },
+  { "z",                                 444, NULL },
+  { "hungarumlaut",                      333, NULL },
+  { "quotedbl",                          408, NULL },
+  { "mu",                                500, NULL },
+  { "Scaron",                            556, NULL },
+  { "Lslash",                            611, NULL },
+  { "semicolon",                         278, NULL },
+  { "oslash",                            500, NULL },
+  { "parenright",                        333, NULL },
+  { "Ecircumflex",                       611, NULL },
+  { "trademark",                         980, NULL },
+  { "daggerdbl",                         500, NULL },
+  { "macron",                            333, NULL },
+  { "Otilde",                            722, NULL },
+  { "ellipsis",                         1000, NULL },
+  { "scaron",                            389, NULL },
+  { "AE",                                889, NULL },
+  { "Ucircumflex",                       722, NULL },
+  { "lslash",                            278, NULL },
+  { "quotedblleft",                      444, NULL },
+  { "guilsinglright",                    333, NULL },
+  { "hyphen",                            333, NULL },
+  { "quotesingle",                       180, NULL },
+  { "eight",                             500, NULL },
+  { "exclamdown",                        333, NULL },
+  { "endash",                            500, NULL },
+  { "oe",                                722, NULL },
+  { "ecircumflex",                       444, NULL },
+  { "copyright",                         760, NULL },
+  { "Adieresis",                         722, NULL },
+  { "Egrave",                            611, NULL },
+  { "slash",                             278, NULL },
+  { "Edieresis",                         611, NULL },
+  { "otilde",                            500, NULL },
+  { "Idieresis",                         333, NULL },
+  { "parenleft",                         333, NULL },
+  { "one",                               500, NULL },
+  { "ucircumflex",                       500, NULL },
+  { "Odieresis",                         722, NULL },
+  { "bracketleft",                       333, NULL },
+  { "Ugrave",                            722, NULL },
+  { "quoteright",                        333, NULL },
+  { "Udieresis",                         722, NULL },
+  { "perthousand",                      1000, NULL },
+  { "Ydieresis",                         722, NULL },
+  { "Eacute",                            611, NULL },
+  { "adieresis",                         444, NULL },
+  { "egrave",                            444, NULL },
+  { "edieresis",                         444, NULL },
+  { "idieresis",                         278, NULL },
+  { "Eth",                               722, NULL },
+  { "ae",                                667, NULL },
+  { "asterisk",                          500, NULL },
+  { "odieresis",                         500, NULL },
+  { "Uacute",                            722, NULL },
+  { "ugrave",                            500, NULL },
+  { "nine",                              500, NULL },
+  { "five",                              500, NULL },
+  { "udieresis",                         500, NULL },
+  { "Zcaron",                            611, NULL },
+  { "threequarters",                     750, NULL },
+  { "guillemotright",                    500, NULL },
+  { "ydieresis",                         500, NULL },
+  { "Ccedilla",                          667, NULL },
+  { "tilde",                             333, NULL },
+  { "at",                                921, NULL },
+  { "eacute",                            444, NULL },
+  { "underscore",                        500, NULL },
+  { "multiply",                          564, NULL },
+  { "zero",                              500, NULL },
+  { "eth",                               500, NULL },
+  { "Ograve",                            722, NULL },
+  { "uacute",                            500, NULL },
+  { "braceleft",                         480, NULL },
+  { "Thorn",                             556, NULL },
+  { "zcaron",                            444, NULL },
+  { "ccedilla",                          444, NULL },
+  { "Ocircumflex",                       722, NULL },
+  { "Oacute",                            722, NULL },
+  { "ogonek",                            333, NULL },
+  { "ograve",                            500, NULL },
+  { "thorn",                             500, NULL },
+  { "degree",                            400, NULL },
+  { "registered",                        760, NULL },
+  { "Aring",                             722, NULL },
+  { "percent",                           833, NULL },
+  { "six",                               500, NULL },
+  { "paragraph",                         453, NULL },
+  { "two",                               500, NULL },
+  { "Igrave",                            333, NULL },
+  { "ocircumflex",                       500, NULL },
+  { "oacute",                            500, NULL },
+  { "asciicircum",                       469, NULL },
+  { "aring",                             444, NULL },
+  { "grave",                             333, NULL },
+  { "bracketright",                      333, NULL },
+  { "Iacute",                            333, NULL },
+  { "ampersand",                         778, NULL },
+  { "igrave",                            278, NULL },
+  { "plus",                              564, NULL },
+  { "quotesinglbase",                    333, NULL },
+  { "Yacute",                            722, NULL },
+  { "threesuperior",                     300, NULL },
+  { "acute",                             333, NULL },
+  { "section",                           500, NULL },
+  { "dieresis",                          333, NULL },
+  { "iacute",                            278, NULL },
+  { "quotedblbase",                      444, NULL },
+  { "florin",                            500, NULL },
+  { "yacute",                            500, NULL },
+  { "fi",                                556, NULL },
+  { "fl",                                556, NULL },
+  { "Acircumflex",                       722, NULL },
+  { "Icircumflex",                       333, NULL },
+  { "guillemotleft",                     500, NULL },
+  { "germandbls",                        500, NULL },
+  { "seven",                             500, NULL },
+  { "ordmasculine",                      310, NULL },
+  { "dotlessi",                          278, NULL },
+  { "sterling",                          500, NULL },
+  { "acircumflex",                       444, NULL },
+  { "icircumflex",                       278, NULL },
+  { "braceright",                        480, NULL },
+  { "quotedblright",                     444, NULL },
+  { "cent",                              500, NULL },
+  { "currency",                          500, NULL },
+  { "logicalnot",                        564, NULL },
+  { "Atilde",                            722, NULL },
+  { "breve",                             333, NULL },
+  { "bar",                               200, NULL },
+  { "fraction",                          167, NULL },
+  { "less",                              564, NULL },
+  { "guilsinglleft",                     333, NULL },
+  { "exclam",                            333, NULL },
+  { "period",                            250, NULL },
+  { "greater",                           564, NULL },
+  { "atilde",                            444, NULL },
+  { "brokenbar",                         200, NULL },
+  { "quoteleft",                         333, NULL },
+  { "onesuperior",                       300, NULL }
+};
+
+static BuiltinFontWidth zapfDingbatsWidthsTab[] = {
+  { "a81",                               438, NULL },
+  { "a82",                               138, NULL },
+  { "a83",                               277, NULL },
+  { "a84",                               415, NULL },
+  { "a85",                               509, NULL },
+  { "a86",                               410, NULL },
+  { "a87",                               234, NULL },
+  { "a88",                               234, NULL },
+  { "a89",                               390, NULL },
+  { "a140",                              788, NULL },
+  { "a141",                              788, NULL },
+  { "a142",                              788, NULL },
+  { "a143",                              788, NULL },
+  { "a144",                              788, NULL },
+  { "a145",                              788, NULL },
+  { "a146",                              788, NULL },
+  { "a147",                              788, NULL },
+  { "a148",                              788, NULL },
+  { "a149",                              788, NULL },
+  { "a90",                               390, NULL },
+  { "a91",                               276, NULL },
+  { "a92",                               276, NULL },
+  { "space",                             278, NULL },
+  { "a93",                               317, NULL },
+  { "a94",                               317, NULL },
+  { "a95",                               334, NULL },
+  { "a96",                               334, NULL },
+  { "a97",                               392, NULL },
+  { "a98",                               392, NULL },
+  { "a99",                               668, NULL },
+  { "a150",                              788, NULL },
+  { "a151",                              788, NULL },
+  { "a152",                              788, NULL },
+  { "a153",                              788, NULL },
+  { "a154",                              788, NULL },
+  { "a155",                              788, NULL },
+  { "a156",                              788, NULL },
+  { "a157",                              788, NULL },
+  { "a158",                              788, NULL },
+  { "a159",                              788, NULL },
+  { "a160",                              894, NULL },
+  { "a161",                              838, NULL },
+  { "a162",                              924, NULL },
+  { "a163",                             1016, NULL },
+  { "a164",                              458, NULL },
+  { "a165",                              924, NULL },
+  { "a166",                              918, NULL },
+  { "a167",                              927, NULL },
+  { "a168",                              928, NULL },
+  { "a169",                              928, NULL },
+  { "a170",                              834, NULL },
+  { "a171",                              873, NULL },
+  { "a172",                              828, NULL },
+  { "a173",                              924, NULL },
+  { "a174",                              917, NULL },
+  { "a175",                              930, NULL },
+  { "a176",                              931, NULL },
+  { "a177",                              463, NULL },
+  { "a178",                              883, NULL },
+  { "a179",                              836, NULL },
+  { "a180",                              867, NULL },
+  { "a181",                              696, NULL },
+  { "a182",                              874, NULL },
+  { "a183",                              760, NULL },
+  { "a184",                              946, NULL },
+  { "a185",                              865, NULL },
+  { "a186",                              967, NULL },
+  { "a187",                              831, NULL },
+  { "a188",                              873, NULL },
+  { "a189",                              927, NULL },
+  { "a1",                                974, NULL },
+  { "a2",                                961, NULL },
+  { "a3",                                980, NULL },
+  { "a4",                                719, NULL },
+  { "a5",                                789, NULL },
+  { "a6",                                494, NULL },
+  { "a7",                                552, NULL },
+  { "a8",                                537, NULL },
+  { "a9",                                577, NULL },
+  { "a190",                              970, NULL },
+  { "a191",                              918, NULL },
+  { "a192",                              748, NULL },
+  { "a193",                              836, NULL },
+  { "a194",                              771, NULL },
+  { "a195",                              888, NULL },
+  { "a196",                              748, NULL },
+  { "a197",                              771, NULL },
+  { "a198",                              888, NULL },
+  { "a199",                              867, NULL },
+  { "a10",                               692, NULL },
+  { "a11",                               960, NULL },
+  { "a12",                               939, NULL },
+  { "a13",                               549, NULL },
+  { "a14",                               855, NULL },
+  { "a15",                               911, NULL },
+  { "a16",                               933, NULL },
+  { "a17",                               945, NULL },
+  { "a18",                               974, NULL },
+  { "a19",                               755, NULL },
+  { "a20",                               846, NULL },
+  { "a21",                               762, NULL },
+  { "a22",                               761, NULL },
+  { "a23",                               571, NULL },
+  { "a24",                               677, NULL },
+  { "a25",                               763, NULL },
+  { "a26",                               760, NULL },
+  { "a27",                               759, NULL },
+  { "a28",                               754, NULL },
+  { "a29",                               786, NULL },
+  { "a30",                               788, NULL },
+  { "a31",                               788, NULL },
+  { "a32",                               790, NULL },
+  { "a33",                               793, NULL },
+  { "a34",                               794, NULL },
+  { "a35",                               816, NULL },
+  { "a36",                               823, NULL },
+  { "a37",                               789, NULL },
+  { "a38",                               841, NULL },
+  { "a39",                               823, NULL },
+  { "a40",                               833, NULL },
+  { "a41",                               816, NULL },
+  { "a42",                               831, NULL },
+  { "a43",                               923, NULL },
+  { "a44",                               744, NULL },
+  { "a45",                               723, NULL },
+  { "a46",                               749, NULL },
+  { "a47",                               790, NULL },
+  { "a48",                               792, NULL },
+  { "a49",                               695, NULL },
+  { "a100",                              668, NULL },
+  { "a101",                              732, NULL },
+  { "a102",                              544, NULL },
+  { "a103",                              544, NULL },
+  { "a104",                              910, NULL },
+  { "a105",                              911, NULL },
+  { "a106",                              667, NULL },
+  { "a107",                              760, NULL },
+  { "a108",                              760, NULL },
+  { "a109",                              626, NULL },
+  { "a50",                               776, NULL },
+  { "a51",                               768, NULL },
+  { "a52",                               792, NULL },
+  { "a53",                               759, NULL },
+  { "a54",                               707, NULL },
+  { "a55",                               708, NULL },
+  { "a56",                               682, NULL },
+  { "a57",                               701, NULL },
+  { "a58",                               826, NULL },
+  { "a59",                               815, NULL },
+  { "a110",                              694, NULL },
+  { "a111",                              595, NULL },
+  { "a112",                              776, NULL },
+  { "a117",                              690, NULL },
+  { "a118",                              791, NULL },
+  { "a119",                              790, NULL },
+  { "a60",                               789, NULL },
+  { "a61",                               789, NULL },
+  { "a62",                               707, NULL },
+  { "a63",                               687, NULL },
+  { "a64",                               696, NULL },
+  { "a65",                               689, NULL },
+  { "a66",                               786, NULL },
+  { "a67",                               787, NULL },
+  { "a68",                               713, NULL },
+  { "a69",                               791, NULL },
+  { "a200",                              696, NULL },
+  { "a201",                              874, NULL },
+  { "a120",                              788, NULL },
+  { "a121",                              788, NULL },
+  { "a202",                              974, NULL },
+  { "a122",                              788, NULL },
+  { "a203",                              762, NULL },
+  { "a123",                              788, NULL },
+  { "a204",                              759, NULL },
+  { "a205",                              509, NULL },
+  { "a124",                              788, NULL },
+  { "a206",                              410, NULL },
+  { "a125",                              788, NULL },
+  { "a126",                              788, NULL },
+  { "a127",                              788, NULL },
+  { "a128",                              788, NULL },
+  { "a129",                              788, NULL },
+  { "a70",                               785, NULL },
+  { "a71",                               791, NULL },
+  { "a72",                               873, NULL },
+  { "a73",                               761, NULL },
+  { "a74",                               762, NULL },
+  { "a75",                               759, NULL },
+  { "a76",                               892, NULL },
+  { "a77",                               892, NULL },
+  { "a78",                               788, NULL },
+  { "a79",                               784, NULL },
+  { "a130",                              788, NULL },
+  { "a131",                              788, NULL },
+  { "a132",                              788, NULL },
+  { "a133",                              788, NULL },
+  { "a134",                              788, NULL },
+  { "a135",                              788, NULL },
+  { "a136",                              788, NULL },
+  { "a137",                              788, NULL },
+  { "a138",                              788, NULL },
+  { "a139",                              788, NULL }
+};
+
+BuiltinFont builtinFonts[] = {
+  { "Courier",               standardEncoding,            624, -207, { -40, -290,  640,  795}, NULL },
+  { "Courier-Bold",          standardEncoding,            674, -257, {-100, -350,  700,  855}, NULL },
+  { "Courier-BoldOblique",   standardEncoding,            674, -257, {-145, -350,  817,  855}, NULL },
+  { "Courier-Oblique",       standardEncoding,            624, -207, { -85, -290,  759,  795}, NULL },
+  { "Helvetica",             standardEncoding,            729, -219, {-174, -220, 1001,  944}, NULL },
+  { "Helvetica-Bold",        standardEncoding,            729, -219, {-173, -221, 1003,  936}, NULL },
+  { "Helvetica-BoldOblique", standardEncoding,            729, -219, {-177, -221, 1107,  936}, NULL },
+  { "Helvetica-Oblique",     standardEncoding,            729, -219, {-178, -220, 1108,  944}, NULL },
+  { "Symbol",                symbolEncoding,             1010, -293, {-180, -293, 1090, 1010}, NULL },
+  { "Times-Bold",            standardEncoding,            670, -210, {-172, -256, 1008,  965}, NULL },
+  { "Times-BoldItalic",      standardEncoding,            682, -203, {-168, -232, 1014,  894}, NULL },
+  { "Times-Italic",          standardEncoding,            684, -206, {-176, -252,  990,  930}, NULL },
+  { "Times-Roman",           standardEncoding,            682, -217, {-170, -223, 1024,  896}, NULL },
+  { "ZapfDingbats",          zapfDingbatsEncoding,        820, -143, {  -1, -143,  981,  820}, NULL }
+};
+
+BuiltinFont *builtinFontSubst[] = {
+  &builtinFonts[0],
+  &builtinFonts[3],
+  &builtinFonts[1],
+  &builtinFonts[2],
+  &builtinFonts[4],
+  &builtinFonts[7],
+  &builtinFonts[5],
+  &builtinFonts[6],
+  &builtinFonts[12],
+  &builtinFonts[11],
+  &builtinFonts[9],
+  &builtinFonts[10]
+};
+
+void initBuiltinFontTables() {
+  builtinFonts[0].widths = new BuiltinFontWidths(courierWidthsTab, 260);
+  builtinFonts[1].widths = new BuiltinFontWidths(courierBoldWidthsTab, 260);
+  builtinFonts[2].widths = new BuiltinFontWidths(courierBoldObliqueWidthsTab, 260);
+  builtinFonts[3].widths = new BuiltinFontWidths(courierObliqueWidthsTab, 260);
+  builtinFonts[4].widths = new BuiltinFontWidths(helveticaWidthsTab, 228);
+  builtinFonts[5].widths = new BuiltinFontWidths(helveticaBoldWidthsTab, 228);
+  builtinFonts[6].widths = new BuiltinFontWidths(helveticaBoldObliqueWidthsTab, 228);
+  builtinFonts[7].widths = new BuiltinFontWidths(helveticaObliqueWidthsTab, 228);
+  builtinFonts[8].widths = new BuiltinFontWidths(symbolWidthsTab, 189);
+  builtinFonts[9].widths = new BuiltinFontWidths(timesBoldWidthsTab, 228);
+  builtinFonts[10].widths = new BuiltinFontWidths(timesBoldItalicWidthsTab, 228);
+  builtinFonts[11].widths = new BuiltinFontWidths(timesItalicWidthsTab, 228);
+  builtinFonts[12].widths = new BuiltinFontWidths(timesRomanWidthsTab, 228);
+  builtinFonts[13].widths = new BuiltinFontWidths(zapfDingbatsWidthsTab, 202);
+}
+
+void freeBuiltinFontTables() {
+  int i;
+
+  for (i = 0; i < 14; ++i) {
+    delete builtinFonts[i].widths;
+  }
+}
diff --git a/pdf2swf/xpdf/BuiltinFontTables.h b/pdf2swf/xpdf/BuiltinFontTables.h
new file mode 100644 (file)
index 0000000..3a8892e
--- /dev/null
@@ -0,0 +1,23 @@
+//========================================================================
+//
+// BuiltinFontTables.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef BUILTINFONTTABLES_H
+#define BUILTINFONTTABLES_H
+
+#include "BuiltinFont.h"
+
+#define nBuiltinFonts      14
+#define nBuiltinFontSubsts 12
+
+extern BuiltinFont builtinFonts[nBuiltinFonts];
+extern BuiltinFont *builtinFontSubst[nBuiltinFontSubsts];
+
+extern void initBuiltinFontTables();
+extern void freeBuiltinFontTables();
+
+#endif
diff --git a/pdf2swf/xpdf/CMap.cc b/pdf2swf/xpdf/CMap.cc
new file mode 100644 (file)
index 0000000..b49cffd
--- /dev/null
@@ -0,0 +1,359 @@
+//========================================================================
+//
+// CMap.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include "gmem.h"
+#include "gfile.h"
+#include "GString.h"
+#include "Error.h"
+#include "GlobalParams.h"
+#include "PSTokenizer.h"
+#include "CMap.h"
+
+//------------------------------------------------------------------------
+
+struct CMapVectorEntry {
+  GBool isVector;
+  union {
+    CMapVectorEntry *vector;
+    CID cid;
+  };
+};
+
+//------------------------------------------------------------------------
+
+static int getCharFromFile(void *data) {
+  return fgetc((FILE *)data);
+}
+
+//------------------------------------------------------------------------
+
+CMap *CMap::parse(CMapCache *cache, GString *collectionA,
+                 GString *cMapNameA) {
+  FILE *f;
+  CMap *cmap;
+  PSTokenizer *pst;
+  char tok1[256], tok2[256], tok3[256];
+  int n1, n2, n3;
+  Guint start, end;
+
+  if (!(f = globalParams->findCMapFile(collectionA, cMapNameA))) {
+
+    // Check for an identity CMap.
+    if (!cMapNameA->cmp("Identity") || !cMapNameA->cmp("Identity-H")) {
+      return new CMap(collectionA->copy(), cMapNameA->copy(), 0);
+    }
+    if (!cMapNameA->cmp("Identity-V")) {
+      return new CMap(collectionA->copy(), cMapNameA->copy(), 1);
+    }
+
+    error(-1, "Couldn't find '%s' CMap file for '%s' collection",
+         cMapNameA->getCString(), collectionA->getCString());
+    return NULL;
+  }
+
+  cmap = new CMap(collectionA->copy(), cMapNameA->copy());
+
+  pst = new PSTokenizer(&getCharFromFile, f);
+  pst->getToken(tok1, sizeof(tok1), &n1);
+  while (pst->getToken(tok2, sizeof(tok2), &n2)) {
+    if (!strcmp(tok2, "usecmap")) {
+      if (tok1[0] == '/') {
+       cmap->useCMap(cache, tok1 + 1);
+      }
+      pst->getToken(tok1, sizeof(tok1), &n1);
+    } else if (!strcmp(tok1, "/WMode")) {
+      cmap->wMode = atoi(tok2);
+      pst->getToken(tok1, sizeof(tok1), &n1);
+    } else if (!strcmp(tok2, "begincodespacerange")) {
+      while (pst->getToken(tok1, sizeof(tok1), &n1)) {
+       if (!strcmp(tok1, "endcodespacerange")) {
+         break;
+       }
+       if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
+           !strcmp(tok2, "endcodespacerange")) {
+         error(-1, "Illegal entry in codespacerange block in CMap");
+         break;
+       }
+       if (tok1[0] == '<' && tok2[0] == '<' &&
+           n1 == n2 && n1 >= 4 && (n1 & 1) == 0) {
+         tok1[n1 - 1] = tok2[n1 - 1] = '\0';
+         sscanf(tok1 + 1, "%x", &start);
+         sscanf(tok2 + 1, "%x", &end);
+         n1 = (n1 - 2) / 2;
+         cmap->addCodeSpace(cmap->vector, start, end, n1);
+       }
+      }
+      pst->getToken(tok1, sizeof(tok1), &n1);
+    } else if (!strcmp(tok2, "begincidrange")) {
+      while (pst->getToken(tok1, sizeof(tok1), &n1)) {
+       if (!strcmp(tok1, "endcidrange")) {
+         break;
+       }
+       if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
+           !strcmp(tok2, "endcidrange") ||
+           !pst->getToken(tok3, sizeof(tok3), &n3) ||
+           !strcmp(tok3, "endcidrange")) {
+         error(-1, "Illegal entry in cidrange block in CMap");
+         break;
+       }
+       if (tok1[0] == '<' && tok2[0] == '<' &&
+           n1 == n2 && n1 >= 4 && (n1 & 1) == 0) {
+         tok1[n1 - 1] = tok2[n1 - 1] = '\0';
+         sscanf(tok1 + 1, "%x", &start);
+         sscanf(tok2 + 1, "%x", &end);
+         n1 = (n1 - 2) / 2;
+         cmap->addCIDs(start, end, n1, (CID)atoi(tok3));
+       }
+      }
+      pst->getToken(tok1, sizeof(tok1), &n1);
+    } else {
+      strcpy(tok1, tok2);
+    }
+  }
+  delete pst;
+
+  fclose(f);
+
+  return cmap;
+}
+
+CMap::CMap(GString *collectionA, GString *cMapNameA) {
+  int i;
+
+  collection = collectionA;
+  cMapName = cMapNameA;
+  wMode = 0;
+  vector = (CMapVectorEntry *)gmalloc(256 * sizeof(CMapVectorEntry));
+  for (i = 0; i < 256; ++i) {
+    vector[i].isVector = gFalse;
+    vector[i].cid = 0;
+  }
+  refCnt = 1;
+}
+
+CMap::CMap(GString *collectionA, GString *cMapNameA, int wModeA) {
+  collection = collectionA;
+  cMapName = cMapNameA;
+  wMode = wModeA;
+  vector = NULL;
+  refCnt = 1;
+}
+
+void CMap::useCMap(CMapCache *cache, char *useName) {
+  GString *useNameStr;
+  CMap *subCMap;
+
+  useNameStr = new GString(useName);
+  subCMap = cache->getCMap(collection, useNameStr);
+  delete useNameStr;
+  if (!subCMap) {
+    return;
+  }
+  copyVector(vector, subCMap->vector);
+  subCMap->decRefCnt();
+}
+
+void CMap::copyVector(CMapVectorEntry *dest, CMapVectorEntry *src) {
+  int i, j;
+
+  for (i = 0; i < 256; ++i) {
+    if (src[i].isVector) {
+      if (!dest[i].isVector) {
+       dest[i].isVector = gTrue;
+       dest[i].vector =
+         (CMapVectorEntry *)gmalloc(256 * sizeof(CMapVectorEntry));
+       for (j = 0; j < 256; ++j) {
+         dest[i].vector[j].isVector = gFalse;
+         dest[i].vector[j].cid = 0;
+       }
+      }
+      copyVector(dest[i].vector, src[i].vector);
+    } else {
+      if (dest[i].isVector) {
+       error(-1, "Collision in usecmap");
+      } else {
+       dest[i].cid = src[i].cid;
+      }
+    }
+  }
+}
+
+void CMap::addCodeSpace(CMapVectorEntry *vec, Guint start, Guint end,
+                       Guint nBytes) {
+  Guint start2, end2;
+  int startByte, endByte, i, j;
+
+  if (nBytes > 1) {
+    startByte = (start >> (8 * (nBytes - 1))) & 0xff;
+    endByte = (end >> (8 * (nBytes - 1))) & 0xff;
+    start2 = start & ((1 << (8 * (nBytes - 1))) - 1);
+    end2 = end & ((1 << (8 * (nBytes - 1))) - 1);
+    for (i = startByte; i <= endByte; ++i) {
+      if (!vec[i].isVector) {
+       vec[i].isVector = gTrue;
+       vec[i].vector =
+         (CMapVectorEntry *)gmalloc(256 * sizeof(CMapVectorEntry));
+       for (j = 0; j < 256; ++j) {
+         vec[i].vector[j].isVector = gFalse;
+         vec[i].vector[j].cid = 0;
+       }
+      }
+      addCodeSpace(vec[i].vector, start2, end2, nBytes - 1);
+    }
+  }
+}
+
+void CMap::addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID) {
+  CMapVectorEntry *vec;
+  CID cid;
+  int byte;
+  Guint i;
+
+  vec = vector;
+  for (i = nBytes - 1; i >= 1; --i) {
+    byte = (start >> (8 * i)) & 0xff;
+    if (!vec[byte].isVector) {
+      error(-1, "Invalid CID (%*x - %*x) in CMap",
+           2*nBytes, start, 2*nBytes, end);
+      return;
+    }
+    vec = vec[byte].vector;
+  }
+  cid = firstCID;
+  for (byte = (int)(start & 0xff); byte <= (int)(end & 0xff); ++byte) {
+    if (vec[byte].isVector) {
+      error(-1, "Invalid CID (%*x - %*x) in CMap",
+           2*nBytes, start, 2*nBytes, end);
+    } else {
+      vec[byte].cid = cid;
+    }
+    ++cid;
+  }
+}
+
+CMap::~CMap() {
+  delete collection;
+  delete cMapName;
+  if (vector) {
+    freeCMapVector(vector);
+  }
+}
+
+void CMap::freeCMapVector(CMapVectorEntry *vec) {
+  int i;
+
+  for (i = 0; i < 256; ++i) {
+    if (vec[i].isVector) {
+      freeCMapVector(vec[i].vector);
+    }
+  }
+  gfree(vec);
+}
+
+void CMap::incRefCnt() {
+  ++refCnt;
+}
+
+void CMap::decRefCnt() {
+  if (--refCnt == 0) {
+    delete this;
+  }
+}
+
+GBool CMap::match(GString *collectionA, GString *cMapNameA) {
+  return !collection->cmp(collectionA) && !cMapName->cmp(cMapNameA);
+}
+
+CID CMap::getCID(char *s, int len, int *nUsed) {
+  CMapVectorEntry *vec;
+  int n, i;
+
+  if (!(vec = vector)) {
+    // identity CMap
+    *nUsed = 2;
+    if (len < 2) {
+      return 0;
+    }
+    return ((s[0] & 0xff) << 8) + (s[1] & 0xff);
+  }
+  n = 0;
+  while (1) {
+    if (n >= len) {
+      *nUsed = n;
+      return 0;
+    }
+    i = s[n++] & 0xff;
+    if (!vec[i].isVector) {
+      *nUsed = n;
+      return vec[i].cid;
+    }
+    vec = vec[i].vector;
+  }
+}
+
+//------------------------------------------------------------------------
+
+CMapCache::CMapCache() {
+  int i;
+
+  for (i = 0; i < cMapCacheSize; ++i) {
+    cache[i] = NULL;
+  }
+}
+
+CMapCache::~CMapCache() {
+  int i;
+
+  for (i = 0; i < cMapCacheSize; ++i) {
+    if (cache[i]) {
+      cache[i]->decRefCnt();
+    }
+  }
+}
+
+CMap *CMapCache::getCMap(GString *collection, GString *cMapName) {
+  CMap *cmap;
+  int i, j;
+
+  if (cache[0] && cache[0]->match(collection, cMapName)) {
+    cache[0]->incRefCnt();
+    return cache[0];
+  }
+  for (i = 1; i < cMapCacheSize; ++i) {
+    if (cache[i] && cache[i]->match(collection, cMapName)) {
+      cmap = cache[i];
+      for (j = i; j >= 1; --j) {
+       cache[j] = cache[j - 1];
+      }
+      cache[0] = cmap;
+      cmap->incRefCnt();
+      return cmap;
+    }
+  }
+  if ((cmap = CMap::parse(this, collection, cMapName))) {
+    if (cache[cMapCacheSize - 1]) {
+      cache[cMapCacheSize - 1]->decRefCnt();
+    }
+    for (j = cMapCacheSize - 1; j >= 1; --j) {
+      cache[j] = cache[j - 1];
+    }
+    cache[0] = cmap;
+    cmap->incRefCnt();
+    return cmap;
+  }
+  return NULL;
+}
diff --git a/pdf2swf/xpdf/CMap.h b/pdf2swf/xpdf/CMap.h
new file mode 100644 (file)
index 0000000..fe49acf
--- /dev/null
@@ -0,0 +1,93 @@
+//========================================================================
+//
+// CMap.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef CMAP_H
+#define CMAP_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include "gtypes.h"
+#include "CharTypes.h"
+
+class GString;
+struct CMapVectorEntry;
+class CMapCache;
+
+//------------------------------------------------------------------------
+
+class CMap {
+public:
+
+  // Create the CMap specified by <collection> and <cMapName>.  Sets
+  // the initial reference count to 1.  Returns NULL on failure.
+  static CMap *parse(CMapCache *cache, GString *collectionA,
+                    GString *cMapNameA);
+
+  ~CMap();
+
+  void incRefCnt();
+  void decRefCnt();
+
+  // Return collection name (<registry>-<ordering>).
+  GString *getCollection() { return collection; }
+
+  // Return true if this CMap matches the specified <collectionA>, and
+  // <cMapNameA>.
+  GBool match(GString *collectionA, GString *cMapNameA);
+
+  // Return the CID corresponding to the character code starting at
+  // <s>, which contains <len> bytes.  Sets *<nUsed> to the number of
+  // bytes used by the char code.
+  CID getCID(char *s, int len, int *nUsed);
+
+  // Return the writing mode (0=horizontal, 1=vertical).
+  int getWMode() { return wMode; }
+
+private:
+
+  CMap(GString *collectionA, GString *cMapNameA);
+  CMap(GString *collectionA, GString *cMapNameA, int wModeA);
+  void useCMap(CMapCache *cache, char *useName);
+  void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src);
+  void addCodeSpace(CMapVectorEntry *vec, Guint start, Guint end,
+                   Guint nBytes);
+  void addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID);
+  void freeCMapVector(CMapVectorEntry *vec);
+
+  GString *collection;
+  GString *cMapName;
+  int wMode;                   // writing mode (0=horizontal, 1=vertical)
+  CMapVectorEntry *vector;     // vector for first byte (NULL for
+                               //   identity CMap)
+  int refCnt;
+};
+
+//------------------------------------------------------------------------
+
+#define cMapCacheSize 4
+
+class CMapCache {
+public:
+
+  CMapCache();
+  ~CMapCache();
+
+  // Get the <cMapName> CMap for the specified character collection.
+  // Increments its reference count; there will be one reference for
+  // the cache plus one for the caller of this function.  Returns NULL
+  // on failure.
+  CMap *getCMap(GString *collection, GString *cMapName);
+
+private:
+
+  CMap *cache[cMapCacheSize];
+};
+
+#endif
diff --git a/pdf2swf/xpdf/CharCodeToUnicode.cc b/pdf2swf/xpdf/CharCodeToUnicode.cc
new file mode 100644 (file)
index 0000000..912981e
--- /dev/null
@@ -0,0 +1,390 @@
+//========================================================================
+//
+// CharCodeToUnicode.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include <stdio.h>
+#include <string.h>
+#include "gmem.h"
+#include "gfile.h"
+#include "GString.h"
+#include "Error.h"
+#include "GlobalParams.h"
+#include "PSTokenizer.h"
+#include "CharCodeToUnicode.h"
+
+//------------------------------------------------------------------------
+
+#define maxUnicodeString 8
+
+struct CharCodeToUnicodeString {
+  CharCode c;
+  Unicode u[maxUnicodeString];
+  int len;
+};
+
+//------------------------------------------------------------------------
+
+static int getCharFromString(void *data) {
+  char *p;
+  int c;
+
+  p = *(char **)data;
+  if (*p) {
+    c = *p++;
+    *(char **)data = p;
+  } else {
+    c = EOF;
+  }
+  return c;
+}
+
+static int getCharFromFile(void *data) {
+  return fgetc((FILE *)data);
+}
+
+//------------------------------------------------------------------------
+
+CharCodeToUnicode *CharCodeToUnicode::parseCIDToUnicode(GString *collectionA) {
+  FILE *f;
+  Unicode *mapA;
+  CharCode size, mapLenA;
+  char buf[64];
+  Unicode u;
+  CharCodeToUnicode *ctu;
+
+  if (!(f = globalParams->getCIDToUnicodeFile(collectionA))) {
+    error(-1, "Couldn't find cidToUnicode file for the '%s' collection",
+         collectionA->getCString());
+    return NULL;
+  }
+
+  size = 32768;
+  mapA = (Unicode *)gmalloc(size * sizeof(Unicode));
+  mapLenA = 0;
+
+  while (getLine(buf, sizeof(buf), f)) {
+    if (mapLenA == size) {
+      size *= 2;
+      mapA = (Unicode *)grealloc(mapA, size * sizeof(Unicode));
+    }
+    if (sscanf(buf, "%x", &u) == 1) {
+      mapA[mapLenA] = u;
+    } else {
+      error(-1, "Bad line (%d) in cidToUnicode file for the '%s' collection",
+           (int)(mapLenA + 1), collectionA->getCString());
+      mapA[mapLenA] = 0;
+    }
+    ++mapLenA;
+  }
+
+  ctu = new CharCodeToUnicode(collectionA->copy(), mapA, mapLenA, gTrue,
+                             NULL, 0);
+  gfree(mapA);
+  return ctu;
+}
+
+CharCodeToUnicode *CharCodeToUnicode::make8BitToUnicode(Unicode *toUnicode) {
+  return new CharCodeToUnicode(NULL, toUnicode, 256, gTrue, NULL, 0);
+}
+
+CharCodeToUnicode *CharCodeToUnicode::parseCMap(GString *buf, int nBits) {
+  CharCodeToUnicode *ctu;
+  char *p;
+
+  ctu = new CharCodeToUnicode(NULL);
+  p = buf->getCString();
+  ctu->parseCMap1(&getCharFromString, &p, nBits);
+  return ctu;
+}
+
+void CharCodeToUnicode::parseCMap1(int (*getCharFunc)(void *), void *data,
+                                  int nBits) {
+  PSTokenizer *pst;
+  char tok1[256], tok2[256], tok3[256];
+  int nDigits, n1, n2, n3;
+  CharCode oldLen, i;
+  CharCode code1, code2;
+  Unicode u;
+  char uHex[5];
+  int j;
+  GString *name;
+  FILE *f;
+
+  nDigits = nBits / 4;
+  pst = new PSTokenizer(getCharFunc, data);
+  pst->getToken(tok1, sizeof(tok1), &n1);
+  while (pst->getToken(tok2, sizeof(tok2), &n2)) {
+    if (!strcmp(tok2, "usecmap")) {
+      if (tok1[0] == '/') {
+       name = new GString(tok1 + 1);
+       if ((f = globalParams->findToUnicodeFile(name))) {
+         parseCMap1(&getCharFromFile, f, nBits);
+         fclose(f);
+       } else {
+         error(-1, "Couldn't find ToUnicode CMap file for '%s'",
+               name->getCString());
+       }
+       delete name;
+      }
+      pst->getToken(tok1, sizeof(tok1), &n1);
+    } else if (!strcmp(tok2, "beginbfchar")) {
+      while (pst->getToken(tok1, sizeof(tok1), &n1)) {
+       if (!strcmp(tok1, "endbfchar")) {
+         break;
+       }
+       if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
+           !strcmp(tok2, "endbfchar")) {
+         error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
+         break;
+       }
+       if (!(n1 == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
+             tok2[0] == '<' && tok2[n2 - 1] == '>')) {
+         error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
+         continue;
+       }
+       tok1[n1 - 1] = tok2[n2 - 1] = '\0';
+       if (sscanf(tok1 + 1, "%x", &code1) != 1) {
+         error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
+         continue;
+       }
+       if (code1 >= mapLen) {
+         oldLen = mapLen;
+         mapLen = (code1 + 256) & ~255;
+         map = (Unicode *)grealloc(map, mapLen * sizeof(Unicode));
+         for (i = oldLen; i < mapLen; ++i) {
+           map[i] = 0;
+         }
+       }
+       if (n2 == 6) {
+         if (sscanf(tok2 + 1, "%x", &u) != 1) {
+           error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
+           continue;
+         }
+         map[code1] = u;
+       } else {
+         map[code1] = 0;
+         if (sMapLen == sMapSize) {
+           sMapSize += 8;
+           sMap = (CharCodeToUnicodeString *)
+               grealloc(sMap, sMapSize * sizeof(CharCodeToUnicodeString));
+         }
+         sMap[sMapLen].c = code1;
+         sMap[sMapLen].len = (n2 - 2) / 4;
+         for (j = 0; j < sMap[sMapLen].len && j < maxUnicodeString; ++j) {
+           strncpy(uHex, tok2 + 1 + j*4, 4);
+           uHex[4] = '\0';
+           if (sscanf(uHex, "%x", &sMap[sMapLen].u[j]) != 1) {
+             error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
+           }
+         }
+         ++sMapLen;
+       }
+      }
+      pst->getToken(tok1, sizeof(tok1), &n1);
+    } else if (!strcmp(tok2, "beginbfrange")) {
+      while (pst->getToken(tok1, sizeof(tok1), &n1)) {
+       if (!strcmp(tok1, "endbfrange")) {
+         break;
+       }
+       if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
+           !strcmp(tok2, "endbfrange") ||
+           !pst->getToken(tok3, sizeof(tok3), &n3) ||
+           !strcmp(tok3, "endbfrange")) {
+         error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
+         break;
+       }
+       if (!(n1 == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
+             n2 == 2 + nDigits && tok2[0] == '<' && tok2[n2 - 1] == '>' &&
+             tok3[0] == '<' && tok3[n3 - 1] == '>')) {
+         error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
+         continue;
+       }
+       tok1[n1 - 1] = tok2[n2 - 1] = tok3[n3 - 1] = '\0';
+       if (sscanf(tok1 + 1, "%x", &code1) != 1 ||
+           sscanf(tok2 + 1, "%x", &code2) != 1) {
+         error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
+         continue;
+       }
+       if (code2 >= mapLen) {
+         oldLen = mapLen;
+         mapLen = (code2 + 256) & ~255;
+         map = (Unicode *)grealloc(map, mapLen * sizeof(Unicode));
+         for (i = oldLen; i < mapLen; ++i) {
+           map[i] = 0;
+         }
+       }
+       if (n3 == 6) {
+         if (sscanf(tok3 + 1, "%x", &u) != 1) {
+           error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
+           continue;
+         }
+         for (; code1 <= code2; ++code1) {
+           map[code1] = u++;
+         }
+       } else {
+         if (sMapLen + (int)(code2 - code1 + 1) > sMapSize) {
+           sMapSize = (sMapSize + (code2 - code1 + 1) + 7) & ~7;
+           sMap = (CharCodeToUnicodeString *)
+               grealloc(sMap, sMapSize * sizeof(CharCodeToUnicodeString));
+         }
+         for (i = 0; code1 <= code2; ++code1, ++i) {
+           map[code1] = 0;
+           sMap[sMapLen].c = code1;
+           sMap[sMapLen].len = (n3 - 2) / 4;
+           for (j = 0; j < sMap[sMapLen].len && j < maxUnicodeString; ++j) {
+             strncpy(uHex, tok3 + 1 + j*4, 4);
+             uHex[4] = '\0';
+             if (sscanf(uHex, "%x", &sMap[sMapLen].u[j]) != 1) {
+               error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
+             }
+           }
+           sMap[sMapLen].u[sMap[sMapLen].len - 1] += i;
+           ++sMapLen;
+         }
+       }
+      }
+      pst->getToken(tok1, sizeof(tok1), &n1);
+    } else {
+      strcpy(tok1, tok2);
+    }
+  }
+  delete pst;
+}
+
+CharCodeToUnicode::CharCodeToUnicode(GString *collectionA) {
+  CharCode i;
+
+  collection = collectionA;
+  mapLen = 256;
+  map = (Unicode *)gmalloc(mapLen * sizeof(Unicode));
+  for (i = 0; i < mapLen; ++i) {
+    map[i] = 0;
+  }
+  sMap = NULL;
+  sMapLen = sMapSize = 0;
+  refCnt = 1;
+}
+
+CharCodeToUnicode::CharCodeToUnicode(GString *collectionA, Unicode *mapA,
+                                    CharCode mapLenA, GBool copyMap,
+                                    CharCodeToUnicodeString *sMapA,
+                                    int sMapLenA) {
+  collection = collectionA;
+  mapLen = mapLenA;
+  if (copyMap) {
+    map = (Unicode *)gmalloc(mapLen * sizeof(Unicode));
+    memcpy(map, mapA, mapLen * sizeof(Unicode));
+  } else {
+    map = mapA;
+  }
+  sMap = sMapA;
+  sMapLen = sMapSize = sMapLenA;
+  refCnt = 1;
+}
+
+CharCodeToUnicode::~CharCodeToUnicode() {
+  if (collection) {
+    delete collection;
+  }
+  gfree(map);
+  if (sMap) {
+    gfree(sMap);
+  }
+}
+
+void CharCodeToUnicode::incRefCnt() {
+  ++refCnt;
+}
+
+void CharCodeToUnicode::decRefCnt() {
+  if (--refCnt == 0) {
+    delete this;
+  }
+}
+
+GBool CharCodeToUnicode::match(GString *collectionA) {
+  return collection && !collection->cmp(collectionA);
+}
+
+int CharCodeToUnicode::mapToUnicode(CharCode c, Unicode *u, int size) {
+  int i, j;
+
+  if (c >= mapLen) {
+    return 0;
+  }
+  if (map[c]) {
+    u[0] = map[c];
+    return 1;
+  }
+  for (i = 0; i < sMapLen; ++i) {
+    if (sMap[i].c == c) {
+      for (j = 0; j < sMap[i].len && j < size; ++j) {
+       u[j] = sMap[i].u[j];
+      }
+      return j;
+    }
+  }
+  return 0;
+}
+
+//------------------------------------------------------------------------
+
+CIDToUnicodeCache::CIDToUnicodeCache() {
+  int i;
+
+  for (i = 0; i < cidToUnicodeCacheSize; ++i) {
+    cache[i] = NULL;
+  }
+}
+
+CIDToUnicodeCache::~CIDToUnicodeCache() {
+  int i;
+
+  for (i = 0; i < cidToUnicodeCacheSize; ++i) {
+    if (cache[i]) {
+      cache[i]->decRefCnt();
+    }
+  }
+}
+
+CharCodeToUnicode *CIDToUnicodeCache::getCIDToUnicode(GString *collection) {
+  CharCodeToUnicode *ctu;
+  int i, j;
+
+  if (cache[0] && cache[0]->match(collection)) {
+    cache[0]->incRefCnt();
+    return cache[0];
+  }
+  for (i = 1; i < cidToUnicodeCacheSize; ++i) {
+    if (cache[i] && cache[i]->match(collection)) {
+      ctu = cache[i];
+      for (j = i; j >= 1; --j) {
+       cache[j] = cache[j - 1];
+      }
+      cache[0] = ctu;
+      ctu->incRefCnt();
+      return ctu;
+    }
+  }
+  if ((ctu = CharCodeToUnicode::parseCIDToUnicode(collection))) {
+    if (cache[cidToUnicodeCacheSize - 1]) {
+      cache[cidToUnicodeCacheSize - 1]->decRefCnt();
+    }
+    for (j = cidToUnicodeCacheSize - 1; j >= 1; --j) {
+      cache[j] = cache[j - 1];
+    }
+    cache[0] = ctu;
+    ctu->incRefCnt();
+    return ctu;
+  }
+  return NULL;
+}
diff --git a/pdf2swf/xpdf/CharCodeToUnicode.h b/pdf2swf/xpdf/CharCodeToUnicode.h
new file mode 100644 (file)
index 0000000..06916c8
--- /dev/null
@@ -0,0 +1,88 @@
+//========================================================================
+//
+// CharCodeToUnicode.h
+//
+// Mapping from character codes to Unicode.
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef CHARCODETOUNICODE_H
+#define CHARCODETOUNICODE_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include "CharTypes.h"
+
+struct CharCodeToUnicodeString;
+
+//------------------------------------------------------------------------
+
+class CharCodeToUnicode {
+public:
+
+  // Create the CID-to-Unicode mapping specified by <collection>.
+  // This reads a .cidToUnicode file from disk.  Sets the initial
+  // reference count to 1.  Returns NULL on failure.
+  static CharCodeToUnicode *parseCIDToUnicode(GString *collectionA);
+
+  // Create the CharCode-to-Unicode mapping for an 8-bit font.
+  // <toUnicode> is an array of 256 Unicode indexes.  Sets the initial
+  // reference count to 1.
+  static CharCodeToUnicode *make8BitToUnicode(Unicode *toUnicode);
+
+  // Parse a ToUnicode CMap for an 8- or 16-bit font.
+  static CharCodeToUnicode *parseCMap(GString *buf, int nBits);
+
+  ~CharCodeToUnicode();
+
+  void incRefCnt();
+  void decRefCnt();
+
+  // Return true if this mapping matches the specified <collectionA>.
+  GBool match(GString *collectionA);
+
+  // Map a CharCode to Unicode.
+  int mapToUnicode(CharCode c, Unicode *u, int size);
+
+private:
+
+  void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
+  CharCodeToUnicode(GString *collectionA);
+  CharCodeToUnicode(GString *collectionA, Unicode *mapA,
+                   CharCode mapLenA, GBool copyMap,
+                   CharCodeToUnicodeString *sMapA, int sMapLenA);
+
+  GString *collection;
+  Unicode *map;
+  CharCode mapLen;
+  CharCodeToUnicodeString *sMap;
+  int sMapLen, sMapSize;
+  int refCnt;
+};
+
+//------------------------------------------------------------------------
+
+#define cidToUnicodeCacheSize 4
+
+class CIDToUnicodeCache {
+public:
+
+  CIDToUnicodeCache();
+  ~CIDToUnicodeCache();
+
+  // Get the CharCodeToUnicode object for <collection>.  Increments
+  // its reference count; there will be one reference for the cache
+  // plus one for the caller of this function.  Returns NULL on
+  // failure.
+  CharCodeToUnicode *getCIDToUnicode(GString *collection);
+
+private:
+
+  CharCodeToUnicode *cache[cidToUnicodeCacheSize];
+};
+
+#endif
diff --git a/pdf2swf/xpdf/CharTypes.h b/pdf2swf/xpdf/CharTypes.h
new file mode 100644 (file)
index 0000000..bae2f26
--- /dev/null
@@ -0,0 +1,24 @@
+//========================================================================
+//
+// CharTypes.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef CHARTYPES_H
+#define CHARTYPES_H
+
+// Unicode character.
+typedef unsigned int Unicode;
+
+// Character ID for CID character collections.
+typedef unsigned int CID;
+
+// This is large enough to hold any of the following:
+// - 8-bit char code
+// - 16-bit CID
+// - Unicode
+typedef unsigned int CharCode;
+
+#endif
diff --git a/pdf2swf/xpdf/CompactFontTables.h b/pdf2swf/xpdf/CompactFontTables.h
new file mode 100644 (file)
index 0000000..62d6f5a
--- /dev/null
@@ -0,0 +1,464 @@
+//========================================================================
+//
+// CompactFontTables.h
+//
+// Copyright 1999-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef COMPACTFONTINFO_H
+#define COMPACTFONTINFO_H
+
+static char *type1CStdStrings[391] = {
+  ".notdef",
+  "space",
+  "exclam",
+  "quotedbl",
+  "numbersign",
+  "dollar",
+  "percent",
+  "ampersand",
+  "quoteright",
+  "parenleft",
+  "parenright",
+  "asterisk",
+  "plus",
+  "comma",
+  "hyphen",
+  "period",
+  "slash",
+  "zero",
+  "one",
+  "two",
+  "three",
+  "four",
+  "five",
+  "six",
+  "seven",
+  "eight",
+  "nine",
+  "colon",
+  "semicolon",
+  "less",
+  "equal",
+  "greater",
+  "question",
+  "at",
+  "A",
+  "B",
+  "C",
+  "D",
+  "E",
+  "F",
+  "G",
+  "H",
+  "I",
+  "J",
+  "K",
+  "L",
+  "M",
+  "N",
+  "O",
+  "P",
+  "Q",
+  "R",
+  "S",
+  "T",
+  "U",
+  "V",
+  "W",
+  "X",
+  "Y",
+  "Z",
+  "bracketleft",
+  "backslash",
+  "bracketright",
+  "asciicircum",
+  "underscore",
+  "quoteleft",
+  "a",
+  "b",
+  "c",
+  "d",
+  "e",
+  "f",
+  "g",
+  "h",
+  "i",
+  "j",
+  "k",
+  "l",
+  "m",
+  "n",
+  "o",
+  "p",
+  "q",
+  "r",
+  "s",
+  "t",
+  "u",
+  "v",
+  "w",
+  "x",
+  "y",
+  "z",
+  "braceleft",
+  "bar",
+  "braceright",
+  "asciitilde",
+  "exclamdown",
+  "cent",
+  "sterling",
+  "fraction",
+  "yen",
+  "florin",
+  "section",
+  "currency",
+  "quotesingle",
+  "quotedblleft",
+  "guillemotleft",
+  "guilsinglleft",
+  "guilsinglright",
+  "fi",
+  "fl",
+  "endash",
+  "dagger",
+  "daggerdbl",
+  "periodcentered",
+  "paragraph",
+  "bullet",
+  "quotesinglbase",
+  "quotedblbase",
+  "quotedblright",
+  "guillemotright",
+  "ellipsis",
+  "perthousand",
+  "questiondown",
+  "grave",
+  "acute",
+  "circumflex",
+  "tilde",
+  "macron",
+  "breve",
+  "dotaccent",
+  "dieresis",
+  "ring",
+  "cedilla",
+  "hungarumlaut",
+  "ogonek",
+  "caron",
+  "emdash",
+  "AE",
+  "ordfeminine",
+  "Lslash",
+  "Oslash",
+  "OE",
+  "ordmasculine",
+  "ae",
+  "dotlessi",
+  "lslash",
+  "oslash",
+  "oe",
+  "germandbls",
+  "onesuperior",
+  "logicalnot",
+  "mu",
+  "trademark",
+  "Eth",
+  "onehalf",
+  "plusminus",
+  "Thorn",
+  "onequarter",
+  "divide",
+  "brokenbar",
+  "degree",
+  "thorn",
+  "threequarters",
+  "twosuperior",
+  "registered",
+  "minus",
+  "eth",
+  "multiply",
+  "threesuperior",
+  "copyright",
+  "Aacute",
+  "Acircumflex",
+  "Adieresis",
+  "Agrave",
+  "Aring",
+  "Atilde",
+  "Ccedilla",
+  "Eacute",
+  "Ecircumflex",
+  "Edieresis",
+  "Egrave",
+  "Iacute",
+  "Icircumflex",
+  "Idieresis",
+  "Igrave",
+  "Ntilde",
+  "Oacute",
+  "Ocircumflex",
+  "Odieresis",
+  "Ograve",
+  "Otilde",
+  "Scaron",
+  "Uacute",
+  "Ucircumflex",
+  "Udieresis",
+  "Ugrave",
+  "Yacute",
+  "Ydieresis",
+  "Zcaron",
+  "aacute",
+  "acircumflex",
+  "adieresis",
+  "agrave",
+  "aring",
+  "atilde",
+  "ccedilla",
+  "eacute",
+  "ecircumflex",
+  "edieresis",
+  "egrave",
+  "iacute",
+  "icircumflex",
+  "idieresis",
+  "igrave",
+  "ntilde",
+  "oacute",
+  "ocircumflex",
+  "odieresis",
+  "ograve",
+  "otilde",
+  "scaron",
+  "uacute",
+  "ucircumflex",
+  "udieresis",
+  "ugrave",
+  "yacute",
+  "ydieresis",
+  "zcaron",
+  "exclamsmall",
+  "Hungarumlautsmall",
+  "dollaroldstyle",
+  "dollarsuperior",
+  "ampersandsmall",
+  "Acutesmall",
+  "parenleftsuperior",
+  "parenrightsuperior",
+  "twodotenleader",
+  "onedotenleader",
+  "zerooldstyle",
+  "oneoldstyle",
+  "twooldstyle",
+  "threeoldstyle",
+  "fouroldstyle",
+  "fiveoldstyle",
+  "sixoldstyle",
+  "sevenoldstyle",
+  "eightoldstyle",
+  "nineoldstyle",
+  "commasuperior",
+  "threequartersemdash",
+  "periodsuperior",
+  "questionsmall",
+  "asuperior",
+  "bsuperior",
+  "centsuperior",
+  "dsuperior",
+  "esuperior",
+  "isuperior",
+  "lsuperior",
+  "msuperior",
+  "nsuperior",
+  "osuperior",
+  "rsuperior",
+  "ssuperior",
+  "tsuperior",
+  "ff",
+  "ffi",
+  "ffl",
+  "parenleftinferior",
+  "parenrightinferior",
+  "Circumflexsmall",
+  "hyphensuperior",
+  "Gravesmall",
+  "Asmall",
+  "Bsmall",
+  "Csmall",
+  "Dsmall",
+  "Esmall",
+  "Fsmall",
+  "Gsmall",
+  "Hsmall",
+  "Ismall",
+  "Jsmall",
+  "Ksmall",
+  "Lsmall",
+  "Msmall",
+  "Nsmall",
+  "Osmall",
+  "Psmall",
+  "Qsmall",
+  "Rsmall",
+  "Ssmall",
+  "Tsmall",
+  "Usmall",
+  "Vsmall",
+  "Wsmall",
+  "Xsmall",
+  "Ysmall",
+  "Zsmall",
+  "colonmonetary",
+  "onefitted",
+  "rupiah",
+  "Tildesmall",
+  "exclamdownsmall",
+  "centoldstyle",
+  "Lslashsmall",
+  "Scaronsmall",
+  "Zcaronsmall",
+  "Dieresissmall",
+  "Brevesmall",
+  "Caronsmall",
+  "Dotaccentsmall",
+  "Macronsmall",
+  "figuredash",
+  "hypheninferior",
+  "Ogoneksmall",
+  "Ringsmall",
+  "Cedillasmall",
+  "questiondownsmall",
+  "oneeighth",
+  "threeeighths",
+  "fiveeighths",
+  "seveneighths",
+  "onethird",
+  "twothirds",
+  "zerosuperior",
+  "foursuperior",
+  "fivesuperior",
+  "sixsuperior",
+  "sevensuperior",
+  "eightsuperior",
+  "ninesuperior",
+  "zeroinferior",
+  "oneinferior",
+  "twoinferior",
+  "threeinferior",
+  "fourinferior",
+  "fiveinferior",
+  "sixinferior",
+  "seveninferior",
+  "eightinferior",
+  "nineinferior",
+  "centinferior",
+  "dollarinferior",
+  "periodinferior",
+  "commainferior",
+  "Agravesmall",
+  "Aacutesmall",
+  "Acircumflexsmall",
+  "Atildesmall",
+  "Adieresissmall",
+  "Aringsmall",
+  "AEsmall",
+  "Ccedillasmall",
+  "Egravesmall",
+  "Eacutesmall",
+  "Ecircumflexsmall",
+  "Edieresissmall",
+  "Igravesmall",
+  "Iacutesmall",
+  "Icircumflexsmall",
+  "Idieresissmall",
+  "Ethsmall",
+  "Ntildesmall",
+  "Ogravesmall",
+  "Oacutesmall",
+  "Ocircumflexsmall",
+  "Otildesmall",
+  "Odieresissmall",
+  "OEsmall",
+  "Oslashsmall",
+  "Ugravesmall",
+  "Uacutesmall",
+  "Ucircumflexsmall",
+  "Udieresissmall",
+  "Yacutesmall",
+  "Thornsmall",
+  "Ydieresissmall",
+  "001.000",
+  "001.001",
+  "001.002",
+  "001.003",
+  "Black",
+  "Bold",
+  "Book",
+  "Light",
+  "Medium",
+  "Regular",
+  "Roman",
+  "Semibold"
+};
+
+static Gushort type1CISOAdobeCharset[229] = {
+    0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
+   10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
+   20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
+   30,  31,  32,  33,  34,  35,  36,  37,  38,  39,
+   40,  41,  42,  43,  44,  45,  46,  47,  48,  49,
+   50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
+   60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
+   70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
+   80,  81,  82,  83,  84,  85,  86,  87,  88,  89,
+   90,  91,  92,  93,  94,  95,  96,  97,  98,  99,
+  100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
+  110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+  120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
+  130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
+  140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+  150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+  160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
+  170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+  180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
+  190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
+  200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
+  210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
+  220, 221, 222, 223, 224, 225, 226, 227, 228
+};
+
+static Gushort type1CExpertCharset[166] = {
+    0,   1, 229, 230, 231, 232, 233, 234, 235, 236,
+  237, 238,  13,  14,  15,  99, 239, 240, 241, 242,
+  243, 244, 245, 246, 247, 248,  27,  28, 249, 250,
+  251, 252, 253, 254, 255, 256, 257, 258, 259, 260,
+  261, 262, 263, 264, 265, 266, 109, 110, 267, 268,
+  269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
+  279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
+  289, 290, 291, 292, 293, 294, 295, 296, 297, 298,
+  299, 300, 301, 302, 303, 304, 305, 306, 307, 308,
+  309, 310, 311, 312, 313, 314, 315, 316, 317, 318,
+  158, 155, 163, 319, 320, 321, 322, 323, 324, 325,
+  326, 150, 164, 169, 327, 328, 329, 330, 331, 332,
+  333, 334, 335, 336, 337, 338, 339, 340, 341, 342,
+  343, 344, 345, 346, 347, 348, 349, 350, 351, 352,
+  353, 354, 355, 356, 357, 358, 359, 360, 361, 362,
+  363, 364, 365, 366, 367, 368, 369, 370, 371, 372,
+  373, 374, 375, 376, 377, 378
+};
+
+static Gushort type1CExpertSubsetCharset[87] = {
+    0,   1, 231, 232, 235, 236, 237, 238,  13,  14,
+   15,  99, 239, 240, 241, 242, 243, 244, 245, 246,
+  247, 248,  27,  28, 249, 250, 251, 253, 254, 255,
+  256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
+  266, 109, 110, 267, 268, 269, 270, 272, 300, 301,
+  302, 305, 314, 315, 158, 155, 163, 320, 321, 322,
+  323, 324, 325, 326, 150, 164, 169, 327, 328, 329,
+  330, 331, 332, 333, 334, 335, 336, 337, 338, 339,
+  340, 341, 342, 343, 344, 345, 346
+};
+
+#endif
diff --git a/pdf2swf/xpdf/DisplayFontTable.h b/pdf2swf/xpdf/DisplayFontTable.h
new file mode 100644 (file)
index 0000000..4606031
--- /dev/null
@@ -0,0 +1,29 @@
+//========================================================================
+//
+// DisplayFontTable.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+static struct {
+  char *name;
+  char *xlfd;
+  char *encoding;
+} displayFontTab[] = {
+  {"Courier",               "-*-courier-medium-r-normal-*-%s-*-*-*-*-*-iso8859-1",         "Latin1"},
+  {"Courier-Bold",          "-*-courier-bold-r-normal-*-%s-*-*-*-*-*-iso8859-1",           "Latin1"},
+  {"Courier-BoldOblique",   "-*-courier-bold-o-normal-*-%s-*-*-*-*-*-iso8859-1",           "Latin1"},
+  {"Courier-Oblique",       "-*-courier-medium-o-normal-*-%s-*-*-*-*-*-iso8859-1",         "Latin1"},
+  {"Helvetica",             "-*-helvetica-medium-r-normal-*-%s-*-*-*-*-*-iso8859-1",       "Latin1"},
+  {"Helvetica-Bold",        "-*-helvetica-bold-r-normal-*-%s-*-*-*-*-*-iso8859-1",         "Latin1"},
+  {"Helvetica-BoldOblique", "-*-helvetica-bold-o-normal-*-%s-*-*-*-*-*-iso8859-1",         "Latin1"},
+  {"Helvetica-Oblique",     "-*-helvetica-medium-o-normal-*-%s-*-*-*-*-*-iso8859-1",       "Latin1"},
+  {"Symbol",                "-*-symbol-medium-r-normal-*-%s-*-*-*-*-*-adobe-fontspecific", "Symbol"},
+  {"Times-Bold",            "-*-times-bold-r-normal-*-%s-*-*-*-*-*-iso8859-1",             "Latin1"},
+  {"Times-BoldItalic",      "-*-times-bold-i-normal-*-%s-*-*-*-*-*-iso8859-1",             "Latin1"},
+  {"Times-Italic",          "-*-times-medium-i-normal-*-%s-*-*-*-*-*-iso8859-1",           "Latin1"},
+  {"Times-Roman",           "-*-times-medium-r-normal-*-%s-*-*-*-*-*-iso8859-1",           "Latin1"},
+  {"ZapfDingbats",          "-*-zapfdingbats-medium-r-normal-*-%s-*-*-*-*-*-*-*",          "ZapfDingbats"},
+  {NULL}
+};
diff --git a/pdf2swf/xpdf/ErrorCodes.h b/pdf2swf/xpdf/ErrorCodes.h
new file mode 100644 (file)
index 0000000..4e0d38a
--- /dev/null
@@ -0,0 +1,24 @@
+//========================================================================
+//
+// ErrorCodes.h
+//
+// Copyright 2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef ERRORCODES_H
+#define ERRORCODES_H
+
+#define errNone             0  // no error
+
+#define errOpenFile         1  // couldn't open the PDF file
+
+#define errBadCatalog       2  // couldn't read the page catalog
+
+#define errDamaged          3  // PDF file was damaged and couldn't be
+                               // repaired
+
+#define errEncrypted        4  // file was encrypted and password was
+                               // incorrect or not supplied
+
+#endif
diff --git a/pdf2swf/xpdf/FontEncodingTables.cc b/pdf2swf/xpdf/FontEncodingTables.cc
new file mode 100644 (file)
index 0000000..bd5f9cf
--- /dev/null
@@ -0,0 +1,1824 @@
+//========================================================================
+//
+// FontEncodingTables.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#include <aconf.h>
+#include <stdlib.h>
+#include "FontEncodingTables.h"
+
+char *macRomanEncoding[256] = {
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "space",
+  "exclam",
+  "quotedbl",
+  "numbersign",
+  "dollar",
+  "percent",
+  "ampersand",
+  "quotesingle",
+  "parenleft",
+  "parenright",
+  "asterisk",
+  "plus",
+  "comma",
+  "hyphen",
+  "period",
+  "slash",
+  "zero",
+  "one",
+  "two",
+  "three",
+  "four",
+  "five",
+  "six",
+  "seven",
+  "eight",
+  "nine",
+  "colon",
+  "semicolon",
+  "less",
+  "equal",
+  "greater",
+  "question",
+  "at",
+  "A",
+  "B",
+  "C",
+  "D",
+  "E",
+  "F",
+  "G",
+  "H",
+  "I",
+  "J",
+  "K",
+  "L",
+  "M",
+  "N",
+  "O",
+  "P",
+  "Q",
+  "R",
+  "S",
+  "T",
+  "U",
+  "V",
+  "W",
+  "X",
+  "Y",
+  "Z",
+  "bracketleft",
+  "backslash",
+  "bracketright",
+  "asciicircum",
+  "underscore",
+  "grave",
+  "a",
+  "b",
+  "c",
+  "d",
+  "e",
+  "f",
+  "g",
+  "h",
+  "i",
+  "j",
+  "k",
+  "l",
+  "m",
+  "n",
+  "o",
+  "p",
+  "q",
+  "r",
+  "s",
+  "t",
+  "u",
+  "v",
+  "w",
+  "x",
+  "y",
+  "z",
+  "braceleft",
+  "bar",
+  "braceright",
+  "asciitilde",
+  NULL,
+  "Adieresis",
+  "Aring",
+  "Ccedilla",
+  "Eacute",
+  "Ntilde",
+  "Odieresis",
+  "Udieresis",
+  "aacute",
+  "agrave",
+  "acircumflex",
+  "adieresis",
+  "atilde",
+  "aring",
+  "ccedilla",
+  "eacute",
+  "egrave",
+  "ecircumflex",
+  "edieresis",
+  "iacute",
+  "igrave",
+  "icircumflex",
+  "idieresis",
+  "ntilde",
+  "oacute",
+  "ograve",
+  "ocircumflex",
+  "odieresis",
+  "otilde",
+  "uacute",
+  "ugrave",
+  "ucircumflex",
+  "udieresis",
+  "dagger",
+  "degree",
+  "cent",
+  "sterling",
+  "section",
+  "bullet",
+  "paragraph",
+  "germandbls",
+  "registered",
+  "copyright",
+  "trademark",
+  "acute",
+  "dieresis",
+  NULL,
+  "AE",
+  "Oslash",
+  NULL,
+  "plusminus",
+  NULL,
+  NULL,
+  "yen",
+  "mu",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "ordfeminine",
+  "ordmasculine",
+  NULL,
+  "ae",
+  "oslash",
+  "questiondown",
+  "exclamdown",
+  "logicalnot",
+  NULL,
+  "florin",
+  NULL,
+  NULL,
+  "guillemotleft",
+  "guillemotright",
+  "ellipsis",
+  "space",
+  "Agrave",
+  "Atilde",
+  "Otilde",
+  "OE",
+  "oe",
+  "endash",
+  "emdash",
+  "quotedblleft",
+  "quotedblright",
+  "quoteleft",
+  "quoteright",
+  "divide",
+  NULL,
+  "ydieresis",
+  "Ydieresis",
+  "fraction",
+  "currency",
+  "guilsinglleft",
+  "guilsinglright",
+  "fi",
+  "fl",
+  "daggerdbl",
+  "periodcentered",
+  "quotesinglbase",
+  "quotedblbase",
+  "perthousand",
+  "Acircumflex",
+  "Ecircumflex",
+  "Aacute",
+  "Edieresis",
+  "Egrave",
+  "Iacute",
+  "Icircumflex",
+  "Idieresis",
+  "Igrave",
+  "Oacute",
+  "Ocircumflex",
+  NULL,
+  "Ograve",
+  "Uacute",
+  "Ucircumflex",
+  "Ugrave",
+  "dotlessi",
+  "circumflex",
+  "tilde",
+  "macron",
+  "breve",
+  "dotaccent",
+  "ring",
+  "cedilla",
+  "hungarumlaut",
+  "ogonek",
+  "caron"
+};
+
+char *macExpertEncoding[256] = {
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "space",
+  "exclamsmall",
+  "Hungarumlautsmall",
+  "centoldstyle",
+  "dollaroldstyle",
+  "dollarsuperior",
+  "ampersandsmall",
+  "Acutesmall",
+  "parenleftsuperior",
+  "parenrightsuperior",
+  "twodotenleader",
+  "onedotenleader",
+  "comma",
+  "hyphen",
+  "period",
+  "fraction",
+  "zerooldstyle",
+  "oneoldstyle",
+  "twooldstyle",
+  "threeoldstyle",
+  "fouroldstyle",
+  "fiveoldstyle",
+  "sixoldstyle",
+  "sevenoldstyle",
+  "eightoldstyle",
+  "nineoldstyle",
+  "colon",
+  "semicolon",
+  NULL,
+  "threequartersemdash",
+  NULL,
+  "questionsmall",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "Ethsmall",
+  NULL,
+  NULL,
+  "onequarter",
+  "onehalf",
+  "threequarters",
+  "oneeighth",
+  "threeeighths",
+  "fiveeighths",
+  "seveneighths",
+  "onethird",
+  "twothirds",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "ff",
+  "fi",
+  "fl",
+  "ffi",
+  "ffl",
+  "parenleftinferior",
+  NULL,
+  "parenrightinferior",
+  "Circumflexsmall",
+  "hypheninferior",
+  "Gravesmall",
+  "Asmall",
+  "Bsmall",
+  "Csmall",
+  "Dsmall",
+  "Esmall",
+  "Fsmall",
+  "Gsmall",
+  "Hsmall",
+  "Ismall",
+  "Jsmall",
+  "Ksmall",
+  "Lsmall",
+  "Msmall",
+  "Nsmall",
+  "Osmall",
+  "Psmall",
+  "Qsmall",
+  "Rsmall",
+  "Ssmall",
+  "Tsmall",
+  "Usmall",
+  "Vsmall",
+  "Wsmall",
+  "Xsmall",
+  "Ysmall",
+  "Zsmall",
+  "colonmonetary",
+  "onefitted",
+  "rupiah",
+  "Tildesmall",
+  NULL,
+  NULL,
+  "asuperior",
+  "centsuperior",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "Aacutesmall",
+  "Agravesmall",
+  "Acircumflexsmall",
+  "Adieresissmall",
+  "Atildesmall",
+  "Aringsmall",
+  "Ccedillasmall",
+  "Eacutesmall",
+  "Egravesmall",
+  "Ecircumflexsmall",
+  "Edieresissmall",
+  "Iacutesmall",
+  "Igravesmall",
+  "Icircumflexsmall",
+  "Idieresissmall",
+  "Ntildesmall",
+  "Oacutesmall",
+  "Ogravesmall",
+  "Ocircumflexsmall",
+  "Odieresissmall",
+  "Otildesmall",
+  "Uacutesmall",
+  "Ugravesmall",
+  "Ucircumflexsmall",
+  "Udieresissmall",
+  NULL,
+  "eightsuperior",
+  "fourinferior",
+  "threeinferior",
+  "sixinferior",
+  "eightinferior",
+  "seveninferior",
+  "Scaronsmall",
+  NULL,
+  "centinferior",
+  "twoinferior",
+  NULL,
+  "Dieresissmall",
+  NULL,
+  "Caronsmall",
+  "osuperior",
+  "fiveinferior",
+  NULL,
+  "commainferior",
+  "periodinferior",
+  "Yacutesmall",
+  NULL,
+  "dollarinferior",
+  NULL,
+  NULL,
+  "Thornsmall",
+  NULL,
+  "nineinferior",
+  "zeroinferior",
+  "Zcaronsmall",
+  "AEsmall",
+  "Oslashsmall",
+  "questiondownsmall",
+  "oneinferior",
+  "Lslashsmall",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "Cedillasmall",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "OEsmall",
+  "figuredash",
+  "hyphensuperior",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "exclamdownsmall",
+  NULL,
+  "Ydieresissmall",
+  NULL,
+  "onesuperior",
+  "twosuperior",
+  "threesuperior",
+  "foursuperior",
+  "fivesuperior",
+  "sixsuperior",
+  "sevensuperior",
+  "ninesuperior",
+  "zerosuperior",
+  NULL,
+  "esuperior",
+  "rsuperior",
+  "tsuperior",
+  NULL,
+  NULL,
+  "isuperior",
+  "ssuperior",
+  "dsuperior",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "lsuperior",
+  "Ogoneksmall",
+  "Brevesmall",
+  "Macronsmall",
+  "bsuperior",
+  "nsuperior",
+  "msuperior",
+  "commasuperior",
+  "periodsuperior",
+  "Dotaccentsmall",
+  "Ringsmall",
+  NULL,
+  NULL,
+  NULL,
+  NULL
+};
+
+char *winAnsiEncoding[256] = {
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "space",
+  "exclam",
+  "quotedbl",
+  "numbersign",
+  "dollar",
+  "percent",
+  "ampersand",
+  "quotesingle",
+  "parenleft",
+  "parenright",
+  "asterisk",
+  "plus",
+  "comma",
+  "hyphen",
+  "period",
+  "slash",
+  "zero",
+  "one",
+  "two",
+  "three",
+  "four",
+  "five",
+  "six",
+  "seven",
+  "eight",
+  "nine",
+  "colon",
+  "semicolon",
+  "less",
+  "equal",
+  "greater",
+  "question",
+  "at",
+  "A",
+  "B",
+  "C",
+  "D",
+  "E",
+  "F",
+  "G",
+  "H",
+  "I",
+  "J",
+  "K",
+  "L",
+  "M",
+  "N",
+  "O",
+  "P",
+  "Q",
+  "R",
+  "S",
+  "T",
+  "U",
+  "V",
+  "W",
+  "X",
+  "Y",
+  "Z",
+  "bracketleft",
+  "backslash",
+  "bracketright",
+  "asciicircum",
+  "underscore",
+  "grave",
+  "a",
+  "b",
+  "c",
+  "d",
+  "e",
+  "f",
+  "g",
+  "h",
+  "i",
+  "j",
+  "k",
+  "l",
+  "m",
+  "n",
+  "o",
+  "p",
+  "q",
+  "r",
+  "s",
+  "t",
+  "u",
+  "v",
+  "w",
+  "x",
+  "y",
+  "z",
+  "braceleft",
+  "bar",
+  "braceright",
+  "asciitilde",
+  "bullet",
+  "Euro",
+  "bullet",
+  "quotesinglbase",
+  "florin",
+  "quotedblbase",
+  "ellipsis",
+  "dagger",
+  "daggerdbl",
+  "circumflex",
+  "perthousand",
+  "Scaron",
+  "guilsinglleft",
+  "OE",
+  "bullet",
+  "Zcaron",
+  "bullet",
+  "bullet",
+  "quoteleft",
+  "quoteright",
+  "quotedblleft",
+  "quotedblright",
+  "bullet",
+  "endash",
+  "emdash",
+  "tilde",
+  "trademark",
+  "scaron",
+  "guilsinglright",
+  "oe",
+  "bullet",
+  "zcaron",
+  "Ydieresis",
+  "space",
+  "exclamdown",
+  "cent",
+  "sterling",
+  "currency",
+  "yen",
+  "brokenbar",
+  "section",
+  "dieresis",
+  "copyright",
+  "ordfeminine",
+  "guillemotleft",
+  "logicalnot",
+  "hyphen",
+  "registered",
+  "macron",
+  "degree",
+  "plusminus",
+  "twosuperior",
+  "threesuperior",
+  "acute",
+  "mu",
+  "paragraph",
+  "periodcentered",
+  "cedilla",
+  "onesuperior",
+  "ordmasculine",
+  "guillemotright",
+  "onequarter",
+  "onehalf",
+  "threequarters",
+  "questiondown",
+  "Agrave",
+  "Aacute",
+  "Acircumflex",
+  "Atilde",
+  "Adieresis",
+  "Aring",
+  "AE",
+  "Ccedilla",
+  "Egrave",
+  "Eacute",
+  "Ecircumflex",
+  "Edieresis",
+  "Igrave",
+  "Iacute",
+  "Icircumflex",
+  "Idieresis",
+  "Eth",
+  "Ntilde",
+  "Ograve",
+  "Oacute",
+  "Ocircumflex",
+  "Otilde",
+  "Odieresis",
+  "multiply",
+  "Oslash",
+  "Ugrave",
+  "Uacute",
+  "Ucircumflex",
+  "Udieresis",
+  "Yacute",
+  "Thorn",
+  "germandbls",
+  "agrave",
+  "aacute",
+  "acircumflex",
+  "atilde",
+  "adieresis",
+  "aring",
+  "ae",
+  "ccedilla",
+  "egrave",
+  "eacute",
+  "ecircumflex",
+  "edieresis",
+  "igrave",
+  "iacute",
+  "icircumflex",
+  "idieresis",
+  "eth",
+  "ntilde",
+  "ograve",
+  "oacute",
+  "ocircumflex",
+  "otilde",
+  "odieresis",
+  "divide",
+  "oslash",
+  "ugrave",
+  "uacute",
+  "ucircumflex",
+  "udieresis",
+  "yacute",
+  "thorn",
+  "ydieresis"
+};
+
+char *standardEncoding[256] = {
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "space",
+  "exclam",
+  "quotedbl",
+  "numbersign",
+  "dollar",
+  "percent",
+  "ampersand",
+  "quoteright",
+  "parenleft",
+  "parenright",
+  "asterisk",
+  "plus",
+  "comma",
+  "hyphen",
+  "period",
+  "slash",
+  "zero",
+  "one",
+  "two",
+  "three",
+  "four",
+  "five",
+  "six",
+  "seven",
+  "eight",
+  "nine",
+  "colon",
+  "semicolon",
+  "less",
+  "equal",
+  "greater",
+  "question",
+  "at",
+  "A",
+  "B",
+  "C",
+  "D",
+  "E",
+  "F",
+  "G",
+  "H",
+  "I",
+  "J",
+  "K",
+  "L",
+  "M",
+  "N",
+  "O",
+  "P",
+  "Q",
+  "R",
+  "S",
+  "T",
+  "U",
+  "V",
+  "W",
+  "X",
+  "Y",
+  "Z",
+  "bracketleft",
+  "backslash",
+  "bracketright",
+  "asciicircum",
+  "underscore",
+  "quoteleft",
+  "a",
+  "b",
+  "c",
+  "d",
+  "e",
+  "f",
+  "g",
+  "h",
+  "i",
+  "j",
+  "k",
+  "l",
+  "m",
+  "n",
+  "o",
+  "p",
+  "q",
+  "r",
+  "s",
+  "t",
+  "u",
+  "v",
+  "w",
+  "x",
+  "y",
+  "z",
+  "braceleft",
+  "bar",
+  "braceright",
+  "asciitilde",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "exclamdown",
+  "cent",
+  "sterling",
+  "fraction",
+  "yen",
+  "florin",
+  "section",
+  "currency",
+  "quotesingle",
+  "quotedblleft",
+  "guillemotleft",
+  "guilsinglleft",
+  "guilsinglright",
+  "fi",
+  "fl",
+  NULL,
+  "endash",
+  "dagger",
+  "daggerdbl",
+  "periodcentered",
+  NULL,
+  "paragraph",
+  "bullet",
+  "quotesinglbase",
+  "quotedblbase",
+  "quotedblright",
+  "guillemotright",
+  "ellipsis",
+  "perthousand",
+  NULL,
+  "questiondown",
+  NULL,
+  "grave",
+  "acute",
+  "circumflex",
+  "tilde",
+  "macron",
+  "breve",
+  "dotaccent",
+  "dieresis",
+  NULL,
+  "ring",
+  "cedilla",
+  NULL,
+  "hungarumlaut",
+  "ogonek",
+  "caron",
+  "emdash",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "AE",
+  NULL,
+  "ordfeminine",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "Lslash",
+  "Oslash",
+  "OE",
+  "ordmasculine",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "ae",
+  NULL,
+  NULL,
+  NULL,
+  "dotlessi",
+  NULL,
+  NULL,
+  "lslash",
+  "oslash",
+  "oe",
+  "germandbls",
+  NULL,
+  NULL,
+  NULL,
+  NULL
+};
+
+char *expertEncoding[256] = {
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "space",
+  "exclamsmall",
+  "Hungarumlautsmall",
+  NULL,
+  "dollaroldstyle",
+  "dollarsuperior",
+  "ampersandsmall",
+  "Acutesmall",
+  "parenleftsuperior",
+  "parenrightsuperior",
+  "twodotenleader",
+  "onedotenleader",
+  "comma",
+  "hyphen",
+  "period",
+  "fraction",
+  "zerooldstyle",
+  "oneoldstyle",
+  "twooldstyle",
+  "threeoldstyle",
+  "fouroldstyle",
+  "fiveoldstyle",
+  "sixoldstyle",
+  "sevenoldstyle",
+  "eightoldstyle",
+  "nineoldstyle",
+  "colon",
+  "semicolon",
+  "commasuperior",
+  "threequartersemdash",
+  "periodsuperior",
+  "questionsmall",
+  NULL,
+  "asuperior",
+  "bsuperior",
+  "centsuperior",
+  "dsuperior",
+  "esuperior",
+  NULL,
+  NULL,
+  NULL,
+  "isuperior",
+  NULL,
+  NULL,
+  "lsuperior",
+  "msuperior",
+  "nsuperior",
+  "osuperior",
+  NULL,
+  NULL,
+  "rsuperior",
+  "ssuperior",
+  "tsuperior",
+  NULL,
+  "ff",
+  "fi",
+  "fl",
+  "ffi",
+  "ffl",
+  "parenleftinferior",
+  NULL,
+  "parenrightinferior",
+  "Circumflexsmall",
+  "hyphensuperior",
+  "Gravesmall",
+  "Asmall",
+  "Bsmall",
+  "Csmall",
+  "Dsmall",
+  "Esmall",
+  "Fsmall",
+  "Gsmall",
+  "Hsmall",
+  "Ismall",
+  "Jsmall",
+  "Ksmall",
+  "Lsmall",
+  "Msmall",
+  "Nsmall",
+  "Osmall",
+  "Psmall",
+  "Qsmall",
+  "Rsmall",
+  "Ssmall",
+  "Tsmall",
+  "Usmall",
+  "Vsmall",
+  "Wsmall",
+  "Xsmall",
+  "Ysmall",
+  "Zsmall",
+  "colonmonetary",
+  "onefitted",
+  "rupiah",
+  "Tildesmall",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "exclamdownsmall",
+  "centoldstyle",
+  "Lslashsmall",
+  NULL,
+  NULL,
+  "Scaronsmall",
+  "Zcaronsmall",
+  "Dieresissmall",
+  "Brevesmall",
+  "Caronsmall",
+  NULL,
+  "Dotaccentsmall",
+  NULL,
+  NULL,
+  "Macronsmall",
+  NULL,
+  NULL,
+  "figuredash",
+  "hypheninferior",
+  NULL,
+  NULL,
+  "Ogoneksmall",
+  "Ringsmall",
+  "Cedillasmall",
+  NULL,
+  NULL,
+  NULL,
+  "onequarter",
+  "onehalf",
+  "threequarters",
+  "questiondownsmall",
+  "oneeighth",
+  "threeeighths",
+  "fiveeighths",
+  "seveneighths",
+  "onethird",
+  "twothirds",
+  NULL,
+  NULL,
+  "zerosuperior",
+  "onesuperior",
+  "twosuperior",
+  "threesuperior",
+  "foursuperior",
+  "fivesuperior",
+  "sixsuperior",
+  "sevensuperior",
+  "eightsuperior",
+  "ninesuperior",
+  "zeroinferior",
+  "oneinferior",
+  "twoinferior",
+  "threeinferior",
+  "fourinferior",
+  "fiveinferior",
+  "sixinferior",
+  "seveninferior",
+  "eightinferior",
+  "nineinferior",
+  "centinferior",
+  "dollarinferior",
+  "periodinferior",
+  "commainferior",
+  "Agravesmall",
+  "Aacutesmall",
+  "Acircumflexsmall",
+  "Atildesmall",
+  "Adieresissmall",
+  "Aringsmall",
+  "AEsmall",
+  "Ccedillasmall",
+  "Egravesmall",
+  "Eacutesmall",
+  "Ecircumflexsmall",
+  "Edieresissmall",
+  "Igravesmall",
+  "Iacutesmall",
+  "Icircumflexsmall",
+  "Idieresissmall",
+  "Ethsmall",
+  "Ntildesmall",
+  "Ogravesmall",
+  "Oacutesmall",
+  "Ocircumflexsmall",
+  "Otildesmall",
+  "Odieresissmall",
+  "OEsmall",
+  "Oslashsmall",
+  "Ugravesmall",
+  "Uacutesmall",
+  "Ucircumflexsmall",
+  "Udieresissmall",
+  "Yacutesmall",
+  "Thornsmall",
+  "Ydieresissmall"
+};
+
+char *symbolEncoding[256] = {
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "space",
+  "exclam",
+  "universal",
+  "numbersign",
+  "existential",
+  "percent",
+  "ampersand",
+  "suchthat",
+  "parenleft",
+  "parenright",
+  "asteriskmath",
+  "plus",
+  "comma",
+  "minus",
+  "period",
+  "slash",
+  "zero",
+  "one",
+  "two",
+  "three",
+  "four",
+  "five",
+  "six",
+  "seven",
+  "eight",
+  "nine",
+  "colon",
+  "semicolon",
+  "less",
+  "equal",
+  "greater",
+  "question",
+  "congruent",
+  "Alpha",
+  "Beta",
+  "Chi",
+  "Delta",
+  "Epsilon",
+  "Phi",
+  "Gamma",
+  "Eta",
+  "Iota",
+  "theta1",
+  "Kappa",
+  "Lambda",
+  "Mu",
+  "Nu",
+  "Omicron",
+  "Pi",
+  "Theta",
+  "Rho",
+  "Sigma",
+  "Tau",
+  "Upsilon",
+  "sigma1",
+  "Omega",
+  "Xi",
+  "Psi",
+  "Zeta",
+  "bracketleft",
+  "therefore",
+  "bracketright",
+  "perpendicular",
+  "underscore",
+  "radicalex",
+  "alpha",
+  "beta",
+  "chi",
+  "delta",
+  "epsilon",
+  "phi",
+  "gamma",
+  "eta",
+  "iota",
+  "phi1",
+  "kappa",
+  "lambda",
+  "mu",
+  "nu",
+  "omicron",
+  "pi",
+  "theta",
+  "rho",
+  "sigma",
+  "tau",
+  "upsilon",
+  "omega1",
+  "omega",
+  "xi",
+  "psi",
+  "zeta",
+  "braceleft",
+  "bar",
+  "braceright",
+  "similar",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "Upsilon1",
+  "minute",
+  "lessequal",
+  "fraction",
+  "infinity",
+  "florin",
+  "club",
+  "diamond",
+  "heart",
+  "spade",
+  "arrowboth",
+  "arrowleft",
+  "arrowup",
+  "arrowright",
+  "arrowdown",
+  "degree",
+  "plusminus",
+  "second",
+  "greaterequal",
+  "multiply",
+  "proportional",
+  "partialdiff",
+  "bullet",
+  "divide",
+  "notequal",
+  "equivalence",
+  "approxequal",
+  "ellipsis",
+  "arrowvertex",
+  "arrowhorizex",
+  "carriagereturn",
+  "aleph",
+  "Ifraktur",
+  "Rfraktur",
+  "weierstrass",
+  "circlemultiply",
+  "circleplus",
+  "emptyset",
+  "intersection",
+  "union",
+  "propersuperset",
+  "reflexsuperset",
+  "notsubset",
+  "propersubset",
+  "reflexsubset",
+  "element",
+  "notelement",
+  "angle",
+  "gradient",
+  "registerserif",
+  "copyrightserif",
+  "trademarkserif",
+  "product",
+  "radical",
+  "dotmath",
+  "logicalnot",
+  "logicaland",
+  "logicalor",
+  "arrowdblboth",
+  "arrowdblleft",
+  "arrowdblup",
+  "arrowdblright",
+  "arrowdbldown",
+  "lozenge",
+  "angleleft",
+  "registersans",
+  "copyrightsans",
+  "trademarksans",
+  "summation",
+  "parenlefttp",
+  "parenleftex",
+  "parenleftbt",
+  "bracketlefttp",
+  "bracketleftex",
+  "bracketleftbt",
+  "bracelefttp",
+  "braceleftmid",
+  "braceleftbt",
+  "braceex",
+  NULL,
+  "angleright",
+  "integral",
+  "integraltp",
+  "integralex",
+  "integralbt",
+  "parenrighttp",
+  "parenrightex",
+  "parenrightbt",
+  "bracketrighttp",
+  "bracketrightex",
+  "bracketrightbt",
+  "bracerighttp",
+  "bracerightmid",
+  "bracerightbt",
+  NULL
+};
+
+char *zapfDingbatsEncoding[256] = {
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "space",
+  "a1",
+  "a2",
+  "a202",
+  "a3",
+  "a4",
+  "a5",
+  "a119",
+  "a118",
+  "a117",
+  "a11",
+  "a12",
+  "a13",
+  "a14",
+  "a15",
+  "a16",
+  "a105",
+  "a17",
+  "a18",
+  "a19",
+  "a20",
+  "a21",
+  "a22",
+  "a23",
+  "a24",
+  "a25",
+  "a26",
+  "a27",
+  "a28",
+  "a6",
+  "a7",
+  "a8",
+  "a9",
+  "a10",
+  "a29",
+  "a30",
+  "a31",
+  "a32",
+  "a33",
+  "a34",
+  "a35",
+  "a36",
+  "a37",
+  "a38",
+  "a39",
+  "a40",
+  "a41",
+  "a42",
+  "a43",
+  "a44",
+  "a45",
+  "a46",
+  "a47",
+  "a48",
+  "a49",
+  "a50",
+  "a51",
+  "a52",
+  "a53",
+  "a54",
+  "a55",
+  "a56",
+  "a57",
+  "a58",
+  "a59",
+  "a60",
+  "a61",
+  "a62",
+  "a63",
+  "a64",
+  "a65",
+  "a66",
+  "a67",
+  "a68",
+  "a69",
+  "a70",
+  "a71",
+  "a72",
+  "a73",
+  "a74",
+  "a203",
+  "a75",
+  "a204",
+  "a76",
+  "a77",
+  "a78",
+  "a79",
+  "a81",
+  "a82",
+  "a83",
+  "a84",
+  "a97",
+  "a98",
+  "a99",
+  "a100",
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  "a101",
+  "a102",
+  "a103",
+  "a104",
+  "a106",
+  "a107",
+  "a108",
+  "a112",
+  "a111",
+  "a110",
+  "a109",
+  "a120",
+  "a121",
+  "a122",
+  "a123",
+  "a124",
+  "a125",
+  "a126",
+  "a127",
+  "a128",
+  "a129",
+  "a130",
+  "a131",
+  "a132",
+  "a133",
+  "a134",
+  "a135",
+  "a136",
+  "a137",
+  "a138",
+  "a139",
+  "a140",
+  "a141",
+  "a142",
+  "a143",
+  "a144",
+  "a145",
+  "a146",
+  "a147",
+  "a148",
+  "a149",
+  "a150",
+  "a151",
+  "a152",
+  "a153",
+  "a154",
+  "a155",
+  "a156",
+  "a157",
+  "a158",
+  "a159",
+  "a160",
+  "a161",
+  "a163",
+  "a164",
+  "a196",
+  "a165",
+  "a192",
+  "a166",
+  "a167",
+  "a168",
+  "a169",
+  "a170",
+  "a171",
+  "a172",
+  "a173",
+  "a162",
+  "a174",
+  "a175",
+  "a176",
+  "a177",
+  "a178",
+  "a179",
+  "a193",
+  "a180",
+  "a199",
+  "a181",
+  "a200",
+  "a182",
+  NULL,
+  "a201",
+  "a183",
+  "a184",
+  "a197",
+  "a185",
+  "a194",
+  "a198",
+  "a186",
+  "a195",
+  "a187",
+  "a188",
+  "a189",
+  "a190",
+  "a191",
+  NULL
+};
diff --git a/pdf2swf/xpdf/FontEncodingTables.h b/pdf2swf/xpdf/FontEncodingTables.h
new file mode 100644 (file)
index 0000000..deee0a8
--- /dev/null
@@ -0,0 +1,20 @@
+//========================================================================
+//
+// FontEncodingTables.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef FONTENCODINGTABLES_H
+#define FONTENCODINGTABLES_H
+
+extern char *macRomanEncoding[];
+extern char *macExpertEncoding[];
+extern char *winAnsiEncoding[];
+extern char *standardEncoding[];
+extern char *expertEncoding[];
+extern char *symbolEncoding[];
+extern char *zapfDingbatsEncoding[];
+
+#endif
diff --git a/pdf2swf/xpdf/Function.cc b/pdf2swf/xpdf/Function.cc
new file mode 100644 (file)
index 0000000..64ea60c
--- /dev/null
@@ -0,0 +1,1520 @@
+//========================================================================
+//
+// Function.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+#include "gmem.h"
+#include "Object.h"
+#include "Dict.h"
+#include "Stream.h"
+#include "Error.h"
+#include "Function.h"
+
+//------------------------------------------------------------------------
+// Function
+//------------------------------------------------------------------------
+
+Function::Function() {
+}
+
+Function::~Function() {
+}
+
+Function *Function::parse(Object *funcObj) {
+  Function *func;
+  Dict *dict;
+  int funcType;
+  Object obj1;
+
+  if (funcObj->isStream()) {
+    dict = funcObj->streamGetDict();
+  } else if (funcObj->isDict()) {
+    dict = funcObj->getDict();
+  } else if (funcObj->isName("Identity")) {
+    return new IdentityFunction();
+  } else {
+    error(-1, "Expected function dictionary or stream");
+    return NULL;
+  }
+
+  if (!dict->lookup("FunctionType", &obj1)->isInt()) {
+    error(-1, "Function type is missing or wrong type");
+    obj1.free();
+    return NULL;
+  }
+  funcType = obj1.getInt();
+  obj1.free();
+
+  if (funcType == 0) {
+    func = new SampledFunction(funcObj, dict);
+  } else if (funcType == 2) {
+    func = new ExponentialFunction(funcObj, dict);
+  } else if (funcType == 3) {
+    func = new StitchingFunction(funcObj, dict);
+  } else if (funcType == 4) {
+    func = new PostScriptFunction(funcObj, dict);
+  } else {
+    error(-1, "Unimplemented function type (%d)", funcType);
+    return NULL;
+  }
+  if (!func->isOk()) {
+    delete func;
+    return NULL;
+  }
+
+  return func;
+}
+
+GBool Function::init(Dict *dict) {
+  Object obj1, obj2;
+  int i;
+
+  //----- Domain
+  if (!dict->lookup("Domain", &obj1)->isArray()) {
+    error(-1, "Function is missing domain");
+    goto err2;
+  }
+  m = obj1.arrayGetLength() / 2;
+  if (m > funcMaxInputs) {
+    error(-1, "Functions with more than %d inputs are unsupported",
+         funcMaxInputs);
+    goto err2;
+  }
+  for (i = 0; i < m; ++i) {
+    obj1.arrayGet(2*i, &obj2);
+    if (!obj2.isNum()) {
+      error(-1, "Illegal value in function domain array");
+      goto err1;
+    }
+    domain[i][0] = obj2.getNum();
+    obj2.free();
+    obj1.arrayGet(2*i+1, &obj2);
+    if (!obj2.isNum()) {
+      error(-1, "Illegal value in function domain array");
+      goto err1;
+    }
+    domain[i][1] = obj2.getNum();
+    obj2.free();
+  }
+  obj1.free();
+
+  //----- Range
+  hasRange = gFalse;
+  n = 0;
+  if (dict->lookup("Range", &obj1)->isArray()) {
+    hasRange = gTrue;
+    n = obj1.arrayGetLength() / 2;
+    if (n > funcMaxOutputs) {
+      error(-1, "Functions with more than %d outputs are unsupported",
+           funcMaxOutputs);
+      goto err2;
+    }
+    for (i = 0; i < n; ++i) {
+      obj1.arrayGet(2*i, &obj2);
+      if (!obj2.isNum()) {
+       error(-1, "Illegal value in function range array");
+       goto err1;
+      }
+      range[i][0] = obj2.getNum();
+      obj2.free();
+      obj1.arrayGet(2*i+1, &obj2);
+      if (!obj2.isNum()) {
+       error(-1, "Illegal value in function range array");
+       goto err1;
+      }
+      range[i][1] = obj2.getNum();
+      obj2.free();
+    }
+  }
+  obj1.free();
+
+  return gTrue;
+
+ err1:
+  obj2.free();
+ err2:
+  obj1.free();
+  return gFalse;
+}
+
+//------------------------------------------------------------------------
+// IdentityFunction
+//------------------------------------------------------------------------
+
+IdentityFunction::IdentityFunction() {
+  int i;
+
+  // fill these in with arbitrary values just in case they get used
+  // somewhere
+  m = funcMaxInputs;
+  n = funcMaxOutputs;
+  for (i = 0; i < funcMaxInputs; ++i) {
+    domain[i][0] = 0;
+    domain[i][1] = 1;
+  }
+  hasRange = gFalse;
+}
+
+IdentityFunction::~IdentityFunction() {
+}
+
+void IdentityFunction::transform(double *in, double *out) {
+  int i;
+
+  for (i = 0; i < funcMaxOutputs; ++i) {
+    out[i] = in[i];
+  }
+}
+
+//------------------------------------------------------------------------
+// SampledFunction
+//------------------------------------------------------------------------
+
+SampledFunction::SampledFunction(Object *funcObj, Dict *dict) {
+  Stream *str;
+  int nSamples, sampleBits;
+  double sampleMul;
+  Object obj1, obj2;
+  Guint buf, bitMask;
+  int bits;
+  int s;
+  int i;
+
+  samples = NULL;
+  ok = gFalse;
+
+  //----- initialize the generic stuff
+  if (!init(dict)) {
+    goto err1;
+  }
+  if (!hasRange) {
+    error(-1, "Type 0 function is missing range");
+    goto err1;
+  }
+
+  //----- get the stream
+  if (!funcObj->isStream()) {
+    error(-1, "Type 0 function isn't a stream");
+    goto err1;
+  }
+  str = funcObj->getStream();
+
+  //----- Size
+  if (!dict->lookup("Size", &obj1)->isArray() ||
+      obj1.arrayGetLength() != m) {
+    error(-1, "Function has missing or invalid size array");
+    goto err2;
+  }
+  for (i = 0; i < m; ++i) {
+    obj1.arrayGet(i, &obj2);
+    if (!obj2.isInt()) {
+      error(-1, "Illegal value in function size array");
+      goto err3;
+    }
+    sampleSize[i] = obj2.getInt();
+    obj2.free();
+  }
+  obj1.free();
+
+  //----- BitsPerSample
+  if (!dict->lookup("BitsPerSample", &obj1)->isInt()) {
+    error(-1, "Function has missing or invalid BitsPerSample");
+    goto err2;
+  }
+  sampleBits = obj1.getInt();
+  sampleMul = 1.0 / (double)((1 << sampleBits) - 1);
+  obj1.free();
+
+  //----- Encode
+  if (dict->lookup("Encode", &obj1)->isArray() &&
+      obj1.arrayGetLength() == 2*m) {
+    for (i = 0; i < m; ++i) {
+      obj1.arrayGet(2*i, &obj2);
+      if (!obj2.isNum()) {
+       error(-1, "Illegal value in function encode array");
+       goto err3;
+      }
+      encode[i][0] = obj2.getNum();
+      obj2.free();
+      obj1.arrayGet(2*i+1, &obj2);
+      if (!obj2.isNum()) {
+       error(-1, "Illegal value in function encode array");
+       goto err3;
+      }
+      encode[i][1] = obj2.getNum();
+      obj2.free();
+    }
+  } else {
+    for (i = 0; i < m; ++i) {
+      encode[i][0] = 0;
+      encode[i][1] = sampleSize[i] - 1;
+    }
+  }
+  obj1.free();
+
+  //----- Decode
+  if (dict->lookup("Decode", &obj1)->isArray() &&
+      obj1.arrayGetLength() == 2*n) {
+    for (i = 0; i < n; ++i) {
+      obj1.arrayGet(2*i, &obj2);
+      if (!obj2.isNum()) {
+       error(-1, "Illegal value in function decode array");
+       goto err3;
+      }
+      decode[i][0] = obj2.getNum();
+      obj2.free();
+      obj1.arrayGet(2*i+1, &obj2);
+      if (!obj2.isNum()) {
+       error(-1, "Illegal value in function decode array");
+       goto err3;
+      }
+      decode[i][1] = obj2.getNum();
+      obj2.free();
+    }
+  } else {
+    for (i = 0; i < n; ++i) {
+      decode[i][0] = range[i][0];
+      decode[i][1] = range[i][1];
+    }
+  }
+  obj1.free();
+
+  //----- samples
+  nSamples = n;
+  for (i = 0; i < m; ++i)
+    nSamples *= sampleSize[i];
+  samples = (double *)gmalloc(nSamples * sizeof(double));
+  buf = 0;
+  bits = 0;
+  bitMask = (1 << sampleBits) - 1;
+  str->reset();
+  for (i = 0; i < nSamples; ++i) {
+    if (sampleBits == 8) {
+      s = str->getChar();
+    } else if (sampleBits == 16) {
+      s = str->getChar();
+      s = (s << 8) + str->getChar();
+    } else if (sampleBits == 32) {
+      s = str->getChar();
+      s = (s << 8) + str->getChar();
+      s = (s << 8) + str->getChar();
+      s = (s << 8) + str->getChar();
+    } else {
+      while (bits < sampleBits) {
+       buf = (buf << 8) | (str->getChar() & 0xff);
+       bits += 8;
+      }
+      s = (buf >> (bits - sampleBits)) & bitMask;
+      bits -= sampleBits;
+    }
+    samples[i] = (double)s * sampleMul;
+  }
+  str->close();
+
+  ok = gTrue;
+  return;
+
+ err3:
+  obj2.free();
+ err2:
+  obj1.free();
+ err1:
+  return;
+}
+
+SampledFunction::~SampledFunction() {
+  if (samples) {
+    gfree(samples);
+  }
+}
+
+SampledFunction::SampledFunction(SampledFunction *func) {
+  int nSamples, i;
+
+  memcpy(this, func, sizeof(SampledFunction));
+
+  nSamples = n;
+  for (i = 0; i < m; ++i) {
+    nSamples *= sampleSize[i];
+  }
+  samples = (double *)gmalloc(nSamples * sizeof(double));
+  memcpy(samples, func->samples, nSamples * sizeof(double));
+}
+
+void SampledFunction::transform(double *in, double *out) {
+  double x;
+  int e[2][funcMaxInputs];
+  double efrac[funcMaxInputs];
+  double s0[1 << funcMaxInputs], s1[1 << funcMaxInputs];
+  int i, j, k, idx;
+
+  // map input values into sample array
+  for (i = 0; i < m; ++i) {
+    x = ((in[i] - domain[i][0]) / (domain[i][1] - domain[i][0])) *
+        (encode[i][1] - encode[i][0]) + encode[i][0];
+    if (x < 0) {
+      x = 0;
+    } else if (x > sampleSize[i] - 1) {
+      x = sampleSize[i] - 1;
+    }
+    e[0][i] = (int)floor(x);
+    e[1][i] = (int)ceil(x);
+    efrac[i] = x - e[0][i];
+  }
+
+  // for each output, do m-linear interpolation
+  for (i = 0; i < n; ++i) {
+
+    // pull 2^m values out of the sample array
+    for (j = 0; j < (1<<m); ++j) {
+      idx = e[j & 1][m - 1];
+      for (k = m - 2; k >= 0; --k) {
+       idx = idx * sampleSize[k] + e[(j >> k) & 1][k];
+      }
+      idx = idx * n + i;
+      s0[j] = samples[idx];
+    }
+
+    // do m sets of interpolations
+    for (j = 0; j < m; ++j) {
+      for (k = 0; k < (1 << (m - j)); k += 2) {
+       s1[k >> 1] = (1 - efrac[j]) * s0[k] + efrac[j] * s0[k+1];
+      }
+      memcpy(s0, s1, (1 << (m - j - 1)) * sizeof(double));
+    }
+
+    // map output value to range
+    out[i] = s0[0] * (decode[i][1] - decode[i][0]) + decode[i][0];
+    if (out[i] < range[i][0]) {
+      out[i] = range[i][0];
+    } else if (out[i] > range[i][1]) {
+      out[i] = range[i][1];
+    }
+  }
+}
+
+//------------------------------------------------------------------------
+// ExponentialFunction
+//------------------------------------------------------------------------
+
+ExponentialFunction::ExponentialFunction(Object *funcObj, Dict *dict) {
+  Object obj1, obj2;
+  GBool hasN;
+  int i;
+
+  ok = gFalse;
+
+  //----- initialize the generic stuff
+  if (!init(dict)) {
+    goto err1;
+  }
+  if (m != 1) {
+    error(-1, "Exponential function with more than one input");
+    goto err1;
+  }
+  hasN = hasRange;
+
+  //----- default values
+  for (i = 0; i < funcMaxOutputs; ++i) {
+    c0[i] = 0;
+    c1[i] = 1;
+  }
+
+  //----- C0
+  if (dict->lookup("C0", &obj1)->isArray()) {
+    if (!hasN) {
+      n = obj1.arrayGetLength();
+      hasN = gTrue;
+    } else if (obj1.arrayGetLength() != n) {
+      error(-1, "Function's C0 array is wrong length");
+      goto err2;
+    }
+    for (i = 0; i < n; ++i) {
+      obj1.arrayGet(i, &obj2);
+      if (!obj2.isNum()) {
+       error(-1, "Illegal value in function C0 array");
+       goto err3;
+      }
+      c0[i] = obj2.getNum();
+      obj2.free();
+    }
+  }
+  obj1.free();
+
+  //----- C1
+  if (dict->lookup("C1", &obj1)->isArray()) {
+    if (!hasN) {
+      n = obj1.arrayGetLength();
+      hasN = gTrue;
+    } else if (obj1.arrayGetLength() != n) {
+      error(-1, "Function's C1 array is wrong length");
+      goto err2;
+    }
+    for (i = 0; i < n; ++i) {
+      obj1.arrayGet(i, &obj2);
+      if (!obj2.isNum()) {
+       error(-1, "Illegal value in function C1 array");
+       goto err3;
+      }
+      c1[i] = obj2.getNum();
+      obj2.free();
+    }
+  }
+  obj1.free();
+
+  //----- N (exponent)
+  if (!dict->lookup("N", &obj1)->isNum()) {
+    error(-1, "Function has missing or invalid N");
+    goto err2;
+  }
+  e = obj1.getNum();
+  obj1.free();
+
+  // this isn't supposed to happen, but I've run into (broken) PDF
+  // files where it does
+  if (!hasN) {
+    error(-1, "Exponential function does not define number of output values");
+    n = 1;
+  }
+
+  ok = gTrue;
+  return;
+
+ err3:
+  obj2.free();
+ err2:
+  obj1.free();
+ err1:
+  return;
+}
+
+ExponentialFunction::~ExponentialFunction() {
+}
+
+ExponentialFunction::ExponentialFunction(ExponentialFunction *func) {
+  memcpy(this, func, sizeof(ExponentialFunction));
+}
+
+void ExponentialFunction::transform(double *in, double *out) {
+  double x;
+  int i;
+
+  if (in[0] < domain[0][0]) {
+    x = domain[0][0];
+  } else if (in[0] > domain[0][1]) {
+    x = domain[0][1];
+  } else {
+    x = in[0];
+  }
+  for (i = 0; i < n; ++i) {
+    out[i] = c0[i] + pow(x, e) * (c1[i] - c0[i]);
+    if (hasRange) {
+      if (out[i] < range[i][0]) {
+       out[i] = range[i][0];
+      } else if (out[i] > range[i][1]) {
+       out[i] = range[i][1];
+      }
+    }
+  }
+  return;
+}
+
+//------------------------------------------------------------------------
+// StitchingFunction
+//------------------------------------------------------------------------
+
+StitchingFunction::StitchingFunction(Object *funcObj, Dict *dict) {
+  Object obj1, obj2;
+  int i;
+
+  ok = gFalse;
+  funcs = NULL;
+  bounds = NULL;
+  encode = NULL;
+
+  //----- initialize the generic stuff
+  if (!init(dict)) {
+    goto err1;
+  }
+  if (m != 1) {
+    error(-1, "Stitching function with more than one input");
+    goto err1;
+  }
+
+  //----- Functions
+  if (!dict->lookup("Functions", &obj1)->isArray()) {
+    error(-1, "Missing 'Functions' entry in stitching function");
+    goto err1;
+  }
+  k = obj1.arrayGetLength();
+  funcs = (Function **)gmalloc(k * sizeof(Function *));
+  bounds = (double *)gmalloc((k + 1) * sizeof(double));
+  encode = (double *)gmalloc(2 * k * sizeof(double));
+  for (i = 0; i < k; ++i) {
+    funcs[i] = NULL;
+  }
+  for (i = 0; i < k; ++i) {
+    if (!(funcs[i] = Function::parse(obj1.arrayGet(i, &obj2)))) {
+      goto err2;
+    }
+    if (i > 0 && (funcs[i]->getInputSize() != 1 ||
+                 funcs[i]->getOutputSize() != funcs[0]->getOutputSize())) {
+      error(-1, "Incompatible subfunctions in stitching function");
+      goto err2;
+    }
+    obj2.free();
+  }
+  obj1.free();
+
+  //----- Bounds
+  if (!dict->lookup("Bounds", &obj1)->isArray() ||
+      obj1.arrayGetLength() != k - 1) {
+    error(-1, "Missing or invalid 'Bounds' entry in stitching function");
+    goto err1;
+  }
+  bounds[0] = domain[0][0];
+  for (i = 1; i < k; ++i) {
+    if (!obj1.arrayGet(i - 1, &obj2)->isNum()) {
+      error(-1, "Invalid type in 'Bounds' array in stitching function");
+      goto err2;
+    }
+    bounds[i] = obj2.getNum();
+    obj2.free();
+  }
+  bounds[k] = domain[0][1];
+  obj1.free();
+
+  //----- Encode
+  if (!dict->lookup("Encode", &obj1)->isArray() ||
+      obj1.arrayGetLength() != 2 * k) {
+    error(-1, "Missing or invalid 'Encode' entry in stitching function");
+    goto err1;
+  }
+  for (i = 0; i < 2 * k; ++i) {
+    if (!obj1.arrayGet(i, &obj2)->isNum()) {
+      error(-1, "Invalid type in 'Encode' array in stitching function");
+      goto err2;
+    }
+    encode[i] = obj2.getNum();
+    obj2.free();
+  }
+  obj1.free();
+
+  ok = gTrue;
+  return;
+
+ err2:
+  obj2.free();
+ err1:
+  obj1.free();
+}
+
+StitchingFunction::StitchingFunction(StitchingFunction *func) {
+  k = func->k;
+  funcs = (Function **)gmalloc(k * sizeof(Function *));
+  memcpy(funcs, func->funcs, k * sizeof(Function *));
+  bounds = (double *)gmalloc((k + 1) * sizeof(double));
+  memcpy(bounds, func->bounds, (k + 1) * sizeof(double));
+  encode = (double *)gmalloc(2 * k * sizeof(double));
+  memcpy(encode, func->encode, 2 * k * sizeof(double));
+  ok = gTrue;
+}
+
+StitchingFunction::~StitchingFunction() {
+  int i;
+
+  for (i = 0; i < k; ++i) {
+    if (funcs[i]) {
+      delete funcs[i];
+    }
+  }
+  gfree(funcs);
+  gfree(bounds);
+  gfree(encode);
+}
+
+void StitchingFunction::transform(double *in, double *out) {
+  double x;
+  int i;
+
+  if (in[0] < domain[0][0]) {
+    x = domain[0][0];
+  } else if (in[0] > domain[0][1]) {
+    x = domain[0][1];
+  } else {
+    x = in[0];
+  }
+  for (i = 0; i < k - 1; ++i) {
+    if (x < bounds[i+1]) {
+      break;
+    }
+  }
+  x = encode[2*i] + ((x - bounds[i]) / (bounds[i+1] - bounds[i])) *
+                    (encode[2*i+1] - encode[2*i]);
+  funcs[i]->transform(&x, out);
+}
+
+//------------------------------------------------------------------------
+// PostScriptFunction
+//------------------------------------------------------------------------
+
+enum PSOp {
+  psOpAbs,
+  psOpAdd,
+  psOpAnd,
+  psOpAtan,
+  psOpBitshift,
+  psOpCeiling,
+  psOpCopy,
+  psOpCos,
+  psOpCvi,
+  psOpCvr,
+  psOpDiv,
+  psOpDup,
+  psOpEq,
+  psOpExch,
+  psOpExp,
+  psOpFalse,
+  psOpFloor,
+  psOpGe,
+  psOpGt,
+  psOpIdiv,
+  psOpIndex,
+  psOpLe,
+  psOpLn,
+  psOpLog,
+  psOpLt,
+  psOpMod,
+  psOpMul,
+  psOpNe,
+  psOpNeg,
+  psOpNot,
+  psOpOr,
+  psOpPop,
+  psOpRoll,
+  psOpRound,
+  psOpSin,
+  psOpSqrt,
+  psOpSub,
+  psOpTrue,
+  psOpTruncate,
+  psOpXor,
+  psOpIf,
+  psOpIfelse,
+  psOpReturn
+};
+
+// Note: 'if' and 'ifelse' are parsed separately.
+// The rest are listed here in alphabetical order.
+// The index in this table is equivalent to the entry in PSOp.
+char *psOpNames[] = {
+  "abs",
+  "add",
+  "and",
+  "atan",
+  "bitshift",
+  "ceiling",
+  "copy",
+  "cos",
+  "cvi",
+  "cvr",
+  "div",
+  "dup",
+  "eq",
+  "exch",
+  "exp",
+  "false",
+  "floor",
+  "ge",
+  "gt",
+  "idiv",
+  "index",
+  "le",
+  "ln",
+  "log",
+  "lt",
+  "mod",
+  "mul",
+  "ne",
+  "neg",
+  "not",
+  "or",
+  "pop",
+  "roll",
+  "round",
+  "sin",
+  "sqrt",
+  "sub",
+  "true",
+  "truncate",
+  "xor"
+};
+
+#define nPSOps (sizeof(psOpNames) / sizeof(char *))
+
+enum PSObjectType {
+  psBool,
+  psInt,
+  psReal,
+  psOperator,
+  psBlock
+};
+
+// In the code array, 'if'/'ifelse' operators take up three slots
+// plus space for the code in the subclause(s).
+//
+//         +---------------------------------+
+//         | psOperator: psOpIf / psOpIfelse |
+//         +---------------------------------+
+//         | psBlock: ptr=<A>                |
+//         +---------------------------------+
+//         | psBlock: ptr=<B>                |
+//         +---------------------------------+
+//         | if clause                       |
+//         | ...                             |
+//         | psOperator: psOpReturn          |
+//         +---------------------------------+
+//     <A> | else clause                     |
+//         | ...                             |
+//         | psOperator: psOpReturn          |
+//         +---------------------------------+
+//     <B> | ...                             |
+//
+// For 'if', pointer <A> is present in the code stream but unused.
+
+struct PSObject {
+  PSObjectType type;
+  union {
+    GBool booln;               // boolean (stack only)
+    int intg;                  // integer (stack and code)
+    double real;               // real (stack and code)
+    PSOp op;                   // operator (code only)
+    int blk;                   // if/ifelse block pointer (code only)
+  };
+};
+
+#define psStackSize 100
+
+class PSStack {
+public:
+
+  PSStack() { sp = psStackSize; }
+  void pushBool(GBool booln);
+  void pushInt(int intg);
+  void pushReal(double real);
+  GBool popBool();
+  int popInt();
+  double popNum();
+  GBool empty() { return sp == psStackSize; }
+  GBool topIsInt() { return sp < psStackSize && stack[sp].type == psInt; }
+  GBool topTwoAreInts()
+    { return sp < psStackSize - 1 &&
+            stack[sp].type == psInt &&
+             stack[sp+1].type == psInt; }
+  GBool topIsReal() { return sp < psStackSize && stack[sp].type == psReal; }
+  GBool topTwoAreNums()
+    { return sp < psStackSize - 1 &&
+            (stack[sp].type == psInt || stack[sp].type == psReal) &&
+            (stack[sp+1].type == psInt || stack[sp+1].type == psReal); }
+  void copy(int n);
+  void roll(int n, int j);
+  void index(int i);
+  void pop();
+
+private:
+
+  GBool checkOverflow(int n = 1);
+  GBool checkUnderflow();
+  GBool checkType(PSObjectType t1, PSObjectType t2);
+
+  PSObject stack[psStackSize];
+  int sp;
+};
+
+GBool PSStack::checkOverflow(int n) {
+  if (sp - n < 0) {
+    error(-1, "Stack overflow in PostScript function");
+    return gFalse;
+  }
+  return gTrue;
+}
+
+GBool PSStack::checkUnderflow() {
+  if (sp == psStackSize) {
+    error(-1, "Stack underflow in PostScript function");
+    return gFalse;
+  }
+  return gTrue;
+}
+
+GBool PSStack::checkType(PSObjectType t1, PSObjectType t2) {
+  if (stack[sp].type != t1 && stack[sp].type != t2) {
+    error(-1, "Type mismatch in PostScript function");
+    return gFalse;
+  }
+  return gTrue;
+}
+
+void PSStack::pushBool(GBool booln) {
+  if (checkOverflow()) {
+    stack[--sp].type = psBool;
+    stack[sp].booln = booln;
+  }
+}
+
+void PSStack::pushInt(int intg) {
+  if (checkOverflow()) {
+    stack[--sp].type = psInt;
+    stack[sp].intg = intg;
+  }
+}
+
+void PSStack::pushReal(double real) {
+  if (checkOverflow()) {
+    stack[--sp].type = psReal;
+    stack[sp].real = real;
+  }
+}
+
+GBool PSStack::popBool() {
+  if (checkUnderflow() && checkType(psBool, psBool)) {
+    return stack[sp++].booln;
+  }
+  return gFalse;
+}
+
+int PSStack::popInt() {
+  if (checkUnderflow() && checkType(psInt, psInt)) {
+    return stack[sp++].intg;
+  }
+  return 0;
+}
+
+double PSStack::popNum() {
+  double ret;
+
+  if (checkUnderflow() && checkType(psInt, psReal)) {
+    ret = (stack[sp].type == psInt) ? (double)stack[sp].intg : stack[sp].real;
+    ++sp;
+    return ret;
+  }
+  return 0;
+}
+
+void PSStack::copy(int n) {
+  int i;
+
+  if (!checkOverflow(n)) {
+    return;
+  }
+  for (i = sp + n - 1; i <= sp; ++i) {
+    stack[i - n] = stack[i];
+  }
+  sp -= n;
+}
+
+void PSStack::roll(int n, int j) {
+  PSObject obj;
+  int i, k;
+
+  if (j >= 0) {
+    j %= n;
+  } else {
+    j = -j % n;
+    if (j != 0) {
+      j = n - j;
+    }
+  }
+  if (n <= 0 || j == 0) {
+    return;
+  }
+  for (i = 0; i < j; ++i) {
+    obj = stack[sp];
+    for (k = sp; k < sp + n - 1; ++k) {
+      stack[k] = stack[k+1];
+    }
+    stack[sp + n - 1] = obj;
+  }
+}
+
+void PSStack::index(int i) {
+  if (!checkOverflow()) {
+    return;
+  }
+  --sp;
+  stack[sp] = stack[sp + 1 + i];
+}
+
+void PSStack::pop() {
+  if (!checkUnderflow()) {
+    return;
+  }
+  ++sp;
+}
+
+PostScriptFunction::PostScriptFunction(Object *funcObj, Dict *dict) {
+  Stream *str;
+  int codePtr;
+  GString *tok;
+
+  code = NULL;
+  codeSize = 0;
+  ok = gFalse;
+
+  //----- initialize the generic stuff
+  if (!init(dict)) {
+    goto err1;
+  }
+  if (!hasRange) {
+    error(-1, "Type 4 function is missing range");
+    goto err1;
+  }
+
+  //----- get the stream
+  if (!funcObj->isStream()) {
+    error(-1, "Type 4 function isn't a stream");
+    goto err1;
+  }
+  str = funcObj->getStream();
+
+  //----- parse the function
+  str->reset();
+  if (!(tok = getToken(str)) || tok->cmp("{")) {
+    error(-1, "Expected '{' at start of PostScript function");
+    if (tok) {
+      delete tok;
+    }
+    goto err1;
+  }
+  delete tok;
+  codePtr = 0;
+  if (!parseCode(str, &codePtr)) {
+    goto err2;
+  }
+  str->close();
+
+  ok = gTrue;
+
+ err2:
+  str->close();
+ err1:
+  return;
+}
+
+PostScriptFunction::PostScriptFunction(PostScriptFunction *func) {
+  memcpy(this, func, sizeof(PostScriptFunction));
+  code = (PSObject *)gmalloc(codeSize * sizeof(PSObject));
+  memcpy(code, func->code, codeSize * sizeof(PSObject));
+}
+
+PostScriptFunction::~PostScriptFunction() {
+  gfree(code);
+}
+
+void PostScriptFunction::transform(double *in, double *out) {
+  PSStack *stack;
+  int i;
+
+  stack = new PSStack();
+  for (i = 0; i < m; ++i) {
+    //~ may need to check for integers here
+    stack->pushReal(in[i]);
+  }
+  exec(stack, 0);
+  for (i = n - 1; i >= 0; --i) {
+    out[i] = stack->popNum();
+    if (out[i] < range[i][0]) {
+      out[i] = range[i][0];
+    } else if (out[i] > range[i][1]) {
+      out[i] = range[i][1];
+    }
+  }
+  // if (!stack->empty()) {
+  //   error(-1, "Extra values on stack at end of PostScript function");
+  // }
+  delete stack;
+}
+
+GBool PostScriptFunction::parseCode(Stream *str, int *codePtr) {
+  GString *tok;
+  char *p;
+  GBool isReal;
+  int opPtr, elsePtr;
+  int a, b, mid, cmp;
+
+  while (1) {
+    if (!(tok = getToken(str))) {
+      error(-1, "Unexpected end of PostScript function stream");
+      return gFalse;
+    }
+    p = tok->getCString();
+    if (isdigit(*p) || *p == '.' || *p == '-') {
+      isReal = gFalse;
+      for (++p; *p; ++p) {
+       if (*p == '.') {
+         isReal = gTrue;
+         break;
+       }
+      }
+      resizeCode(*codePtr);
+      if (isReal) {
+       code[*codePtr].type = psReal;
+       code[*codePtr].real = atof(tok->getCString());
+      } else {
+       code[*codePtr].type = psInt;
+       code[*codePtr].intg = atoi(tok->getCString());
+      }
+      ++*codePtr;
+      delete tok;
+    } else if (!tok->cmp("{")) {
+      delete tok;
+      opPtr = *codePtr;
+      *codePtr += 3;
+      resizeCode(opPtr + 2);
+      if (!parseCode(str, codePtr)) {
+       return gFalse;
+      }
+      if (!(tok = getToken(str))) {
+       error(-1, "Unexpected end of PostScript function stream");
+       return gFalse;
+      }
+      if (!tok->cmp("{")) {
+       elsePtr = *codePtr;
+       if (!parseCode(str, codePtr)) {
+         return gFalse;
+       }
+      } else {
+       elsePtr = -1;
+      }
+      delete tok;
+      if (!(tok = getToken(str))) {
+       error(-1, "Unexpected end of PostScript function stream");
+       return gFalse;
+      }
+      if (!tok->cmp("if")) {
+       if (elsePtr >= 0) {
+         error(-1, "Got 'if' operator with two blocks in PostScript function");
+         return gFalse;
+       }
+       code[opPtr].type = psOperator;
+       code[opPtr].op = psOpIf;
+       code[opPtr+2].type = psBlock;
+       code[opPtr+2].blk = *codePtr;
+      } else if (!tok->cmp("ifelse")) {
+       if (elsePtr < 0) {
+         error(-1, "Got 'ifelse' operator with one blocks in PostScript function");
+         return gFalse;
+       }
+       code[opPtr].type = psOperator;
+       code[opPtr].op = psOpIfelse;
+       code[opPtr+1].type = psBlock;
+       code[opPtr+1].blk = elsePtr;
+       code[opPtr+2].type = psBlock;
+       code[opPtr+2].blk = *codePtr;
+      } else {
+       error(-1, "Expected if/ifelse operator in PostScript function");
+       delete tok;
+       return gFalse;
+      }
+      delete tok;
+    } else if (!tok->cmp("}")) {
+      delete tok;
+      resizeCode(*codePtr);
+      code[*codePtr].type = psOperator;
+      code[*codePtr].op = psOpReturn;
+      ++*codePtr;
+      break;
+    } else {
+      a = -1;
+      b = nPSOps;
+      // invariant: psOpNames[a] < tok < psOpNames[b]
+      while (b - a > 1) {
+       mid = (a + b) / 2;
+       cmp = tok->cmp(psOpNames[mid]);
+       if (cmp > 0) {
+         a = mid;
+       } else if (cmp < 0) {
+         b = mid;
+       } else {
+         a = b = mid;
+       }
+      }
+      if (cmp != 0) {
+       error(-1, "Unknown operator '%s' in PostScript function",
+             tok->getCString());
+       delete tok;
+       return gFalse;
+      }
+      delete tok;
+      resizeCode(*codePtr);
+      code[*codePtr].type = psOperator;
+      code[*codePtr].op = (PSOp)a;
+      ++*codePtr;
+    }
+  }
+  return gTrue;
+}
+
+GString *PostScriptFunction::getToken(Stream *str) {
+  GString *s;
+  int c;
+
+  s = new GString();
+  do {
+    c = str->getChar();
+  } while (c != EOF && isspace(c));
+  if (c == '{' || c == '}') {
+    s->append((char)c);
+  } else if (isdigit(c) || c == '.' || c == '-') {
+    while (1) {
+      s->append((char)c);
+      c = str->lookChar();
+      if (c == EOF || !(isdigit(c) || c == '.' || c == '-')) {
+       break;
+      }
+      str->getChar();
+    }
+  } else {
+    while (1) {
+      s->append((char)c);
+      c = str->lookChar();
+      if (c == EOF || !isalnum(c)) {
+       break;
+      }
+      str->getChar();
+    }
+  }
+  return s;
+}
+
+void PostScriptFunction::resizeCode(int newSize) {
+  if (newSize >= codeSize) {
+    codeSize += 64;
+    code = (PSObject *)grealloc(code, codeSize * sizeof(PSObject));
+  }
+}
+
+void PostScriptFunction::exec(PSStack *stack, int codePtr) {
+  int i1, i2;
+  double r1, r2;
+  GBool b1, b2;
+
+  while (1) {
+    switch (code[codePtr].type) {
+    case psInt:
+      stack->pushInt(code[codePtr++].intg);
+      break;
+    case psReal:
+      stack->pushReal(code[codePtr++].real);
+      break;
+    case psOperator:
+      switch (code[codePtr++].op) {
+      case psOpAbs:
+       if (stack->topIsInt()) {
+         stack->pushInt(abs(stack->popInt()));
+       } else {
+         stack->pushReal(fabs(stack->popNum()));
+       }
+       break;
+      case psOpAdd:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         stack->pushInt(i1 + i2);
+       } else {
+         r2 = stack->popNum();
+         r1 = stack->popNum();
+         stack->pushReal(r1 + r2);
+       }
+       break;
+      case psOpAnd:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         stack->pushInt(i1 & i2);
+       } else {
+         b2 = stack->popBool();
+         b1 = stack->popBool();
+         stack->pushReal(b1 && b2);
+       }
+       break;
+      case psOpAtan:
+       r2 = stack->popNum();
+       r1 = stack->popNum();
+       stack->pushReal(atan2(r1, r2));
+       break;
+      case psOpBitshift:
+       i2 = stack->popInt();
+       i1 = stack->popInt();
+       if (i2 > 0) {
+         stack->pushInt(i1 << i2);
+       } else if (i2 < 0) {
+         stack->pushInt((int)((Guint)i1 >> i2));
+       } else {
+         stack->pushInt(i1);
+       }
+       break;
+      case psOpCeiling:
+       if (!stack->topIsInt()) {
+         stack->pushReal(ceil(stack->popNum()));
+       }
+       break;
+      case psOpCopy:
+       stack->copy(stack->popInt());
+       break;
+      case psOpCos:
+       stack->pushReal(cos(stack->popNum()));
+       break;
+      case psOpCvi:
+       if (!stack->topIsInt()) {
+         stack->pushInt((int)stack->popNum());
+       }
+       break;
+      case psOpCvr:
+       if (!stack->topIsReal()) {
+         stack->pushReal(stack->popNum());
+       }
+       break;
+      case psOpDiv:
+       r2 = stack->popNum();
+       r1 = stack->popNum();
+       stack->pushReal(r1 / r2);
+       break;
+      case psOpDup:
+       stack->copy(1);
+       break;
+      case psOpEq:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         stack->pushBool(i1 == i2);
+       } else if (stack->topTwoAreNums()) {
+         r2 = stack->popNum();
+         r1 = stack->popNum();
+         stack->pushBool(r1 == r2);
+       } else {
+         b2 = stack->popBool();
+         b1 = stack->popBool();
+         stack->pushBool(b1 == b2);
+       }
+       break;
+      case psOpExch:
+       stack->roll(2, 1);
+       break;
+      case psOpExp:
+       r2 = stack->popInt();
+       r1 = stack->popInt();
+       stack->pushReal(pow(r1, r2));
+       break;
+      case psOpFalse:
+       stack->pushBool(gFalse);
+       break;
+      case psOpFloor:
+       if (!stack->topIsInt()) {
+         stack->pushReal(floor(stack->popNum()));
+       }
+       break;
+      case psOpGe:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         stack->pushBool(i1 >= i2);
+       } else {
+         r2 = stack->popNum();
+         r1 = stack->popNum();
+         stack->pushBool(r1 >= r2);
+       }
+       break;
+      case psOpGt:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         stack->pushBool(i1 > i2);
+       } else {
+         r2 = stack->popNum();
+         r1 = stack->popNum();
+         stack->pushBool(r1 > r2);
+       }
+       break;
+      case psOpIdiv:
+       i2 = stack->popInt();
+       i1 = stack->popInt();
+       stack->pushInt(i1 / i2);
+       break;
+      case psOpIndex:
+       stack->index(stack->popInt());
+       break;
+      case psOpLe:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         stack->pushBool(i1 <= i2);
+       } else {
+         r2 = stack->popNum();
+         r1 = stack->popNum();
+         stack->pushBool(r1 <= r2);
+       }
+       break;
+      case psOpLn:
+       stack->pushReal(log(stack->popNum()));
+       break;
+      case psOpLog:
+       stack->pushReal(log10(stack->popNum()));
+       break;
+      case psOpLt:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         stack->pushBool(i1 < i2);
+       } else {
+         r2 = stack->popNum();
+         r1 = stack->popNum();
+         stack->pushBool(r1 < r2);
+       }
+       break;
+      case psOpMod:
+       i2 = stack->popInt();
+       i1 = stack->popInt();
+       stack->pushInt(i1 % i2);
+       break;
+      case psOpMul:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         //~ should check for out-of-range, and push a real instead
+         stack->pushInt(i1 * i2);
+       } else {
+         r2 = stack->popNum();
+         r1 = stack->popNum();
+         stack->pushReal(r1 * r2);
+       }
+       break;
+      case psOpNe:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         stack->pushBool(i1 != i2);
+       } else if (stack->topTwoAreNums()) {
+         r2 = stack->popNum();
+         r1 = stack->popNum();
+         stack->pushBool(r1 != r2);
+       } else {
+         b2 = stack->popBool();
+         b1 = stack->popBool();
+         stack->pushBool(b1 != b2);
+       }
+       break;
+      case psOpNeg:
+       if (stack->topIsInt()) {
+         stack->pushInt(-stack->popInt());
+       } else {
+         stack->pushReal(-stack->popNum());
+       }
+       break;
+      case psOpNot:
+       if (stack->topIsInt()) {
+         stack->pushInt(~stack->popInt());
+       } else {
+         stack->pushReal(!stack->popBool());
+       }
+       break;
+      case psOpOr:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         stack->pushInt(i1 | i2);
+       } else {
+         b2 = stack->popBool();
+         b1 = stack->popBool();
+         stack->pushReal(b1 || b2);
+       }
+       break;
+      case psOpPop:
+       stack->pop();
+       break;
+      case psOpRoll:
+       i2 = stack->popInt();
+       i1 = stack->popInt();
+       stack->roll(i1, i2);
+       break;
+      case psOpRound:
+       if (!stack->topIsInt()) {
+         r1 = stack->popNum();
+         stack->pushReal((r1 >= 0) ? floor(r1 + 0.5) : ceil(r1 - 0.5));
+       }
+       break;
+      case psOpSin:
+       stack->pushReal(cos(stack->popNum()));
+       break;
+      case psOpSqrt:
+       stack->pushReal(sqrt(stack->popNum()));
+       break;
+      case psOpSub:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         stack->pushInt(i1 - i2);
+       } else {
+         r2 = stack->popNum();
+         r1 = stack->popNum();
+         stack->pushReal(r1 - r2);
+       }
+       break;
+      case psOpTrue:
+       stack->pushBool(gTrue);
+       break;
+      case psOpTruncate:
+       if (!stack->topIsInt()) {
+         r1 = stack->popNum();
+         stack->pushReal((r1 >= 0) ? floor(r1) : ceil(r1));
+       }
+       break;
+      case psOpXor:
+       if (stack->topTwoAreInts()) {
+         i2 = stack->popInt();
+         i1 = stack->popInt();
+         stack->pushInt(i1 ^ i2);
+       } else {
+         b2 = stack->popBool();
+         b1 = stack->popBool();
+         stack->pushReal(b1 ^ b2);
+       }
+       break;
+      case psOpIf:
+       b1 = stack->popBool();
+       if (b1) {
+         exec(stack, codePtr + 2);
+       }
+       codePtr = code[codePtr + 1].blk;
+       break;
+      case psOpIfelse:
+       b1 = stack->popBool();
+       if (b1) {
+         exec(stack, codePtr + 2);
+       } else {
+         exec(stack, code[codePtr].blk);
+       }
+       codePtr = code[codePtr + 1].blk;
+       break;
+      case psOpReturn:
+       return;
+      }
+      break;
+    default:
+      error(-1, "Internal: bad object in PostScript function code");
+      break;
+    }
+  }
+}
diff --git a/pdf2swf/xpdf/Function.h b/pdf2swf/xpdf/Function.h
new file mode 100644 (file)
index 0000000..9b0879f
--- /dev/null
@@ -0,0 +1,181 @@
+//========================================================================
+//
+// Function.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef FUNCTION_H
+#define FUNCTION_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include "gtypes.h"
+#include "Object.h"
+
+class Dict;
+class Stream;
+struct PSObject;
+class PSStack;
+
+//------------------------------------------------------------------------
+// Function
+//------------------------------------------------------------------------
+
+#define funcMaxInputs  8
+#define funcMaxOutputs 8
+
+class Function {
+public:
+
+  Function();
+
+  virtual ~Function();
+
+  // Construct a function.  Returns NULL if unsuccessful.
+  static Function *parse(Object *funcObj);
+
+  // Initialize the entries common to all function types.
+  GBool init(Dict *dict);
+
+  virtual Function *copy() = 0;
+
+  // Return size of input and output tuples.
+  int getInputSize() { return m; }
+  int getOutputSize() { return n; }
+
+  // Transform an input tuple into an output tuple.
+  virtual void transform(double *in, double *out) = 0;
+
+  virtual GBool isOk() = 0;
+
+protected:
+
+  int m, n;                    // size of input and output tuples
+  double                       // min and max values for function domain
+    domain[funcMaxInputs][2];
+  double                       // min and max values for function range
+    range[funcMaxOutputs][2];
+  GBool hasRange;              // set if range is defined
+};
+
+//------------------------------------------------------------------------
+// IdentityFunction
+//------------------------------------------------------------------------
+
+class IdentityFunction: public Function {
+public:
+
+  IdentityFunction();
+  virtual ~IdentityFunction();
+  virtual Function *copy() { return new IdentityFunction(); }
+  virtual void transform(double *in, double *out);
+  virtual GBool isOk() { return gTrue; }
+
+private:
+};
+
+//------------------------------------------------------------------------
+// SampledFunction
+//------------------------------------------------------------------------
+
+class SampledFunction: public Function {
+public:
+
+  SampledFunction(Object *funcObj, Dict *dict);
+  virtual ~SampledFunction();
+  virtual Function *copy() { return new SampledFunction(this); }
+  virtual void transform(double *in, double *out);
+  virtual GBool isOk() { return ok; }
+
+private:
+
+  SampledFunction(SampledFunction *func);
+
+  int                          // number of samples for each domain element
+    sampleSize[funcMaxInputs];
+  double                       // min and max values for domain encoder
+    encode[funcMaxInputs][2];
+  double                       // min and max values for range decoder
+    decode[funcMaxOutputs][2];
+  double *samples;             // the samples
+  GBool ok;
+};
+
+//------------------------------------------------------------------------
+// ExponentialFunction
+//------------------------------------------------------------------------
+
+class ExponentialFunction: public Function {
+public:
+
+  ExponentialFunction(Object *funcObj, Dict *dict);
+  virtual ~ExponentialFunction();
+  virtual Function *copy() { return new ExponentialFunction(this); }
+  virtual void transform(double *in, double *out);
+  virtual GBool isOk() { return ok; }
+
+private:
+
+  ExponentialFunction(ExponentialFunction *func);
+
+  double c0[funcMaxOutputs];
+  double c1[funcMaxOutputs];
+  double e;
+  GBool ok;
+};
+
+//------------------------------------------------------------------------
+// StitchingFunction
+//------------------------------------------------------------------------
+
+class StitchingFunction: public Function {
+public:
+
+  StitchingFunction(Object *funcObj, Dict *dict);
+  virtual ~StitchingFunction();
+  virtual Function *copy() { return new StitchingFunction(this); }
+  virtual void transform(double *in, double *out);
+  virtual GBool isOk() { return ok; }
+
+private:
+
+  StitchingFunction(StitchingFunction *func);
+
+  int k;
+  Function **funcs;
+  double *bounds;
+  double *encode;
+  GBool ok;
+};
+
+//------------------------------------------------------------------------
+// PostScriptFunction
+//------------------------------------------------------------------------
+
+class PostScriptFunction: public Function {
+public:
+
+  PostScriptFunction(Object *funcObj, Dict *dict);
+  virtual ~PostScriptFunction();
+  virtual Function *copy() { return new PostScriptFunction(this); }
+  virtual void transform(double *in, double *out);
+  virtual GBool isOk() { return ok; }
+
+private:
+
+  PostScriptFunction(PostScriptFunction *func);
+  GBool parseCode(Stream *str, int *codePtr);
+  GString *getToken(Stream *str);
+  void resizeCode(int newSize);
+  void exec(PSStack *stack, int codePtr);
+
+  PSObject *code;
+  int codeSize;
+  GBool ok;
+};
+
+#endif
diff --git a/pdf2swf/xpdf/GHash.cc b/pdf2swf/xpdf/GHash.cc
new file mode 100644 (file)
index 0000000..dc09f71
--- /dev/null
@@ -0,0 +1,240 @@
+//========================================================================
+//
+// GHash.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include "gmem.h"
+#include "GString.h"
+#include "GHash.h"
+
+//------------------------------------------------------------------------
+
+struct GHashBucket {
+  GString *key;
+  void *val;
+  GHashBucket *next;
+};
+
+struct GHashIter {
+  int h;
+  GHashBucket *p;
+};
+
+//------------------------------------------------------------------------
+
+GHash::GHash(GBool deleteKeysA) {
+  int h;
+
+  deleteKeys = deleteKeysA;
+  size = 7;
+  tab = (GHashBucket **)gmalloc(size * sizeof(GHashBucket *));
+  for (h = 0; h < size; ++h) {
+    tab[h] = NULL;
+  }
+  len = 0;
+}
+
+GHash::~GHash() {
+  GHashBucket *p;
+  int h;
+
+  for (h = 0; h < size; ++h) {
+    while (tab[h]) {
+      p = tab[h];
+      tab[h] = p->next;
+      if (deleteKeys) {
+       delete p->key;
+      }
+      delete p;
+    }
+  }
+  gfree(tab);
+}
+
+void GHash::add(GString *key, void *val) {
+  GHashBucket **oldTab;
+  GHashBucket *p;
+  int oldSize, i, h;
+
+  // expand the table if necessary
+  if (len >= size) {
+    oldSize = size;
+    oldTab = tab;
+    size = 2*size + 1;
+    tab = (GHashBucket **)gmalloc(size * sizeof(GHashBucket *));
+    for (h = 0; h < size; ++h) {
+      tab[h] = NULL;
+    }
+    for (i = 0; i < oldSize; ++i) {
+      while (oldTab[i]) {
+       p = oldTab[i];
+       oldTab[i] = oldTab[i]->next;
+       h = hash(p->key);
+       p->next = tab[h];
+       tab[h] = p;
+      }
+    }
+    gfree(oldTab);
+  }
+
+  // add the new symbol
+  p = new GHashBucket;
+  p->key = key;
+  p->val = val;
+  h = hash(key);
+  p->next = tab[h];
+  tab[h] = p;
+  ++len;
+}
+
+void *GHash::lookup(GString *key) {
+  GHashBucket *p;
+  int h;
+
+  if (!(p = find(key, &h))) {
+    return NULL;
+  }
+  return p->val;
+}
+
+void *GHash::lookup(char *key) {
+  GHashBucket *p;
+  int h;
+
+  if (!(p = find(key, &h))) {
+    return NULL;
+  }
+  return p->val;
+}
+
+void *GHash::remove(GString *key) {
+  GHashBucket *p;
+  GHashBucket **q;
+  void *val;
+  int h;
+
+  if (!(p = find(key, &h))) {
+    return NULL;
+  }
+  q = &tab[h];
+  while (*q != p) {
+    q = &((*q)->next);
+  }
+  *q = p->next;
+  if (deleteKeys) {
+    delete p->key;
+  }
+  val = p->val;
+  delete p;
+  --len;
+  return val;
+}
+
+void *GHash::remove(char *key) {
+  GHashBucket *p;
+  GHashBucket **q;
+  void *val;
+  int h;
+
+  if (!(p = find(key, &h))) {
+    return NULL;
+  }
+  q = &tab[h];
+  while (*q != p) {
+    q = &((*q)->next);
+  }
+  *q = p->next;
+  if (deleteKeys) {
+    delete p->key;
+  }
+  val = p->val;
+  delete p;
+  --len;
+  return val;
+}
+
+void GHash::startIter(GHashIter **iter) {
+  *iter = new GHashIter;
+  (*iter)->h = -1;
+  (*iter)->p = NULL;
+}
+
+GBool GHash::getNext(GHashIter **iter, GString **key, void **val) {
+  if (!*iter) {
+    return gFalse;
+  }
+  if ((*iter)->p) {
+    (*iter)->p = (*iter)->p->next;
+  }
+  while (!(*iter)->p) {
+    if (++(*iter)->h == size) {
+      delete *iter;
+      *iter = NULL;
+      return gFalse;
+    }
+    (*iter)->p = tab[(*iter)->h];
+  }
+  *key = (*iter)->p->key;
+  *val = (*iter)->p->val;
+  return gTrue;
+}
+
+void GHash::killIter(GHashIter **iter) {
+  delete *iter;
+  *iter = NULL;
+}
+
+GHashBucket *GHash::find(GString *key, int *h) {
+  GHashBucket *p;
+
+  *h = hash(key);
+  for (p = tab[*h]; p; p = p->next) {
+    if (!p->key->cmp(key)) {
+      return p;
+    }
+  }
+  return NULL;
+}
+
+GHashBucket *GHash::find(char *key, int *h) {
+  GHashBucket *p;
+
+  *h = hash(key);
+  for (p = tab[*h]; p; p = p->next) {
+    if (!p->key->cmp(key)) {
+      return p;
+    }
+  }
+  return NULL;
+}
+
+int GHash::hash(GString *key) {
+  char *p;
+  unsigned int h;
+  int i;
+
+  h = 0;
+  for (p = key->getCString(), i = 0; i < key->getLength(); ++p, ++i) {
+    h = 17 * h + (int)(*p & 0xff);
+  }
+  return (int)(h % size);
+}
+
+int GHash::hash(char *key) {
+  char *p;
+  unsigned int h;
+
+  h = 0;
+  for (p = key; *p; ++p) {
+    h = 17 * h + (int)(*p & 0xff);
+  }
+  return (int)(h % size);
+}
diff --git a/pdf2swf/xpdf/GHash.h b/pdf2swf/xpdf/GHash.h
new file mode 100644 (file)
index 0000000..91d9700
--- /dev/null
@@ -0,0 +1,67 @@
+//========================================================================
+//
+// GHash.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef GHASH_H
+#define GHASH_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include "gtypes.h"
+
+class GString;
+struct GHashBucket;
+struct GHashIter;
+
+//------------------------------------------------------------------------
+
+class GHash {
+public:
+
+  GHash(GBool deleteKeysA = gFalse);
+  ~GHash();
+  void add(GString *key, void *val);
+  void *lookup(GString *key);
+  void *lookup(char *key);
+  void *remove(GString *key);
+  void *remove(char *key);
+  int getLength() { return len; }
+  void startIter(GHashIter **iter);
+  GBool getNext(GHashIter **iter, GString **key, void **val);
+  void killIter(GHashIter **iter);
+
+private:
+
+  GHashBucket *find(GString *key, int *h);
+  GHashBucket *find(char *key, int *h);
+  int hash(GString *key);
+  int hash(char *key);
+
+  GBool deleteKeys;            // set if key strings should be deleted
+  int size;                    // number of buckets
+  int len;                     // number of entries
+  GHashBucket **tab;
+};
+
+#define deleteGHash(hash, T)                       \
+  do {                                             \
+    GHash *_hash = (hash);                         \
+    {                                              \
+      GHashIter *_iter;                            \
+      GString *_key;                               \
+      void *_p;                                    \
+      _hash->startIter(&_iter);                    \
+      while (_hash->getNext(&_iter, &_key, &_p)) { \
+        delete (T*)_p;                             \
+      }                                            \
+      delete _hash;                                \
+    }                                              \
+  } while(0)
+
+#endif
diff --git a/pdf2swf/xpdf/GList.cc b/pdf2swf/xpdf/GList.cc
new file mode 100644 (file)
index 0000000..f52bc26
--- /dev/null
@@ -0,0 +1,91 @@
+//========================================================================
+//
+// GList.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include <string.h>
+#include "gmem.h"
+#include "GList.h"
+
+//------------------------------------------------------------------------
+// GList
+//------------------------------------------------------------------------
+
+GList::GList() {
+  size = 8;
+  data = (void **)gmalloc(size * sizeof(void*));
+  length = 0;
+  inc = 0;
+}
+
+GList::GList(int sizeA) {
+  size = sizeA;
+  data = (void **)gmalloc(size * sizeof(void*));
+  length = 0;
+  inc = 0;
+}
+
+GList::~GList() {
+  gfree(data);
+}
+
+void GList::append(void *p) {
+  if (length >= size) {
+    expand();
+  }
+  data[length++] = p;
+}
+
+void GList::append(GList *list) {
+  int i;
+
+  while (length + list->length > size) {
+    expand();
+  }
+  for (i = 0; i < list->length; ++i) {
+    data[length++] = list->data[i];
+  }
+}
+
+void GList::insert(int i, void *p) {
+  if (length >= size) {
+    expand();
+  }
+  if (i < length) {
+    memmove(data+i+1, data+i, (length - i) * sizeof(void *));
+  }
+  data[i] = p;
+  ++length;
+}
+
+void *GList::del(int i) {
+  void *p;
+
+  p = data[i];
+  if (i < length - 1) {
+    memmove(data+i, data+i+1, (length - i - 1) * sizeof(void *));
+  }
+  --length;
+  if (size - length >= ((inc > 0) ? inc : size/2)) {
+    shrink();
+  }
+  return p;
+}
+
+void GList::expand() {
+  size += (inc > 0) ? inc : size;
+  data = (void **)grealloc(data, size * sizeof(void*));
+}
+
+void GList::shrink() {
+  size -= (inc > 0) ? inc : size/2;
+  data = (void **)grealloc(data, size * sizeof(void*));
+}
diff --git a/pdf2swf/xpdf/GList.h b/pdf2swf/xpdf/GList.h
new file mode 100644 (file)
index 0000000..0ef4fd7
--- /dev/null
@@ -0,0 +1,89 @@
+//========================================================================
+//
+// GList.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef GLIST_H
+#define GLIST_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include "gtypes.h"
+
+//------------------------------------------------------------------------
+// GList
+//------------------------------------------------------------------------
+
+class GList {
+public:
+
+  // Create an empty list.
+  GList();
+
+  // Create an empty list with space for <size1> elements.
+  GList(int sizeA);
+
+  // Destructor - does not free pointed-to objects.
+  ~GList();
+
+  //----- general
+
+  // Get the number of elements.
+  int getLength() { return length; }
+
+  //----- ordered list support
+
+  // Return the <i>th element.
+  // Assumes 0 <= i < length.
+  void *get(int i) { return data[i]; }
+
+  // Append an element to the end of the list.
+  void append(void *p);
+
+  // Append another list to the end of this one.
+  void append(GList *list);
+
+  // Insert an element at index <i>.
+  // Assumes 0 <= i <= length.
+  void insert(int i, void *p);
+
+  // Deletes and returns the element at index <i>.
+  // Assumes 0 <= i < length.
+  void *del(int i);
+
+  //----- control
+
+  // Set allocation increment to <inc>.  If inc > 0, that many
+  // elements will be allocated every time the list is expanded.
+  // If inc <= 0, the list will be doubled in size.
+  void setAllocIncr(int incA) { inc = incA; }
+
+private:
+
+  void expand();
+  void shrink();
+
+  void **data;                 // the list elements
+  int size;                    // size of data array
+  int length;                  // number of elements on list
+  int inc;                     // allocation increment
+};
+
+#define deleteGList(list, T)                        \
+  do {                                              \
+    GList *_list = (list);                          \
+    {                                               \
+      int _i;                                       \
+      for (_i = 0; _i < _list->getLength(); ++_i) { \
+        delete (T*)_list->get(_i);                  \
+      }                                             \
+      delete _list;                                 \
+    }                                               \
+  } while (0)
+
+#endif
diff --git a/pdf2swf/xpdf/GlobalParams.cc b/pdf2swf/xpdf/GlobalParams.cc
new file mode 100644 (file)
index 0000000..0bc908e
--- /dev/null
@@ -0,0 +1,1065 @@
+//========================================================================
+//
+// GlobalParams.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include <string.h>
+#include <ctype.h>
+#if HAVE_PAPER_H
+#include <paper.h>
+#endif
+#include "gmem.h"
+#include "GString.h"
+#include "GList.h"
+#include "GHash.h"
+#include "gfile.h"
+#include "Error.h"
+#include "NameToCharCode.h"
+#include "CharCodeToUnicode.h"
+#include "UnicodeMap.h"
+#include "CMap.h"
+#include "BuiltinFontTables.h"
+#include "FontEncodingTables.h"
+#include "GlobalParams.h"
+
+#include "NameToUnicodeTable.h"
+#include "UnicodeMapTables.h"
+#include "DisplayFontTable.h"
+#include "UTF8.h"
+
+//------------------------------------------------------------------------
+
+GlobalParams *globalParams = NULL;
+
+//------------------------------------------------------------------------
+// DisplayFontParam
+//------------------------------------------------------------------------
+
+DisplayFontParam::DisplayFontParam(GString *nameA,
+                                  DisplayFontParamKind kindA) {
+  name = nameA;
+  kind = kindA;
+  switch (kind) {
+  case displayFontX:
+    x.xlfd = NULL;
+    x.encoding = NULL;
+    break;
+  case displayFontT1:
+    t1.fileName = NULL;
+    break;
+  case displayFontTT:
+    tt.fileName = NULL;
+    break;
+  }
+}
+
+DisplayFontParam::DisplayFontParam(char *nameA, char *xlfdA, char *encodingA) {
+  name = new GString(nameA);
+  kind = displayFontX;
+  x.xlfd = new GString(xlfdA);
+  x.encoding = new GString(encodingA);
+}
+
+DisplayFontParam::~DisplayFontParam() {
+  delete name;
+  switch (kind) {
+  case displayFontX:
+    if (x.xlfd) {
+      delete x.xlfd;
+    }
+    if (x.encoding) {
+      delete x.encoding;
+    }
+    break;
+  case displayFontT1:
+    if (t1.fileName) {
+      delete t1.fileName;
+    }
+    break;
+  case displayFontTT:
+    if (tt.fileName) {
+      delete tt.fileName;
+    }
+    break;
+  }
+}
+
+//------------------------------------------------------------------------
+// PSFontParam
+//------------------------------------------------------------------------
+
+PSFontParam::PSFontParam(GString *pdfFontNameA, int wModeA,
+                        GString *psFontNameA, GString *encodingA) {
+  pdfFontName = pdfFontNameA;
+  wMode = wModeA;
+  psFontName = psFontNameA;
+  encoding = encodingA;
+}
+
+PSFontParam::~PSFontParam() {
+  delete pdfFontName;
+  delete psFontName;
+  if (encoding) {
+    delete encoding;
+  }
+}
+
+//------------------------------------------------------------------------
+// parsing
+//------------------------------------------------------------------------
+
+GlobalParams::GlobalParams(char *cfgFileName) {
+  UnicodeMap *map;
+  DisplayFontParam *dfp;
+  GString *fileName;
+  FILE *f;
+  int i;
+
+  initBuiltinFontTables();
+
+  // scan the encoding in reverse because we want the lowest-numbered
+  // index for each char name ('space' is encoded twice)
+  macRomanReverseMap = new NameToCharCode();
+  for (i = 255; i >= 0; --i) {
+    if (macRomanEncoding[i]) {
+      macRomanReverseMap->add(macRomanEncoding[i], (CharCode)i);
+    }
+  }
+
+  nameToUnicode = new NameToCharCode();
+  cidToUnicodes = new GHash(gTrue);
+  residentUnicodeMaps = new GHash();
+  unicodeMaps = new GHash(gTrue);
+  cMapDirs = new GHash(gTrue);
+  toUnicodeDirs = new GList();
+  displayFonts = new GHash();
+  displayCIDFonts = new GHash();
+  displayNamedCIDFonts = new GHash();
+#if HAVE_PAPER_H
+  const struct paper *paperType;
+  paperinit();
+  paperType = paperinfo(systempapername());
+  psPaperWidth = (int)paperpswidth(paperType);
+  psPaperHeight = (int)paperpsheight(paperType);
+  paperdone();
+#else
+  psPaperWidth = defPaperWidth;
+  psPaperHeight = defPaperHeight;
+#endif
+  psDuplex = gFalse;
+  psLevel = psLevel2;
+  psFile = NULL;
+  psFonts = new GHash();
+  psNamedFonts16 = new GList();
+  psFonts16 = new GList();
+  psEmbedType1 = gTrue;
+  psEmbedTrueType = gTrue;
+  psEmbedCIDPostScript = gTrue;
+  psEmbedCIDTrueType = gTrue;
+  psOPI = gFalse;
+  psASCIIHex = gFalse;
+  textEncoding = new GString("Latin1");
+#if defined(WIN32)
+  textEOL = eolDOS;
+#elif defined(MACOS)
+  textEOL = eolMac;
+#else
+  textEOL = eolUnix;
+#endif
+  fontDirs = new GList();
+  initialZoom = new GString("1");
+  t1libControl = fontRastAALow;
+  freetypeControl = fontRastAALow;
+  urlCommand = NULL;
+  mapNumericCharNames = gTrue;
+  errQuiet = gFalse;
+
+  cidToUnicodeCache = new CIDToUnicodeCache();
+  unicodeMapCache = new UnicodeMapCache();
+  cMapCache = new CMapCache();
+
+  // set up the initial nameToUnicode table
+  for (i = 0; nameToUnicodeTab[i].name; ++i) {
+    nameToUnicode->add(nameToUnicodeTab[i].name, nameToUnicodeTab[i].u);
+  }
+
+  // set up the residentUnicodeMaps table
+  map = new UnicodeMap("Latin1", latin1UnicodeMapRanges, latin1UnicodeMapLen);
+  residentUnicodeMaps->add(map->getEncodingName(), map);
+  map = new UnicodeMap("ASCII7", ascii7UnicodeMapRanges, ascii7UnicodeMapLen);
+  residentUnicodeMaps->add(map->getEncodingName(), map);
+  map = new UnicodeMap("Symbol", symbolUnicodeMapRanges, symbolUnicodeMapLen);
+  residentUnicodeMaps->add(map->getEncodingName(), map);
+  map = new UnicodeMap("ZapfDingbats", zapfDingbatsUnicodeMapRanges,
+                      zapfDingbatsUnicodeMapLen);
+  residentUnicodeMaps->add(map->getEncodingName(), map);
+  map = new UnicodeMap("UTF-8", &mapUTF8);
+  residentUnicodeMaps->add(map->getEncodingName(), map);
+  map = new UnicodeMap("UCS-2", &mapUCS2);
+  residentUnicodeMaps->add(map->getEncodingName(), map);
+
+  // default displayFonts table
+  for (i = 0; displayFontTab[i].name; ++i) {
+    dfp = new DisplayFontParam(displayFontTab[i].name,
+                              displayFontTab[i].xlfd,
+                              displayFontTab[i].encoding);
+    displayFonts->add(dfp->name, dfp);
+  }
+
+  // look for a user config file, then a system-wide config file
+  f = NULL;
+  fileName = NULL;
+  if (cfgFileName && cfgFileName[0]) {
+    fileName = new GString(cfgFileName);
+    if (!(f = fopen(fileName->getCString(), "r"))) {
+      delete fileName;
+    }
+  }
+  if (!f) {
+    fileName = appendToPath(getHomeDir(), xpdfUserConfigFile);
+    if (!(f = fopen(fileName->getCString(), "r"))) {
+      delete fileName;
+    }
+  }
+  if (!f) {
+#if defined(WIN32) && !defined(__CYGWIN32__)
+    char buf[512];
+    i = GetModuleFileName(NULL, buf, sizeof(buf));
+    if (i <= 0 || i >= sizeof(buf)) {
+      // error or path too long for buffer - just use the current dir
+      buf[i] = '\0';
+    }
+    fileName = grabPath(buf);
+    appendToPath(fileName, xpdfSysConfigFile);
+#else
+    fileName = new GString(xpdfSysConfigFile);
+#endif
+    if (!(f = fopen(fileName->getCString(), "r"))) {
+      delete fileName;
+    }
+  }
+  if (f) {
+    parseFile(fileName, f);
+    delete fileName;
+  }
+}
+
+void GlobalParams::parseFile(GString *fileName, FILE *f) {
+  int line;
+  GList *tokens;
+  GString *cmd, *incFile;
+  char *p1, *p2;
+  char buf[512];
+  FILE *f2;
+
+  line = 1;
+  while (fgets(buf, sizeof(buf) - 1, f)) {
+
+    // break the line into tokens
+    tokens = new GList();
+    p1 = buf;
+    while (*p1) {
+      for (; *p1 && isspace(*p1); ++p1) ;
+      if (!*p1) {
+       break;
+      }
+      if (*p1 == '"' || *p1 == '\'') {
+       for (p2 = p1 + 1; *p2 && *p2 != *p1; ++p2) ;
+       ++p1;
+      } else {
+       for (p2 = p1 + 1; *p2 && !isspace(*p2); ++p2) ;
+      }
+      tokens->append(new GString(p1, p2 - p1));
+      p1 = p2 + 1;
+    }
+
+    if (tokens->getLength() > 0 &&
+       ((GString *)tokens->get(0))->getChar(0) != '#') {
+      cmd = (GString *)tokens->get(0);
+      if (!cmd->cmp("include")) {
+       if (tokens->getLength() == 2) {
+         incFile = (GString *)tokens->get(1);
+         if ((f2 = fopen(incFile->getCString(), "r"))) {
+           parseFile(incFile, f2);
+           fclose(f2);
+         } else {
+           error(-1, "Couldn't find included config file: '%s' (%s:%d)",
+                 incFile->getCString(), fileName->getCString(), line);
+         }
+       } else {
+         error(-1, "Bad 'include' config file command (%s:%d)",
+               fileName->getCString(), line);
+       }
+      } else if (!cmd->cmp("nameToUnicode")) {
+       parseNameToUnicode(tokens, fileName, line);
+      } else if (!cmd->cmp("cidToUnicode")) {
+       parseCIDToUnicode(tokens, fileName, line);
+      } else if (!cmd->cmp("unicodeMap")) {
+       parseUnicodeMap(tokens, fileName, line);
+      } else if (!cmd->cmp("cMapDir")) {
+       parseCMapDir(tokens, fileName, line);
+      } else if (!cmd->cmp("toUnicodeDir")) {
+       parseToUnicodeDir(tokens, fileName, line);
+      } else if (!cmd->cmp("displayFontX")) {
+       parseDisplayFont(tokens, displayFonts, displayFontX, fileName, line);
+      } else if (!cmd->cmp("displayFontT1")) {
+       parseDisplayFont(tokens, displayFonts, displayFontT1, fileName, line);
+      } else if (!cmd->cmp("displayFontTT")) {
+       parseDisplayFont(tokens, displayFonts, displayFontTT, fileName, line);
+      } else if (!cmd->cmp("displayCIDFontX")) {
+       parseDisplayFont(tokens, displayCIDFonts,
+                        displayFontX, fileName, line);
+      } else if (!cmd->cmp("displayNamedCIDFontX")) {
+       parseDisplayFont(tokens, displayNamedCIDFonts,
+                        displayFontX, fileName, line);
+      } else if (!cmd->cmp("psFile")) {
+       parsePSFile(tokens, fileName, line);
+      } else if (!cmd->cmp("psFont")) {
+       parsePSFont(tokens, fileName, line);
+      } else if (!cmd->cmp("psNamedFont16")) {
+       parsePSFont16("psNamedFont16", psNamedFonts16,
+                     tokens, fileName, line);
+      } else if (!cmd->cmp("psFont16")) {
+       parsePSFont16("psFont16", psFonts16, tokens, fileName, line);
+      } else if (!cmd->cmp("psPaperSize")) {
+       parsePSPaperSize(tokens, fileName, line);
+      } else if (!cmd->cmp("psDuplex")) {
+       parseYesNo("psDuplex", &psDuplex, tokens, fileName, line);
+      } else if (!cmd->cmp("psLevel")) {
+       parsePSLevel(tokens, fileName, line);
+      } else if (!cmd->cmp("psEmbedType1Fonts")) {
+       parseYesNo("psEmbedType1", &psEmbedType1, tokens, fileName, line);
+      } else if (!cmd->cmp("psEmbedTrueTypeFonts")) {
+       parseYesNo("psEmbedTrueType", &psEmbedTrueType,
+                  tokens, fileName, line);
+      } else if (!cmd->cmp("psEmbedCIDPostScriptFonts")) {
+       parseYesNo("psEmbedCIDPostScript", &psEmbedCIDPostScript,
+                  tokens, fileName, line);
+      } else if (!cmd->cmp("psEmbedCIDTrueTypeFonts")) {
+       parseYesNo("psEmbedCIDTrueType", &psEmbedCIDTrueType,
+                  tokens, fileName, line);
+      } else if (!cmd->cmp("psOPI")) {
+       parseYesNo("psOPI", &psOPI, tokens, fileName, line);
+      } else if (!cmd->cmp("psASCIIHex")) {
+       parseYesNo("psASCIIHex", &psASCIIHex, tokens, fileName, line);
+      } else if (!cmd->cmp("textEncoding")) {
+       parseTextEncoding(tokens, fileName, line);
+      } else if (!cmd->cmp("textEOL")) {
+       parseTextEOL(tokens, fileName, line);
+      } else if (!cmd->cmp("fontDir")) {
+       parseFontDir(tokens, fileName, line);
+      } else if (!cmd->cmp("initialZoom")) {
+       parseInitialZoom(tokens, fileName, line);
+      } else if (!cmd->cmp("t1libControl")) {
+       parseFontRastControl("t1libControl", &t1libControl,
+                            tokens, fileName, line);
+      } else if (!cmd->cmp("freetypeControl")) {
+       parseFontRastControl("freetypeControl", &freetypeControl,
+                            tokens, fileName, line);
+      } else if (!cmd->cmp("urlCommand")) {
+       parseURLCommand(tokens, fileName, line);
+      } else if (!cmd->cmp("mapNumericCharNames")) {
+       parseYesNo("mapNumericCharNames", &mapNumericCharNames,
+                  tokens, fileName, line);
+      } else if (!cmd->cmp("errQuiet")) {
+       parseYesNo("errQuiet", &errQuiet, tokens, fileName, line);
+      } else if (!cmd->cmp("fontpath") || !cmd->cmp("fontmap")) {
+       error(-1, "Unknown config file command");
+       error(-1, "-- the config file format has changed since Xpdf 0.9x");
+      } else {
+       error(-1, "Unknown config file command '%s' (%s:%d)",
+             cmd->getCString(), fileName->getCString(), line);
+      }
+    }
+
+    deleteGList(tokens, GString);
+    ++line;
+  }
+}
+
+void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
+                                        int line) {
+  GString *name;
+  char *tok1, *tok2;
+  FILE *f;
+  char buf[256];
+  int line2;
+  Unicode u;
+
+  if (tokens->getLength() != 2) {
+    error(-1, "Bad 'nameToUnicode' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  name = (GString *)tokens->get(1);
+  if (!(f = fopen(name->getCString(), "r"))) {
+    error(-1, "Couldn't open 'nameToUnicode' file '%s'",
+         name->getCString());
+    return;
+  }
+  line2 = 1;
+  while (fgets(buf, sizeof(buf), f)) {
+    tok1 = strtok(buf, " \t\r\n");
+    tok2 = strtok(NULL, " \t\r\n");
+    if (tok1 && tok2) {
+      sscanf(tok1, "%x", &u);
+      nameToUnicode->add(tok2, u);
+    } else {
+      error(-1, "Bad line in 'nameToUnicode' file (%s:%d)", name, line2);
+    }
+    ++line2;
+  }
+  fclose(f);
+}
+
+void GlobalParams::parseCIDToUnicode(GList *tokens, GString *fileName,
+                                    int line) {
+  GString *collection, *name, *old;
+
+  if (tokens->getLength() != 3) {
+    error(-1, "Bad 'cidToUnicode' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  collection = (GString *)tokens->get(1);
+  name = (GString *)tokens->get(2);
+  if ((old = (GString *)cidToUnicodes->remove(collection))) {
+    delete old;
+  }
+  cidToUnicodes->add(collection->copy(), name->copy());
+}
+
+void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
+                                  int line) {
+  GString *encodingName, *name, *old;
+
+  if (tokens->getLength() != 3) {
+    error(-1, "Bad 'unicodeMap' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  encodingName = (GString *)tokens->get(1);
+  name = (GString *)tokens->get(2);
+  if ((old = (GString *)unicodeMaps->remove(encodingName))) {
+    delete old;
+  }
+  unicodeMaps->add(encodingName->copy(), name->copy());
+}
+
+void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
+  GString *collection, *dir;
+  GList *list;
+
+  if (tokens->getLength() != 3) {
+    error(-1, "Bad 'cMapDir' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  collection = (GString *)tokens->get(1);
+  dir = (GString *)tokens->get(2);
+  if (!(list = (GList *)cMapDirs->lookup(collection))) {
+    list = new GList();
+    cMapDirs->add(collection->copy(), list);
+  }
+  list->append(dir->copy());
+}
+
+void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
+                                    int line) {
+  if (tokens->getLength() != 2) {
+    error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
+}
+
+void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
+                                   DisplayFontParamKind kind,
+                                   GString *fileName, int line) {
+  DisplayFontParam *param, *old;
+
+  if (tokens->getLength() < 2) {
+    goto err1;
+  }
+  param = new DisplayFontParam(((GString *)tokens->get(1))->copy(), kind);
+  
+  switch (kind) {
+  case displayFontX:
+    if (tokens->getLength() != 4) {
+      goto err2;
+    }
+    param->x.xlfd = ((GString *)tokens->get(2))->copy();
+    param->x.encoding = ((GString *)tokens->get(3))->copy();
+    break;
+  case displayFontT1:
+    if (tokens->getLength() != 3) {
+      goto err2;
+    }
+    param->t1.fileName = ((GString *)tokens->get(2))->copy();
+    break;
+  case displayFontTT:
+    if (tokens->getLength() != 3) {
+      goto err2;
+    }
+    param->tt.fileName = ((GString *)tokens->get(2))->copy();
+    break;
+  }
+
+  if ((old = (DisplayFontParam *)fontHash->remove(param->name))) {
+    delete old;
+  }
+  fontHash->add(param->name, param);
+  return;
+
+ err2:
+  delete param;
+ err1:
+  error(-1, "Bad 'display*Font*' config file command (%s:%d)",
+       fileName->getCString(), line);
+}
+
+void GlobalParams::parsePSPaperSize(GList *tokens, GString *fileName,
+                                   int line) {
+  GString *tok;
+
+  if (tokens->getLength() == 2) {
+    tok = (GString *)tokens->get(1);
+    if (!setPSPaperSize(tok->getCString())) {
+      error(-1, "Bad 'psPaperSize' config file command (%s:%d)",
+           fileName->getCString(), line);
+    }
+  } else if (tokens->getLength() == 3) {
+    tok = (GString *)tokens->get(1);
+    psPaperWidth = atoi(tok->getCString());
+    tok = (GString *)tokens->get(2);
+    psPaperHeight = atoi(tok->getCString());
+  } else {
+    error(-1, "Bad 'psPaperSize' config file command (%s:%d)",
+         fileName->getCString(), line);
+  }
+}
+
+void GlobalParams::parsePSLevel(GList *tokens, GString *fileName, int line) {
+  GString *tok;
+
+  if (tokens->getLength() != 2) {
+    error(-1, "Bad 'psLevel' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  tok = (GString *)tokens->get(1);
+  if (!tok->cmp("level1")) {
+    psLevel = psLevel1;
+  } else if (!tok->cmp("level1sep")) {
+    psLevel = psLevel1Sep;
+  } else if (!tok->cmp("level2")) {
+    psLevel = psLevel2;
+  } else if (!tok->cmp("level2sep")) {
+    psLevel = psLevel2Sep;
+  } else if (!tok->cmp("level3")) {
+    psLevel = psLevel3;
+  } else if (!tok->cmp("level3Sep")) {
+    psLevel = psLevel3Sep;
+  } else {
+    error(-1, "Bad 'psLevel' config file command (%s:%d)",
+         fileName->getCString(), line);
+  }
+}
+
+void GlobalParams::parsePSFile(GList *tokens, GString *fileName, int line) {
+  if (tokens->getLength() != 2) {
+    error(-1, "Bad 'psFile' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  if (psFile) {
+    delete psFile;
+  }
+  psFile = ((GString *)tokens->get(1))->copy();
+}
+
+void GlobalParams::parsePSFont(GList *tokens, GString *fileName, int line) {
+  PSFontParam *param;
+
+  if (tokens->getLength() != 3) {
+    error(-1, "Bad 'psFont' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  param = new PSFontParam(((GString *)tokens->get(1))->copy(), 0,
+                         ((GString *)tokens->get(2))->copy(), NULL);
+  psFonts->add(param->pdfFontName, param);
+}
+
+void GlobalParams::parsePSFont16(char *cmdName, GList *fontList,
+                                GList *tokens, GString *fileName, int line) {
+  PSFontParam *param;
+  int wMode;
+  GString *tok;
+
+  if (tokens->getLength() != 5) {
+    error(-1, "Bad '%s' config file command (%s:%d)",
+         cmdName, fileName->getCString(), line);
+    return;
+  }
+  tok = (GString *)tokens->get(2);
+  if (!tok->cmp("H")) {
+    wMode = 0;
+  } else if (!tok->cmp("V")) {
+    wMode = 1;
+  } else {
+    error(-1, "Bad '%s' config file command (%s:%d)",
+         cmdName, fileName->getCString(), line);
+    return;
+  }
+  param = new PSFontParam(((GString *)tokens->get(1))->copy(),
+                         wMode,
+                         ((GString *)tokens->get(3))->copy(),
+                         ((GString *)tokens->get(4))->copy());
+  fontList->append(param);
+}
+
+void GlobalParams::parseTextEncoding(GList *tokens, GString *fileName,
+                                    int line) {
+  if (tokens->getLength() != 2) {
+    error(-1, "Bad 'textEncoding' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  delete textEncoding;
+  textEncoding = ((GString *)tokens->get(1))->copy();
+}
+
+void GlobalParams::parseTextEOL(GList *tokens, GString *fileName, int line) {
+  GString *tok;
+
+  if (tokens->getLength() != 2) {
+    error(-1, "Bad 'textEOL' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  tok = (GString *)tokens->get(1);
+  if (!tok->cmp("unix")) {
+    textEOL = eolUnix;
+  } else if (!tok->cmp("dos")) {
+    textEOL = eolDOS;
+  } else if (!tok->cmp("mac")) {
+    textEOL = eolMac;
+  } else {
+    error(-1, "Bad 'textEOL' config file command (%s:%d)",
+         fileName->getCString(), line);
+  }
+}
+
+void GlobalParams::parseFontDir(GList *tokens, GString *fileName, int line) {
+  if (tokens->getLength() != 2) {
+    error(-1, "Bad 'fontDir' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  fontDirs->append(((GString *)tokens->get(1))->copy());
+}
+
+void GlobalParams::parseInitialZoom(GList *tokens,
+                                   GString *fileName, int line) {
+  if (tokens->getLength() != 2) {
+    error(-1, "Bad 'initialZoom' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  delete initialZoom;
+  initialZoom = ((GString *)tokens->get(1))->copy();
+}
+
+void GlobalParams::parseFontRastControl(char *cmdName, FontRastControl *val,
+                                       GList *tokens, GString *fileName,
+                                       int line) {
+  GString *tok;
+
+  if (tokens->getLength() != 2) {
+    error(-1, "Bad '%s' config file command (%s:%d)",
+         cmdName, fileName->getCString(), line);
+    return;
+  }
+  tok = (GString *)tokens->get(1);
+  if (!setFontRastControl(val, tok->getCString())) {
+    error(-1, "Bad '%s' config file command (%s:%d)",
+         cmdName, fileName->getCString(), line);
+  }
+}
+
+void GlobalParams::parseURLCommand(GList *tokens, GString *fileName,
+                                  int line) {
+  if (tokens->getLength() != 2) {
+    error(-1, "Bad 'urlCommand' config file command (%s:%d)",
+         fileName->getCString(), line);
+    return;
+  }
+  if (urlCommand) {
+    delete urlCommand;
+  }
+  urlCommand = ((GString *)tokens->get(1))->copy();
+}
+
+void GlobalParams::parseYesNo(char *cmdName, GBool *flag,
+                             GList *tokens, GString *fileName, int line) {
+  GString *tok;
+
+  if (tokens->getLength() != 2) {
+    error(-1, "Bad '%s' config file command (%s:%d)",
+         cmdName, fileName->getCString(), line);
+    return;
+  }
+  tok = (GString *)tokens->get(1);
+  if (!tok->cmp("yes")) {
+    *flag = gTrue;
+  } else if (!tok->cmp("no")) {
+    *flag = gFalse;
+  } else {
+    error(-1, "Bad '%s' config file command (%s:%d)",
+         cmdName, fileName->getCString(), line);
+  }
+}
+
+GlobalParams::~GlobalParams() {
+  GHashIter *iter;
+  GString *key;
+  GList *list;
+
+  freeBuiltinFontTables();
+
+  delete macRomanReverseMap;
+
+  delete nameToUnicode;
+  deleteGHash(cidToUnicodes, GString);
+  deleteGHash(residentUnicodeMaps, UnicodeMap);
+  deleteGHash(unicodeMaps, GString);
+  deleteGList(toUnicodeDirs, GString);
+  deleteGHash(displayFonts, DisplayFontParam);
+  deleteGHash(displayCIDFonts, DisplayFontParam);
+  deleteGHash(displayNamedCIDFonts, DisplayFontParam);
+  if (psFile) {
+    delete psFile;
+  }
+  deleteGHash(psFonts, PSFontParam);
+  deleteGList(psNamedFonts16, PSFontParam);
+  deleteGList(psFonts16, PSFontParam);
+  delete textEncoding;
+  deleteGList(fontDirs, GString);
+  delete initialZoom;
+  if (urlCommand) {
+    delete urlCommand;
+  }
+
+  cMapDirs->startIter(&iter);
+  while (cMapDirs->getNext(&iter, &key, (void **)&list)) {
+    deleteGList(list, GString);
+  }
+  delete cMapDirs;
+
+  delete cidToUnicodeCache;
+  delete unicodeMapCache;
+  delete cMapCache;
+}
+
+//------------------------------------------------------------------------
+// accessors
+//------------------------------------------------------------------------
+
+CharCode GlobalParams::getMacRomanCharCode(char *charName) {
+  return macRomanReverseMap->lookup(charName);
+}
+
+Unicode GlobalParams::mapNameToUnicode(char *charName) {
+  return nameToUnicode->lookup(charName);
+}
+
+FILE *GlobalParams::getCIDToUnicodeFile(GString *collection) {
+  GString *fileName;
+
+  if (!(fileName = (GString *)cidToUnicodes->lookup(collection))) {
+    return NULL;
+  }
+  return fopen(fileName->getCString(), "r");
+}
+
+UnicodeMap *GlobalParams::getResidentUnicodeMap(GString *encodingName) {
+  return (UnicodeMap *)residentUnicodeMaps->lookup(encodingName);
+}
+
+FILE *GlobalParams::getUnicodeMapFile(GString *encodingName) {
+  GString *fileName;
+
+  if (!(fileName = (GString *)unicodeMaps->lookup(encodingName))) {
+    return NULL;
+  }
+  return fopen(fileName->getCString(), "r");
+}
+
+FILE *GlobalParams::findCMapFile(GString *collection, GString *cMapName) {
+  GList *list;
+  GString *dir;
+  GString *fileName;
+  FILE *f;
+  int i;
+
+  if (!(list = (GList *)cMapDirs->lookup(collection))) {
+    return NULL;
+  }
+  for (i = 0; i < list->getLength(); ++i) {
+    dir = (GString *)list->get(i);
+    fileName = appendToPath(dir->copy(), cMapName->getCString());
+    f = fopen(fileName->getCString(), "r");
+    delete fileName;
+    if (f) {
+      return f;
+    }
+  }
+  return NULL;
+}
+
+FILE *GlobalParams::findToUnicodeFile(GString *name) {
+  GString *dir, *fileName;
+  FILE *f;
+  int i;
+
+  for (i = 0; i < toUnicodeDirs->getLength(); ++i) {
+    dir = (GString *)toUnicodeDirs->get(i);
+    fileName = appendToPath(dir->copy(), name->getCString());
+    f = fopen(fileName->getCString(), "r");
+    delete fileName;
+    if (f) {
+      return f;
+    }
+  }
+  return NULL;
+}
+
+DisplayFontParam *GlobalParams::getDisplayFont(GString *fontName) {
+  return (DisplayFontParam *)displayFonts->lookup(fontName);
+}
+
+DisplayFontParam *GlobalParams::getDisplayCIDFont(GString *fontName,
+                                                 GString *collection) {
+  DisplayFontParam *dfp;
+
+  if (!fontName ||
+      !(dfp = (DisplayFontParam *)displayNamedCIDFonts->lookup(fontName))) {
+    dfp = (DisplayFontParam *)displayCIDFonts->lookup(collection);
+  }
+  return dfp;
+}
+
+PSFontParam *GlobalParams::getPSFont(GString *fontName) {
+  return (PSFontParam *)psFonts->lookup(fontName);
+}
+
+PSFontParam *GlobalParams::getPSFont16(GString *fontName,
+                                      GString *collection, int wMode) {
+  PSFontParam *p;
+  int i;
+
+  p = NULL;
+  if (fontName) {
+    for (i = 0; i < psNamedFonts16->getLength(); ++i) {
+      p = (PSFontParam *)psNamedFonts16->get(i);
+      if (!p->pdfFontName->cmp(fontName) &&
+         p->wMode == wMode) {
+       break;
+      }
+      p = NULL;
+    }
+  }
+  if (!p && collection) {
+    for (i = 0; i < psFonts16->getLength(); ++i) {
+      p = (PSFontParam *)psFonts16->get(i);
+      if (!p->pdfFontName->cmp(collection) &&
+         p->wMode == wMode) {
+       break;
+      }
+      p = NULL;
+    }
+  }
+  return p;
+}
+
+GString *GlobalParams::findFontFile(GString *fontName,
+                                   char *ext1, char *ext2) {
+  GString *dir, *fileName;
+  FILE *f;
+  int i;
+
+  for (i = 0; i < fontDirs->getLength(); ++i) {
+    dir = (GString *)fontDirs->get(i);
+    if (ext1) {
+      fileName = appendToPath(dir->copy(), fontName->getCString());
+      fileName->append(ext1);
+      if ((f = fopen(fileName->getCString(), "r"))) {
+       fclose(f);
+       return fileName;
+      }
+      delete fileName;
+    }
+    if (ext2) {
+      fileName = appendToPath(dir->copy(), fontName->getCString());
+      fileName->append(ext2);
+      if ((f = fopen(fileName->getCString(), "r"))) {
+       fclose(f);
+       return fileName;
+      }
+      delete fileName;
+    }
+  }
+  return NULL;
+}
+
+CharCodeToUnicode *GlobalParams::getCIDToUnicode(GString *collection) {
+  return cidToUnicodeCache->getCIDToUnicode(collection);
+}
+
+UnicodeMap *GlobalParams::getUnicodeMap(GString *encodingName) {
+  UnicodeMap *map;
+
+  if ((map = getResidentUnicodeMap(encodingName))) {
+    map->incRefCnt();
+    return map;
+  }
+  return unicodeMapCache->getUnicodeMap(encodingName);
+}
+
+CMap *GlobalParams::getCMap(GString *collection, GString *cMapName) {
+  return cMapCache->getCMap(collection, cMapName);
+}
+
+UnicodeMap *GlobalParams::getTextEncoding() {
+  return getUnicodeMap(textEncoding);
+}
+
+//------------------------------------------------------------------------
+// functions to set parameters
+//------------------------------------------------------------------------
+
+void GlobalParams::setPSFile(char *file) {
+  if (psFile) {
+    delete psFile;
+  }
+  psFile = new GString(file);
+}
+
+GBool GlobalParams::setPSPaperSize(char *size) {
+  if (!strcmp(size, "letter")) {
+    psPaperWidth = 612;
+    psPaperHeight = 792;
+  } else if (!strcmp(size, "legal")) {
+    psPaperWidth = 612;
+    psPaperHeight = 1008;
+  } else if (!strcmp(size, "A4")) {
+    psPaperWidth = 595;
+    psPaperHeight = 842;
+  } else if (!strcmp(size, "A3")) {
+    psPaperWidth = 842;
+    psPaperHeight = 1190;
+  } else {
+    return gFalse;
+  }
+  return gTrue;
+}
+
+void GlobalParams::setPSPaperWidth(int width) {
+  psPaperWidth = width;
+}
+
+void GlobalParams::setPSPaperHeight(int height) {
+  psPaperHeight = height;
+}
+
+void GlobalParams::setPSDuplex(GBool duplex) {
+  psDuplex = duplex;
+}
+
+void GlobalParams::setPSLevel(PSLevel level) {
+  psLevel = level;
+}
+
+void GlobalParams::setPSEmbedType1(GBool embed) {
+  psEmbedType1 = embed;
+}
+
+void GlobalParams::setPSEmbedTrueType(GBool embed) {
+  psEmbedTrueType = embed;
+}
+
+void GlobalParams::setPSEmbedCIDPostScript(GBool embed) {
+  psEmbedCIDPostScript = embed;
+}
+
+void GlobalParams::setPSEmbedCIDTrueType(GBool embed) {
+  psEmbedCIDTrueType = embed;
+}
+
+void GlobalParams::setPSOPI(GBool opi) {
+  psOPI = opi;
+}
+
+void GlobalParams::setPSASCIIHex(GBool hex) {
+  psASCIIHex = hex;
+}
+
+void GlobalParams::setTextEncoding(char *encodingName) {
+  delete textEncoding;
+  textEncoding = new GString(encodingName);
+}
+
+GBool GlobalParams::setTextEOL(char *s) {
+  if (!strcmp(s, "unix")) {
+    textEOL = eolUnix;
+  } else if (!strcmp(s, "dos")) {
+    textEOL = eolDOS;
+  } else if (!strcmp(s, "mac")) {
+    textEOL = eolMac;
+  } else {
+    return gFalse;
+  }
+  return gTrue;
+}
+
+void GlobalParams::setInitialZoom(char *s) {
+  delete initialZoom;
+  initialZoom = new GString(s);
+}
+
+GBool GlobalParams::setT1libControl(char *s) {
+  return setFontRastControl(&t1libControl, s);
+}
+
+GBool GlobalParams::setFreeTypeControl(char *s) {
+  return setFontRastControl(&freetypeControl, s);
+}
+
+GBool GlobalParams::setFontRastControl(FontRastControl *val, char *s) {
+  if (!strcmp(s, "none")) {
+    *val = fontRastNone;
+  } else if (!strcmp(s, "plain")) {
+    *val = fontRastPlain;
+  } else if (!strcmp(s, "low")) {
+    *val = fontRastAALow;
+  } else if (!strcmp(s, "high")) {
+    *val = fontRastAAHigh;
+  } else {
+    return gFalse;
+  }
+  return gTrue;
+}
+
+void GlobalParams::setErrQuiet(GBool errQuietA) {
+  errQuiet = errQuietA;
+}
diff --git a/pdf2swf/xpdf/GlobalParams.h b/pdf2swf/xpdf/GlobalParams.h
new file mode 100644 (file)
index 0000000..b651110
--- /dev/null
@@ -0,0 +1,273 @@
+//========================================================================
+//
+// GlobalParams.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef GLOBALPARAMS_H
+#define GLOBALPARAMS_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include <stdio.h>
+#include "gtypes.h"
+#include "CharTypes.h"
+
+class GString;
+class GList;
+class GHash;
+class NameToCharCode;
+class CharCodeToUnicode;
+class CIDToUnicodeCache;
+class UnicodeMap;
+class UnicodeMapCache;
+class CMap;
+class CMapCache;
+class GlobalParams;
+
+//------------------------------------------------------------------------
+
+// The global parameters object.
+extern GlobalParams *globalParams;
+
+//------------------------------------------------------------------------
+
+enum DisplayFontParamKind {
+  displayFontX,
+  displayFontT1,
+  displayFontTT
+};
+
+class DisplayFontParam {
+public:
+
+  GString *name;               // font name for 8-bit fonts and named
+                               //   CID fonts; collection name for
+                               //   generic CID fonts
+  DisplayFontParamKind kind;
+  union {
+    struct {
+      GString *xlfd;
+      GString *encoding;
+    } x;
+    struct {
+      GString *fileName;
+    } t1;
+    struct {
+      GString *fileName;
+    } tt;
+  };
+
+  DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
+  DisplayFontParam(char *nameA, char *xlfdA, char *encodingA);
+  ~DisplayFontParam();
+};
+
+// Font rasterizer control.
+enum FontRastControl {
+  fontRastNone,                        // don't use this rasterizer
+  fontRastPlain,               // use it, without anti-aliasing
+  fontRastAALow,               // use it, with low-level anti-aliasing
+  fontRastAAHigh               // use it, with high-level anti-aliasing
+};
+
+//------------------------------------------------------------------------
+
+class PSFontParam {
+public:
+
+  GString *pdfFontName;                // PDF font name for 8-bit fonts and
+                               //   named 16-bit fonts; char collection
+                               //   name for generic 16-bit fonts
+  int wMode;                   // writing mode (0=horiz, 1=vert) for
+                               //   16-bit fonts
+  GString *psFontName;         // PostScript font name
+  GString *encoding;           // encoding, for 16-bit fonts only
+
+  PSFontParam(GString *pdfFontNameA, int wModeA,
+             GString *psFontNameA, GString *encodingA);
+  ~PSFontParam();
+};
+
+//------------------------------------------------------------------------
+
+enum PSLevel {
+  psLevel1,
+  psLevel1Sep,
+  psLevel2,
+  psLevel2Sep,
+  psLevel3,
+  psLevel3Sep
+};
+
+//------------------------------------------------------------------------
+
+enum EndOfLineKind {
+  eolUnix,                     // LF
+  eolDOS,                      // CR+LF
+  eolMac                       // CR
+};
+
+//------------------------------------------------------------------------
+
+class GlobalParams {
+public:
+
+  // Initialize the global parameters by attempting to read a config
+  // file.
+  GlobalParams(char *cfgFileName);
+
+  ~GlobalParams();
+
+  //----- accessors
+
+  CharCode getMacRomanCharCode(char *charName);
+
+  Unicode mapNameToUnicode(char *charName);
+  FILE *getCIDToUnicodeFile(GString *collection);
+  UnicodeMap *getResidentUnicodeMap(GString *encodingName);
+  FILE *getUnicodeMapFile(GString *encodingName);
+  FILE *findCMapFile(GString *collection, GString *cMapName);
+  FILE *findToUnicodeFile(GString *name);
+  DisplayFontParam *getDisplayFont(GString *fontName);
+  DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
+  GString *getPSFile() { return psFile; }
+  int getPSPaperWidth() { return psPaperWidth; }
+  int getPSPaperHeight() { return psPaperHeight; }
+  GBool getPSDuplex() { return psDuplex; }
+  PSLevel getPSLevel() { return psLevel; }
+  PSFontParam *getPSFont(GString *fontName);
+  PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
+  GBool getPSEmbedType1() { return psEmbedType1; }
+  GBool getPSEmbedTrueType() { return psEmbedTrueType; }
+  GBool getPSEmbedCIDPostScript() { return psEmbedCIDPostScript; }
+  GBool getPSEmbedCIDTrueType() { return psEmbedCIDTrueType; }
+  GBool getPSOPI() { return psOPI; }
+  GBool getPSASCIIHex() { return psASCIIHex; }
+  GString *getTextEncodingName() { return textEncoding; }
+  EndOfLineKind getTextEOL() { return textEOL; }
+  GString *findFontFile(GString *fontName, char *ext1, char *ext2);
+  GString *getInitialZoom() { return initialZoom; }
+  FontRastControl getT1libControl() { return t1libControl; }
+  FontRastControl getFreeTypeControl() { return freetypeControl; }
+  GString *getURLCommand() { return urlCommand; }
+  GBool getMapNumericCharNames() { return mapNumericCharNames; }
+  GBool getErrQuiet() { return errQuiet; }
+
+  CharCodeToUnicode *getCIDToUnicode(GString *collection);
+  UnicodeMap *getUnicodeMap(GString *encodingName);
+  CMap *getCMap(GString *collection, GString *cMapName);
+  UnicodeMap *getTextEncoding();
+
+  //----- functions to set parameters
+
+  void setPSFile(char *file);
+  GBool setPSPaperSize(char *size);
+  void setPSPaperWidth(int width);
+  void setPSPaperHeight(int height);
+  void setPSDuplex(GBool duplex);
+  void setPSLevel(PSLevel level);
+  void setPSEmbedType1(GBool embed);
+  void setPSEmbedTrueType(GBool embed);
+  void setPSEmbedCIDPostScript(GBool embed);
+  void setPSEmbedCIDTrueType(GBool embed);
+  void setPSOPI(GBool opi);
+  void setPSASCIIHex(GBool hex);
+  void setTextEncoding(char *encodingName);
+  GBool setTextEOL(char *s);
+  void setInitialZoom(char *s);
+  GBool setT1libControl(char *s);
+  GBool setFreeTypeControl(char *s);
+  void setErrQuiet(GBool errQuietA);
+
+private:
+
+  void parseFile(GString *fileName, FILE *f);
+  void parseNameToUnicode(GList *tokens, GString *fileName, int line);
+  void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
+  void parseUnicodeMap(GList *tokens, GString *fileName, int line);
+  void parseCMapDir(GList *tokens, GString *fileName, int line);
+  void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
+  void parseDisplayFont(GList *tokens, GHash *fontHash,
+                       DisplayFontParamKind kind,
+                       GString *fileName, int line);
+  void parsePSFile(GList *tokens, GString *fileName, int line);
+  void parsePSPaperSize(GList *tokens, GString *fileName, int line);
+  void parsePSLevel(GList *tokens, GString *fileName, int line);
+  void parsePSFont(GList *tokens, GString *fileName, int line);
+  void parsePSFont16(char *cmdName, GList *fontList,
+                    GList *tokens, GString *fileName, int line);
+  void parseTextEncoding(GList *tokens, GString *fileName, int line);
+  void parseTextEOL(GList *tokens, GString *fileName, int line);
+  void parseFontDir(GList *tokens, GString *fileName, int line);
+  void parseInitialZoom(GList *tokens, GString *fileName, int line);
+  void parseFontRastControl(char *cmdName, FontRastControl *val,
+                           GList *tokens, GString *fileName, int line);
+  void parseURLCommand(GList *tokens, GString *fileName, int line);
+  void parseYesNo(char *cmdName, GBool *flag,
+                 GList *tokens, GString *fileName, int line);
+  GBool setFontRastControl(FontRastControl *val, char *s);
+
+  //----- static tables
+
+  NameToCharCode *             // mapping from char name to
+    macRomanReverseMap;                //   MacRomanEncoding index
+
+  //----- user-modifiable settings
+
+  NameToCharCode *             // mapping from char name to Unicode
+    nameToUnicode;
+  GHash *cidToUnicodes;                // files for mappings from char collections
+                               //   to Unicode, indexed by collection name
+                               //   [GString]
+  GHash *residentUnicodeMaps;  // mappings from Unicode to char codes,
+                               //   indexed by encoding name [UnicodeMap]
+  GHash *unicodeMaps;          // files for mappings from Unicode to char
+                               //   codes, indexed by encoding name [GString]
+  GHash *cMapDirs;             // list of CMap dirs, indexed by collection
+                               //   name [GList[GString]]
+  GList *toUnicodeDirs;                // list of ToUnicode CMap dirs [GString]
+  GHash *displayFonts;         // display font info, indexed by font name
+                               //   [DisplayFontParam]
+  GHash *displayCIDFonts;      // display CID font info, indexed by
+                               //   collection [DisplayFontParam]
+  GHash *displayNamedCIDFonts; // display CID font info, indexed by
+                               //   font name [DisplayFontParam]
+  GString *psFile;             // PostScript file or command (for xpdf)
+  int psPaperWidth;            // paper size, in PostScript points, for
+  int psPaperHeight;           //   PostScript output
+  GBool psDuplex;              // enable duplexing in PostScript?
+  PSLevel psLevel;             // PostScript level to generate
+  GHash *psFonts;              // PostScript font info, indexed by PDF
+                               //   font name [PSFontParam]
+  GList *psNamedFonts16;       // named 16-bit fonts [PSFontParam]
+  GList *psFonts16;            // generic 16-bit fonts [PSFontParam]
+  GBool psEmbedType1;          // embed Type 1 fonts?
+  GBool psEmbedTrueType;       // embed TrueType fonts?
+  GBool psEmbedCIDPostScript;  // embed CID PostScript fonts?
+  GBool psEmbedCIDTrueType;    // embed CID TrueType fonts?
+  GBool psOPI;                 // generate PostScript OPI comments?
+  GBool psASCIIHex;            // use ASCIIHex instead of ASCII85?
+  GString *textEncoding;       // encoding (unicodeMap) to use for text
+                               //   output
+  EndOfLineKind textEOL;       // type of EOL marker to use for text
+                               //   output
+  GList *fontDirs;             // list of font dirs [GString]
+  GString *initialZoom;                // initial zoom level
+  FontRastControl t1libControl;        // t1lib rasterization mode
+  FontRastControl              // FreeType rasterization mode
+    freetypeControl;
+  GString *urlCommand;         // command executed for URL links
+  GBool mapNumericCharNames;   // map numeric char names (from font subsets)?
+  GBool errQuiet;              // suppress error messages?
+
+  CIDToUnicodeCache *cidToUnicodeCache;
+  UnicodeMapCache *unicodeMapCache;
+  CMapCache *cMapCache;
+};
+
+#endif
diff --git a/pdf2swf/xpdf/NameToCharCode.cc b/pdf2swf/xpdf/NameToCharCode.cc
new file mode 100644 (file)
index 0000000..b9cde77
--- /dev/null
@@ -0,0 +1,115 @@
+//========================================================================
+//
+// NameToCharCode.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include <string.h>
+#include "gmem.h"
+#include "NameToCharCode.h"
+
+//------------------------------------------------------------------------
+
+struct NameToCharCodeEntry {
+  char *name;
+  CharCode c;
+};
+
+//------------------------------------------------------------------------
+
+NameToCharCode::NameToCharCode() {
+  int i;
+
+  size = 31;
+  len = 0;
+  tab = (NameToCharCodeEntry *)gmalloc(size * sizeof(NameToCharCodeEntry));
+  for (i = 0; i < size; ++i) {
+    tab[i].name = NULL;
+  }
+}
+
+NameToCharCode::~NameToCharCode() {
+  int i;
+
+  for (i = 0; i < size; ++i) {
+    if (tab[i].name) {
+      gfree(tab[i].name);
+    }
+  }
+  gfree(tab);
+}
+
+void NameToCharCode::add(char *name, CharCode c) {
+  NameToCharCodeEntry *oldTab;
+  int h, i, oldSize;
+
+  // expand the table if necessary
+  if (len >= size / 2) {
+    oldSize = size;
+    oldTab = tab;
+    size = 2*size + 1;
+    tab = (NameToCharCodeEntry *)gmalloc(size * sizeof(NameToCharCodeEntry));
+    for (h = 0; h < size; ++h) {
+      tab[h].name = NULL;
+    }
+    for (i = 0; i < oldSize; ++i) {
+      if (oldTab[i].name) {
+       h = hash(oldTab[i].name);
+       while (tab[h].name) {
+         if (++h == size) {
+           h = 0;
+         }
+       }
+       tab[h] = oldTab[i];
+      }
+    }
+    gfree(oldTab);
+  }
+
+  // add the new name
+  h = hash(name);
+  while (tab[h].name && strcmp(tab[h].name, name)) {
+    if (++h == size) {
+      h = 0;
+    }
+  }
+  if (!tab[h].name) {
+    tab[h].name = copyString(name);
+  }
+  tab[h].c = c;
+
+  ++len;
+}
+
+CharCode NameToCharCode::lookup(char *name) {
+  int h;
+
+  h = hash(name);
+  while (tab[h].name) {
+    if (!strcmp(tab[h].name, name)) {
+      return tab[h].c;
+    }
+    if (++h == size) {
+      h = 0;
+    }
+  }
+  return 0;
+}
+
+int NameToCharCode::hash(char *name) {
+  char *p;
+  unsigned int h;
+
+  h = 0;
+  for (p = name; *p; ++p) {
+    h = 17 * h + (int)(*p & 0xff);
+  }
+  return (int)(h % size);
+}
diff --git a/pdf2swf/xpdf/NameToCharCode.h b/pdf2swf/xpdf/NameToCharCode.h
new file mode 100644 (file)
index 0000000..22e41b6
--- /dev/null
@@ -0,0 +1,40 @@
+//========================================================================
+//
+// NameToCharCode.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef NAMETOCHARCODE_H
+#define NAMETOCHARCODE_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include "CharTypes.h"
+
+struct NameToCharCodeEntry;
+
+//------------------------------------------------------------------------
+
+class NameToCharCode {
+public:
+
+  NameToCharCode();
+  ~NameToCharCode();
+
+  void add(char *name, CharCode c);
+  CharCode lookup(char *name);
+
+private:
+
+  int hash(char *name);
+
+  NameToCharCodeEntry *tab;
+  int size;
+  int len;
+};
+
+#endif
diff --git a/pdf2swf/xpdf/NameToUnicodeTable.h b/pdf2swf/xpdf/NameToUnicodeTable.h
new file mode 100644 (file)
index 0000000..432fafb
--- /dev/null
@@ -0,0 +1,1055 @@
+//========================================================================
+//
+// NameToUnicodeTable.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+static struct {
+  Unicode u;
+  char *name;
+} nameToUnicodeTab[] = {
+  {0x0041, "A"},
+  {0x00c6, "AE"},
+  {0x01fc, "AEacute"},
+  {0x00c6, "AEsmall"},
+  {0x00c1, "Aacute"},
+  {0x00c1, "Aacutesmall"},
+  {0x0102, "Abreve"},
+  {0x00c2, "Acircumflex"},
+  {0x00c2, "Acircumflexsmall"},
+  {0xf6c9, "Acute"},
+  {0xf6c9, "Acutesmall"},
+  {0x00c4, "Adieresis"},
+  {0x00c4, "Adieresissmall"},
+  {0x00c0, "Agrave"},
+  {0x00c0, "Agravesmall"},
+  {0x0391, "Alpha"},
+  {0x0386, "Alphatonos"},
+  {0x0100, "Amacron"},
+  {0x0104, "Aogonek"},
+  {0x00c5, "Aring"},
+  {0x01fa, "Aringacute"},
+  {0x00c5, "Aringsmall"},
+  {0x0041, "Asmall"},
+  {0x00c3, "Atilde"},
+  {0x00c3, "Atildesmall"},
+  {0x0042, "B"},
+  {0x0392, "Beta"},
+  {0xf6f4, "Brevesmall"},
+  {0x0042, "Bsmall"},
+  {0x0043, "C"},
+  {0x0106, "Cacute"},
+  {0xf6ca, "Caron"},
+  {0xf6ca, "Caronsmall"},
+  {0x010c, "Ccaron"},
+  {0x00c7, "Ccedilla"},
+  {0x00c7, "Ccedillasmall"},
+  {0x0108, "Ccircumflex"},
+  {0x010a, "Cdotaccent"},
+  {0xf7b8, "Cedillasmall"},
+  {0x03a7, "Chi"},
+  {0xf6f6, "Circumflexsmall"},
+  {0x0043, "Csmall"},
+  {0x0044, "D"},
+  {0x010e, "Dcaron"},
+  {0x0110, "Dcroat"},
+  {0x2206, "Delta"},
+  {0xf6cb, "Dieresis"},
+  {0xf6cc, "DieresisAcute"},
+  {0xf6cd, "DieresisGrave"},
+  {0xf6cb, "Dieresissmall"},
+  {0xf6f7, "Dotaccentsmall"},
+  {0x0044, "Dsmall"},
+  {0x0045, "E"},
+  {0x00c9, "Eacute"},
+  {0x00c9, "Eacutesmall"},
+  {0x0114, "Ebreve"},
+  {0x011a, "Ecaron"},
+  {0x00ca, "Ecircumflex"},
+  {0x00ca, "Ecircumflexsmall"},
+  {0x00cb, "Edieresis"},
+  {0x00cb, "Edieresissmall"},
+  {0x0116, "Edotaccent"},
+  {0x00c8, "Egrave"},
+  {0x00c8, "Egravesmall"},
+  {0x0112, "Emacron"},
+  {0x014a, "Eng"},
+  {0x0118, "Eogonek"},
+  {0x0395, "Epsilon"},
+  {0x0388, "Epsilontonos"},
+  {0x0045, "Esmall"},
+  {0x0397, "Eta"},
+  {0x0389, "Etatonos"},
+  {0x00d0, "Eth"},
+  {0x00d0, "Ethsmall"},
+  {0x20ac, "Euro"},
+  {0x0046, "F"},
+  {0x0046, "Fsmall"},
+  {0x0047, "G"},
+  {0x0393, "Gamma"},
+  {0x011e, "Gbreve"},
+  {0x01e6, "Gcaron"},
+  {0x011c, "Gcircumflex"},
+  {0x0122, "Gcommaaccent"},
+  {0x0120, "Gdotaccent"},
+  {0xf6ce, "Grave"},
+  {0xf6ce, "Gravesmall"},
+  {0x0047, "Gsmall"},
+  {0x0048, "H"},
+  {0x25cf, "H18533"},
+  {0x25aa, "H18543"},
+  {0x25ab, "H18551"},
+  {0x25a1, "H22073"},
+  {0x0126, "Hbar"},
+  {0x0124, "Hcircumflex"},
+  {0x0048, "Hsmall"},
+  {0xf6cf, "Hungarumlaut"},
+  {0xf6cf, "Hungarumlautsmall"},
+  {0x0049, "I"},
+  {0x0132, "IJ"},
+  {0x00cd, "Iacute"},
+  {0x00cd, "Iacutesmall"},
+  {0x012c, "Ibreve"},
+  {0x00ce, "Icircumflex"},
+  {0x00ce, "Icircumflexsmall"},
+  {0x00cf, "Idieresis"},
+  {0x00cf, "Idieresissmall"},
+  {0x0130, "Idotaccent"},
+  {0x2111, "Ifraktur"},
+  {0x00cc, "Igrave"},
+  {0x00cc, "Igravesmall"},
+  {0x012a, "Imacron"},
+  {0x012e, "Iogonek"},
+  {0x0399, "Iota"},
+  {0x03aa, "Iotadieresis"},
+  {0x038a, "Iotatonos"},
+  {0x0049, "Ismall"},
+  {0x0128, "Itilde"},
+  {0x004a, "J"},
+  {0x0134, "Jcircumflex"},
+  {0x004a, "Jsmall"},
+  {0x004b, "K"},
+  {0x039a, "Kappa"},
+  {0x0136, "Kcommaaccent"},
+  {0x004b, "Ksmall"},
+  {0x004c, "L"},
+  {0xf6bf, "LL"},
+  {0x0139, "Lacute"},
+  {0x039b, "Lambda"},
+  {0x013d, "Lcaron"},
+  {0x013b, "Lcommaaccent"},
+  {0x013f, "Ldot"},
+  {0x0141, "Lslash"},
+  {0x0141, "Lslashsmall"},
+  {0x004c, "Lsmall"},
+  {0x004d, "M"},
+  {0xf6d0, "Macron"},
+  {0xf6d0, "Macronsmall"},
+  {0x004d, "Msmall"},
+  {0x039c, "Mu"},
+  {0x004e, "N"},
+  {0x0143, "Nacute"},
+  {0x0147, "Ncaron"},
+  {0x0145, "Ncommaaccent"},
+  {0x004e, "Nsmall"},
+  {0x00d1, "Ntilde"},
+  {0x00d1, "Ntildesmall"},
+  {0x039d, "Nu"},
+  {0x004f, "O"},
+  {0x0152, "OE"},
+  {0x0152, "OEsmall"},
+  {0x00d3, "Oacute"},
+  {0x00d3, "Oacutesmall"},
+  {0x014e, "Obreve"},
+  {0x00d4, "Ocircumflex"},
+  {0x00d4, "Ocircumflexsmall"},
+  {0x00d6, "Odieresis"},
+  {0x00d6, "Odieresissmall"},
+  {0xf6fb, "Ogoneksmall"},
+  {0x00d2, "Ograve"},
+  {0x00d2, "Ogravesmall"},
+  {0x01a0, "Ohorn"},
+  {0x0150, "Ohungarumlaut"},
+  {0x014c, "Omacron"},
+  {0x2126, "Omega"},
+  {0x038f, "Omegatonos"},
+  {0x039f, "Omicron"},
+  {0x038c, "Omicrontonos"},
+  {0x00d8, "Oslash"},
+  {0x01fe, "Oslashacute"},
+  {0x00d8, "Oslashsmall"},
+  {0x004f, "Osmall"},
+  {0x00d5, "Otilde"},
+  {0x00d5, "Otildesmall"},
+  {0x0050, "P"},
+  {0x03a6, "Phi"},
+  {0x03a0, "Pi"},
+  {0x03a8, "Psi"},
+  {0x0050, "Psmall"},
+  {0x0051, "Q"},
+  {0x0051, "Qsmall"},
+  {0x0052, "R"},
+  {0x0154, "Racute"},
+  {0x0158, "Rcaron"},
+  {0x0156, "Rcommaaccent"},
+  {0x211c, "Rfraktur"},
+  {0x03a1, "Rho"},
+  {0xf6fc, "Ringsmall"},
+  {0x0052, "Rsmall"},
+  {0x0053, "S"},
+  {0x250c, "SF010000"},
+  {0x2514, "SF020000"},
+  {0x2510, "SF030000"},
+  {0x2518, "SF040000"},
+  {0x253c, "SF050000"},
+  {0x252c, "SF060000"},
+  {0x2534, "SF070000"},
+  {0x251c, "SF080000"},
+  {0x2524, "SF090000"},
+  {0x2500, "SF100000"},
+  {0x2502, "SF110000"},
+  {0x2561, "SF190000"},
+  {0x2562, "SF200000"},
+  {0x2556, "SF210000"},
+  {0x2555, "SF220000"},
+  {0x2563, "SF230000"},
+  {0x2551, "SF240000"},
+  {0x2557, "SF250000"},
+  {0x255d, "SF260000"},
+  {0x255c, "SF270000"},
+  {0x255b, "SF280000"},
+  {0x255e, "SF360000"},
+  {0x255f, "SF370000"},
+  {0x255a, "SF380000"},
+  {0x2554, "SF390000"},
+  {0x2569, "SF400000"},
+  {0x2566, "SF410000"},
+  {0x2560, "SF420000"},
+  {0x2550, "SF430000"},
+  {0x256c, "SF440000"},
+  {0x2567, "SF450000"},
+  {0x2568, "SF460000"},
+  {0x2564, "SF470000"},
+  {0x2565, "SF480000"},
+  {0x2559, "SF490000"},
+  {0x2558, "SF500000"},
+  {0x2552, "SF510000"},
+  {0x2553, "SF520000"},
+  {0x256b, "SF530000"},
+  {0x256a, "SF540000"},
+  {0x015a, "Sacute"},
+  {0x0160, "Scaron"},
+  {0x0160, "Scaronsmall"},
+  {0x015e, "Scedilla"},
+  {0x015c, "Scircumflex"},
+  {0x0218, "Scommaaccent"},
+  {0x03a3, "Sigma"},
+  {0x0053, "Ssmall"},
+  {0x0054, "T"},
+  {0x03a4, "Tau"},
+  {0x0166, "Tbar"},
+  {0x0164, "Tcaron"},
+  {0x0162, "Tcommaaccent"},
+  {0x0398, "Theta"},
+  {0x00de, "Thorn"},
+  {0x00de, "Thornsmall"},
+  {0xf6fe, "Tildesmall"},
+  {0x0054, "Tsmall"},
+  {0x0055, "U"},
+  {0x00da, "Uacute"},
+  {0x00da, "Uacutesmall"},
+  {0x016c, "Ubreve"},
+  {0x00db, "Ucircumflex"},
+  {0x00db, "Ucircumflexsmall"},
+  {0x00dc, "Udieresis"},
+  {0x00dc, "Udieresissmall"},
+  {0x00d9, "Ugrave"},
+  {0x00d9, "Ugravesmall"},
+  {0x01af, "Uhorn"},
+  {0x0170, "Uhungarumlaut"},
+  {0x016a, "Umacron"},
+  {0x0172, "Uogonek"},
+  {0x03a5, "Upsilon"},
+  {0x03d2, "Upsilon1"},
+  {0x03ab, "Upsilondieresis"},
+  {0x038e, "Upsilontonos"},
+  {0x016e, "Uring"},
+  {0x0055, "Usmall"},
+  {0x0168, "Utilde"},
+  {0x0056, "V"},
+  {0x0056, "Vsmall"},
+  {0x0057, "W"},
+  {0x1e82, "Wacute"},
+  {0x0174, "Wcircumflex"},
+  {0x1e84, "Wdieresis"},
+  {0x1e80, "Wgrave"},
+  {0x0057, "Wsmall"},
+  {0x0058, "X"},
+  {0x039e, "Xi"},
+  {0x0058, "Xsmall"},
+  {0x0059, "Y"},
+  {0x00dd, "Yacute"},
+  {0x00dd, "Yacutesmall"},
+  {0x0176, "Ycircumflex"},
+  {0x0178, "Ydieresis"},
+  {0x0178, "Ydieresissmall"},
+  {0x1ef2, "Ygrave"},
+  {0x0059, "Ysmall"},
+  {0x005a, "Z"},
+  {0x0179, "Zacute"},
+  {0x017d, "Zcaron"},
+  {0x017d, "Zcaronsmall"},
+  {0x017b, "Zdotaccent"},
+  {0x0396, "Zeta"},
+  {0x005a, "Zsmall"},
+  {0x0061, "a"},
+  {0x00e1, "aacute"},
+  {0x0103, "abreve"},
+  {0x00e2, "acircumflex"},
+  {0x00b4, "acute"},
+  {0x0301, "acutecomb"},
+  {0x00e4, "adieresis"},
+  {0x00e6, "ae"},
+  {0x01fd, "aeacute"},
+  {0x2015, "afii00208"},
+  {0x0410, "afii10017"},
+  {0x0411, "afii10018"},
+  {0x0412, "afii10019"},
+  {0x0413, "afii10020"},
+  {0x0414, "afii10021"},
+  {0x0415, "afii10022"},
+  {0x0401, "afii10023"},
+  {0x0416, "afii10024"},
+  {0x0417, "afii10025"},
+  {0x0418, "afii10026"},
+  {0x0419, "afii10027"},
+  {0x041a, "afii10028"},
+  {0x041b, "afii10029"},
+  {0x041c, "afii10030"},
+  {0x041d, "afii10031"},
+  {0x041e, "afii10032"},
+  {0x041f, "afii10033"},
+  {0x0420, "afii10034"},
+  {0x0421, "afii10035"},
+  {0x0422, "afii10036"},
+  {0x0423, "afii10037"},
+  {0x0424, "afii10038"},
+  {0x0425, "afii10039"},
+  {0x0426, "afii10040"},
+  {0x0427, "afii10041"},
+  {0x0428, "afii10042"},
+  {0x0429, "afii10043"},
+  {0x042a, "afii10044"},
+  {0x042b, "afii10045"},
+  {0x042c, "afii10046"},
+  {0x042d, "afii10047"},
+  {0x042e, "afii10048"},
+  {0x042f, "afii10049"},
+  {0x0490, "afii10050"},
+  {0x0402, "afii10051"},
+  {0x0403, "afii10052"},
+  {0x0404, "afii10053"},
+  {0x0405, "afii10054"},
+  {0x0406, "afii10055"},
+  {0x0407, "afii10056"},
+  {0x0408, "afii10057"},
+  {0x0409, "afii10058"},
+  {0x040a, "afii10059"},
+  {0x040b, "afii10060"},
+  {0x040c, "afii10061"},
+  {0x040e, "afii10062"},
+  {0xf6c4, "afii10063"},
+  {0xf6c5, "afii10064"},
+  {0x0430, "afii10065"},
+  {0x0431, "afii10066"},
+  {0x0432, "afii10067"},
+  {0x0433, "afii10068"},
+  {0x0434, "afii10069"},
+  {0x0435, "afii10070"},
+  {0x0451, "afii10071"},
+  {0x0436, "afii10072"},
+  {0x0437, "afii10073"},
+  {0x0438, "afii10074"},
+  {0x0439, "afii10075"},
+  {0x043a, "afii10076"},
+  {0x043b, "afii10077"},
+  {0x043c, "afii10078"},
+  {0x043d, "afii10079"},
+  {0x043e, "afii10080"},
+  {0x043f, "afii10081"},
+  {0x0440, "afii10082"},
+  {0x0441, "afii10083"},
+  {0x0442, "afii10084"},
+  {0x0443, "afii10085"},
+  {0x0444, "afii10086"},
+  {0x0445, "afii10087"},
+  {0x0446, "afii10088"},
+  {0x0447, "afii10089"},
+  {0x0448, "afii10090"},
+  {0x0449, "afii10091"},
+  {0x044a, "afii10092"},
+  {0x044b, "afii10093"},
+  {0x044c, "afii10094"},
+  {0x044d, "afii10095"},
+  {0x044e, "afii10096"},
+  {0x044f, "afii10097"},
+  {0x0491, "afii10098"},
+  {0x0452, "afii10099"},
+  {0x0453, "afii10100"},
+  {0x0454, "afii10101"},
+  {0x0455, "afii10102"},
+  {0x0456, "afii10103"},
+  {0x0457, "afii10104"},
+  {0x0458, "afii10105"},
+  {0x0459, "afii10106"},
+  {0x045a, "afii10107"},
+  {0x045b, "afii10108"},
+  {0x045c, "afii10109"},
+  {0x045e, "afii10110"},
+  {0x040f, "afii10145"},
+  {0x0462, "afii10146"},
+  {0x0472, "afii10147"},
+  {0x0474, "afii10148"},
+  {0xf6c6, "afii10192"},
+  {0x045f, "afii10193"},
+  {0x0463, "afii10194"},
+  {0x0473, "afii10195"},
+  {0x0475, "afii10196"},
+  {0xf6c7, "afii10831"},
+  {0xf6c8, "afii10832"},
+  {0x04d9, "afii10846"},
+  {0x200e, "afii299"},
+  {0x200f, "afii300"},
+  {0x200d, "afii301"},
+  {0x066a, "afii57381"},
+  {0x060c, "afii57388"},
+  {0x0660, "afii57392"},
+  {0x0661, "afii57393"},
+  {0x0662, "afii57394"},
+  {0x0663, "afii57395"},
+  {0x0664, "afii57396"},
+  {0x0665, "afii57397"},
+  {0x0666, "afii57398"},
+  {0x0667, "afii57399"},
+  {0x0668, "afii57400"},
+  {0x0669, "afii57401"},
+  {0x061b, "afii57403"},
+  {0x061f, "afii57407"},
+  {0x0621, "afii57409"},
+  {0x0622, "afii57410"},
+  {0x0623, "afii57411"},
+  {0x0624, "afii57412"},
+  {0x0625, "afii57413"},
+  {0x0626, "afii57414"},
+  {0x0627, "afii57415"},
+  {0x0628, "afii57416"},
+  {0x0629, "afii57417"},
+  {0x062a, "afii57418"},
+  {0x062b, "afii57419"},
+  {0x062c, "afii57420"},
+  {0x062d, "afii57421"},
+  {0x062e, "afii57422"},
+  {0x062f, "afii57423"},
+  {0x0630, "afii57424"},
+  {0x0631, "afii57425"},
+  {0x0632, "afii57426"},
+  {0x0633, "afii57427"},
+  {0x0634, "afii57428"},
+  {0x0635, "afii57429"},
+  {0x0636, "afii57430"},
+  {0x0637, "afii57431"},
+  {0x0638, "afii57432"},
+  {0x0639, "afii57433"},
+  {0x063a, "afii57434"},
+  {0x0640, "afii57440"},
+  {0x0641, "afii57441"},
+  {0x0642, "afii57442"},
+  {0x0643, "afii57443"},
+  {0x0644, "afii57444"},
+  {0x0645, "afii57445"},
+  {0x0646, "afii57446"},
+  {0x0648, "afii57448"},
+  {0x0649, "afii57449"},
+  {0x064a, "afii57450"},
+  {0x064b, "afii57451"},
+  {0x064c, "afii57452"},
+  {0x064d, "afii57453"},
+  {0x064e, "afii57454"},
+  {0x064f, "afii57455"},
+  {0x0650, "afii57456"},
+  {0x0651, "afii57457"},
+  {0x0652, "afii57458"},
+  {0x0647, "afii57470"},
+  {0x06a4, "afii57505"},
+  {0x067e, "afii57506"},
+  {0x0686, "afii57507"},
+  {0x0698, "afii57508"},
+  {0x06af, "afii57509"},
+  {0x0679, "afii57511"},
+  {0x0688, "afii57512"},
+  {0x0691, "afii57513"},
+  {0x06ba, "afii57514"},
+  {0x06d2, "afii57519"},
+  {0x06d5, "afii57534"},
+  {0x20aa, "afii57636"},
+  {0x05be, "afii57645"},
+  {0x05c3, "afii57658"},
+  {0x05d0, "afii57664"},
+  {0x05d1, "afii57665"},
+  {0x05d2, "afii57666"},
+  {0x05d3, "afii57667"},
+  {0x05d4, "afii57668"},
+  {0x05d5, "afii57669"},
+  {0x05d6, "afii57670"},
+  {0x05d7, "afii57671"},
+  {0x05d8, "afii57672"},
+  {0x05d9, "afii57673"},
+  {0x05da, "afii57674"},
+  {0x05db, "afii57675"},
+  {0x05dc, "afii57676"},
+  {0x05dd, "afii57677"},
+  {0x05de, "afii57678"},
+  {0x05df, "afii57679"},
+  {0x05e0, "afii57680"},
+  {0x05e1, "afii57681"},
+  {0x05e2, "afii57682"},
+  {0x05e3, "afii57683"},
+  {0x05e4, "afii57684"},
+  {0x05e5, "afii57685"},
+  {0x05e6, "afii57686"},
+  {0x05e7, "afii57687"},
+  {0x05e8, "afii57688"},
+  {0x05e9, "afii57689"},
+  {0x05ea, "afii57690"},
+  {0xfb2a, "afii57694"},
+  {0xfb2b, "afii57695"},
+  {0xfb4b, "afii57700"},
+  {0xfb1f, "afii57705"},
+  {0x05f0, "afii57716"},
+  {0x05f1, "afii57717"},
+  {0x05f2, "afii57718"},
+  {0xfb35, "afii57723"},
+  {0x05b4, "afii57793"},
+  {0x05b5, "afii57794"},
+  {0x05b6, "afii57795"},
+  {0x05bb, "afii57796"},
+  {0x05b8, "afii57797"},
+  {0x05b7, "afii57798"},
+  {0x05b0, "afii57799"},
+  {0x05b2, "afii57800"},
+  {0x05b1, "afii57801"},
+  {0x05b3, "afii57802"},
+  {0x05c2, "afii57803"},
+  {0x05c1, "afii57804"},
+  {0x05b9, "afii57806"},
+  {0x05bc, "afii57807"},
+  {0x05bd, "afii57839"},
+  {0x05bf, "afii57841"},
+  {0x05c0, "afii57842"},
+  {0x02bc, "afii57929"},
+  {0x2105, "afii61248"},
+  {0x2113, "afii61289"},
+  {0x2116, "afii61352"},
+  {0x202c, "afii61573"},
+  {0x202d, "afii61574"},
+  {0x202e, "afii61575"},
+  {0x200c, "afii61664"},
+  {0x066d, "afii63167"},
+  {0x02bd, "afii64937"},
+  {0x00e0, "agrave"},
+  {0x2135, "aleph"},
+  {0x03b1, "alpha"},
+  {0x03ac, "alphatonos"},
+  {0x0101, "amacron"},
+  {0x0026, "ampersand"},
+  {0x0026, "ampersandsmall"},
+  {0x2220, "angle"},
+  {0x2329, "angleleft"},
+  {0x232a, "angleright"},
+  {0x0387, "anoteleia"},
+  {0x0105, "aogonek"},
+  {0x2248, "approxequal"},
+  {0x00e5, "aring"},
+  {0x01fb, "aringacute"},
+  {0x2194, "arrowboth"},
+  {0x21d4, "arrowdblboth"},
+  {0x21d3, "arrowdbldown"},
+  {0x21d0, "arrowdblleft"},
+  {0x21d2, "arrowdblright"},
+  {0x21d1, "arrowdblup"},
+  {0x2193, "arrowdown"},
+  {0xf8e7, "arrowhorizex"},
+  {0x2190, "arrowleft"},
+  {0x2192, "arrowright"},
+  {0x2191, "arrowup"},
+  {0x2195, "arrowupdn"},
+  {0x21a8, "arrowupdnbse"},
+  {0xf8e6, "arrowvertex"},
+  {0x005e, "asciicircum"},
+  {0x007e, "asciitilde"},
+  {0x002a, "asterisk"},
+  {0x2217, "asteriskmath"},
+  {0xf6e9, "asuperior"},
+  {0x0040, "at"},
+  {0x00e3, "atilde"},
+  {0x0062, "b"},
+  {0x005c, "backslash"},
+  {0x007c, "bar"},
+  {0x03b2, "beta"},
+  {0x2588, "block"},
+  {0xf8f4, "braceex"},
+  {0x007b, "braceleft"},
+  {0xf8f3, "braceleftbt"},
+  {0xf8f2, "braceleftmid"},
+  {0xf8f1, "bracelefttp"},
+  {0x007d, "braceright"},
+  {0xf8fe, "bracerightbt"},
+  {0xf8fd, "bracerightmid"},
+  {0xf8fc, "bracerighttp"},
+  {0x005b, "bracketleft"},
+  {0xf8f0, "bracketleftbt"},
+  {0xf8ef, "bracketleftex"},
+  {0xf8ee, "bracketlefttp"},
+  {0x005d, "bracketright"},
+  {0xf8fb, "bracketrightbt"},
+  {0xf8fa, "bracketrightex"},
+  {0xf8f9, "bracketrighttp"},
+  {0x02d8, "breve"},
+  {0x00a6, "brokenbar"},
+  {0xf6ea, "bsuperior"},
+  {0x2022, "bullet"},
+  {0x0063, "c"},
+  {0x0107, "cacute"},
+  {0x02c7, "caron"},
+  {0x21b5, "carriagereturn"},
+  {0x010d, "ccaron"},
+  {0x00e7, "ccedilla"},
+  {0x0109, "ccircumflex"},
+  {0x010b, "cdotaccent"},
+  {0x00b8, "cedilla"},
+  {0x00a2, "cent"},
+  {0xf6df, "centinferior"},
+  {0x00a2, "centoldstyle"},
+  {0xf6e0, "centsuperior"},
+  {0x03c7, "chi"},
+  {0x25cb, "circle"},
+  {0x2297, "circlemultiply"},
+  {0x2295, "circleplus"},
+  {0x02c6, "circumflex"},
+  {0x2663, "club"},
+  {0x003a, "colon"},
+  {0x20a1, "colonmonetary"},
+  {0x002c, "comma"},
+  {0xf6c3, "commaaccent"},
+  {0xf6e1, "commainferior"},
+  {0xf6e2, "commasuperior"},
+  {0x2245, "congruent"},
+  {0x00a9, "copyright"},
+  {0xf8e9, "copyrightsans"},
+  {0xf6d9, "copyrightserif"},
+  {0x00a4, "currency"},
+  {0xf6d1, "cyrBreve"},
+  {0xf6d2, "cyrFlex"},
+  {0xf6d4, "cyrbreve"},
+  {0xf6d5, "cyrflex"},
+  {0x0064, "d"},
+  {0x2020, "dagger"},
+  {0x2021, "daggerdbl"},
+  {0xf6d3, "dblGrave"},
+  {0xf6d6, "dblgrave"},
+  {0x010f, "dcaron"},
+  {0x0111, "dcroat"},
+  {0x00b0, "degree"},
+  {0x03b4, "delta"},
+  {0x2666, "diamond"},
+  {0x00a8, "dieresis"},
+  {0xf6d7, "dieresisacute"},
+  {0xf6d8, "dieresisgrave"},
+  {0x0385, "dieresistonos"},
+  {0x00f7, "divide"},
+  {0x2593, "dkshade"},
+  {0x2584, "dnblock"},
+  {0x0024, "dollar"},
+  {0xf6e3, "dollarinferior"},
+  {0x0024, "dollaroldstyle"},
+  {0xf6e4, "dollarsuperior"},
+  {0x20ab, "dong"},
+  {0x02d9, "dotaccent"},
+  {0x0323, "dotbelowcomb"},
+  {0x0131, "dotlessi"},
+  {0xf6be, "dotlessj"},
+  {0x22c5, "dotmath"},
+  {0xf6eb, "dsuperior"},
+  {0x0065, "e"},
+  {0x00e9, "eacute"},
+  {0x0115, "ebreve"},
+  {0x011b, "ecaron"},
+  {0x00ea, "ecircumflex"},
+  {0x00eb, "edieresis"},
+  {0x0117, "edotaccent"},
+  {0x00e8, "egrave"},
+  {0x0038, "eight"},
+  {0x2088, "eightinferior"},
+  {0x0038, "eightoldstyle"},
+  {0x2078, "eightsuperior"},
+  {0x2208, "element"},
+  {0x2026, "ellipsis"},
+  {0x0113, "emacron"},
+  {0x2014, "emdash"},
+  {0x2205, "emptyset"},
+  {0x2013, "endash"},
+  {0x014b, "eng"},
+  {0x0119, "eogonek"},
+  {0x03b5, "epsilon"},
+  {0x03ad, "epsilontonos"},
+  {0x003d, "equal"},
+  {0x2261, "equivalence"},
+  {0x212e, "estimated"},
+  {0xf6ec, "esuperior"},
+  {0x03b7, "eta"},
+  {0x03ae, "etatonos"},
+  {0x00f0, "eth"},
+  {0x0021, "exclam"},
+  {0x203c, "exclamdbl"},
+  {0x00a1, "exclamdown"},
+  {0x00a1, "exclamdownsmall"},
+  {0x0021, "exclamsmall"},
+  {0x2203, "existential"},
+  {0x0066, "f"},
+  {0x2640, "female"},
+  {0xfb00, "ff"},
+  {0xfb03, "ffi"},
+  {0xfb04, "ffl"},
+  {0xfb01, "fi"},
+  {0x2012, "figuredash"},
+  {0x25a0, "filledbox"},
+  {0x25ac, "filledrect"},
+  {0x0035, "five"},
+  {0x215d, "fiveeighths"},
+  {0x2085, "fiveinferior"},
+  {0x0035, "fiveoldstyle"},
+  {0x2075, "fivesuperior"},
+  {0xfb02, "fl"},
+  {0x0192, "florin"},
+  {0x0034, "four"},
+  {0x2084, "fourinferior"},
+  {0x0034, "fouroldstyle"},
+  {0x2074, "foursuperior"},
+  {0x2044, "fraction"},
+  {0x20a3, "franc"},
+  {0x0067, "g"},
+  {0x03b3, "gamma"},
+  {0x011f, "gbreve"},
+  {0x01e7, "gcaron"},
+  {0x011d, "gcircumflex"},
+  {0x0123, "gcommaaccent"},
+  {0x0121, "gdotaccent"},
+  {0x00df, "germandbls"},
+  {0x2207, "gradient"},
+  {0x0060, "grave"},
+  {0x0300, "gravecomb"},
+  {0x003e, "greater"},
+  {0x2265, "greaterequal"},
+  {0x00ab, "guillemotleft"},
+  {0x00bb, "guillemotright"},
+  {0x2039, "guilsinglleft"},
+  {0x203a, "guilsinglright"},
+  {0x0068, "h"},
+  {0x0127, "hbar"},
+  {0x0125, "hcircumflex"},
+  {0x2665, "heart"},
+  {0x0309, "hookabovecomb"},
+  {0x2302, "house"},
+  {0x02dd, "hungarumlaut"},
+  {0x002d, "hyphen"},
+  {0xf6e5, "hypheninferior"},
+  {0xf6e6, "hyphensuperior"},
+  {0x0069, "i"},
+  {0x00ed, "iacute"},
+  {0x012d, "ibreve"},
+  {0x00ee, "icircumflex"},
+  {0x00ef, "idieresis"},
+  {0x00ec, "igrave"},
+  {0x0133, "ij"},
+  {0x012b, "imacron"},
+  {0x221e, "infinity"},
+  {0x222b, "integral"},
+  {0x2321, "integralbt"},
+  {0xf8f5, "integralex"},
+  {0x2320, "integraltp"},
+  {0x2229, "intersection"},
+  {0x25d8, "invbullet"},
+  {0x25d9, "invcircle"},
+  {0x263b, "invsmileface"},
+  {0x012f, "iogonek"},
+  {0x03b9, "iota"},
+  {0x03ca, "iotadieresis"},
+  {0x0390, "iotadieresistonos"},
+  {0x03af, "iotatonos"},
+  {0xf6ed, "isuperior"},
+  {0x0129, "itilde"},
+  {0x006a, "j"},
+  {0x0135, "jcircumflex"},
+  {0x006b, "k"},
+  {0x03ba, "kappa"},
+  {0x0137, "kcommaaccent"},
+  {0x0138, "kgreenlandic"},
+  {0x006c, "l"},
+  {0x013a, "lacute"},
+  {0x03bb, "lambda"},
+  {0x013e, "lcaron"},
+  {0x013c, "lcommaaccent"},
+  {0x0140, "ldot"},
+  {0x003c, "less"},
+  {0x2264, "lessequal"},
+  {0x258c, "lfblock"},
+  {0x20a4, "lira"},
+  {0xf6c0, "ll"},
+  {0x2227, "logicaland"},
+  {0x00ac, "logicalnot"},
+  {0x2228, "logicalor"},
+  {0x017f, "longs"},
+  {0x25ca, "lozenge"},
+  {0x0142, "lslash"},
+  {0xf6ee, "lsuperior"},
+  {0x2591, "ltshade"},
+  {0x006d, "m"},
+  {0x00af, "macron"},
+  {0x2642, "male"},
+  {0x2212, "minus"},
+  {0x2032, "minute"},
+  {0xf6ef, "msuperior"},
+  {0x00b5, "mu"},
+  {0x00d7, "multiply"},
+  {0x266a, "musicalnote"},
+  {0x266b, "musicalnotedbl"},
+  {0x006e, "n"},
+  {0x0144, "nacute"},
+  {0x0149, "napostrophe"},
+  {0x00a0, "nbspace"},
+  {0x0148, "ncaron"},
+  {0x0146, "ncommaaccent"},
+  {0x0039, "nine"},
+  {0x2089, "nineinferior"},
+  {0x0039, "nineoldstyle"},
+  {0x2079, "ninesuperior"},
+  {0x00a0, "nonbreakingspace"},
+  {0x2209, "notelement"},
+  {0x2260, "notequal"},
+  {0x2284, "notsubset"},
+  {0x207f, "nsuperior"},
+  {0x00f1, "ntilde"},
+  {0x03bd, "nu"},
+  {0x0023, "numbersign"},
+  {0x006f, "o"},
+  {0x00f3, "oacute"},
+  {0x014f, "obreve"},
+  {0x00f4, "ocircumflex"},
+  {0x00f6, "odieresis"},
+  {0x0153, "oe"},
+  {0x02db, "ogonek"},
+  {0x00f2, "ograve"},
+  {0x01a1, "ohorn"},
+  {0x0151, "ohungarumlaut"},
+  {0x014d, "omacron"},
+  {0x03c9, "omega"},
+  {0x03d6, "omega1"},
+  {0x03ce, "omegatonos"},
+  {0x03bf, "omicron"},
+  {0x03cc, "omicrontonos"},
+  {0x0031, "one"},
+  {0x2024, "onedotenleader"},
+  {0x215b, "oneeighth"},
+  {0xf6dc, "onefitted"},
+  {0x00bd, "onehalf"},
+  {0x2081, "oneinferior"},
+  {0x0031, "oneoldstyle"},
+  {0x00bc, "onequarter"},
+  {0x00b9, "onesuperior"},
+  {0x2153, "onethird"},
+  {0x25e6, "openbullet"},
+  {0x00aa, "ordfeminine"},
+  {0x00ba, "ordmasculine"},
+  {0x221f, "orthogonal"},
+  {0x00f8, "oslash"},
+  {0x01ff, "oslashacute"},
+  {0xf6f0, "osuperior"},
+  {0x00f5, "otilde"},
+  {0x0070, "p"},
+  {0x00b6, "paragraph"},
+  {0x0028, "parenleft"},
+  {0xf8ed, "parenleftbt"},
+  {0xf8ec, "parenleftex"},
+  {0x208d, "parenleftinferior"},
+  {0x207d, "parenleftsuperior"},
+  {0xf8eb, "parenlefttp"},
+  {0x0029, "parenright"},
+  {0xf8f8, "parenrightbt"},
+  {0xf8f7, "parenrightex"},
+  {0x208e, "parenrightinferior"},
+  {0x207e, "parenrightsuperior"},
+  {0xf8f6, "parenrighttp"},
+  {0x2202, "partialdiff"},
+  {0x0025, "percent"},
+  {0x002e, "period"},
+  {0x00b7, "periodcentered"},
+  {0xf6e7, "periodinferior"},
+  {0xf6e8, "periodsuperior"},
+  {0x22a5, "perpendicular"},
+  {0x2030, "perthousand"},
+  {0x20a7, "peseta"},
+  {0x03c6, "phi"},
+  {0x03d5, "phi1"},
+  {0x03c0, "pi"},
+  {0x002b, "plus"},
+  {0x00b1, "plusminus"},
+  {0x211e, "prescription"},
+  {0x220f, "product"},
+  {0x2282, "propersubset"},
+  {0x2283, "propersuperset"},
+  {0x221d, "proportional"},
+  {0x03c8, "psi"},
+  {0x0071, "q"},
+  {0x003f, "question"},
+  {0x00bf, "questiondown"},
+  {0x00bf, "questiondownsmall"},
+  {0x003f, "questionsmall"},
+  {0x0022, "quotedbl"},
+  {0x201e, "quotedblbase"},
+  {0x201c, "quotedblleft"},
+  {0x201d, "quotedblright"},
+  {0x2018, "quoteleft"},
+  {0x201b, "quotereversed"},
+  {0x2019, "quoteright"},
+  {0x201a, "quotesinglbase"},
+  {0x0027, "quotesingle"},
+  {0x0072, "r"},
+  {0x0155, "racute"},
+  {0x221a, "radical"},
+  {0xf8e5, "radicalex"},
+  {0x0159, "rcaron"},
+  {0x0157, "rcommaaccent"},
+  {0x2286, "reflexsubset"},
+  {0x2287, "reflexsuperset"},
+  {0x00ae, "registered"},
+  {0xf8e8, "registersans"},
+  {0xf6da, "registerserif"},
+  {0x2310, "revlogicalnot"},
+  {0x03c1, "rho"},
+  {0x02da, "ring"},
+  {0xf6f1, "rsuperior"},
+  {0x2590, "rtblock"},
+  {0xf6dd, "rupiah"},
+  {0x0073, "s"},
+  {0x015b, "sacute"},
+  {0x0161, "scaron"},
+  {0x015f, "scedilla"},
+  {0x015d, "scircumflex"},
+  {0x0219, "scommaaccent"},
+  {0x2033, "second"},
+  {0x00a7, "section"},
+  {0x003b, "semicolon"},
+  {0x0037, "seven"},
+  {0x215e, "seveneighths"},
+  {0x2087, "seveninferior"},
+  {0x0037, "sevenoldstyle"},
+  {0x2077, "sevensuperior"},
+  {0x2592, "shade"},
+  {0x03c3, "sigma"},
+  {0x03c2, "sigma1"},
+  {0x223c, "similar"},
+  {0x0036, "six"},
+  {0x2086, "sixinferior"},
+  {0x0036, "sixoldstyle"},
+  {0x2076, "sixsuperior"},
+  {0x002f, "slash"},
+  {0x263a, "smileface"},
+  {0x0020, "space"},
+  {0x2660, "spade"},
+  {0xf6f2, "ssuperior"},
+  {0x00a3, "sterling"},
+  {0x220b, "suchthat"},
+  {0x2211, "summation"},
+  {0x263c, "sun"},
+  {0x0074, "t"},
+  {0x03c4, "tau"},
+  {0x0167, "tbar"},
+  {0x0165, "tcaron"},
+  {0x0163, "tcommaaccent"},
+  {0x2234, "therefore"},
+  {0x03b8, "theta"},
+  {0x03d1, "theta1"},
+  {0x00fe, "thorn"},
+  {0x0033, "three"},
+  {0x215c, "threeeighths"},
+  {0x2083, "threeinferior"},
+  {0x0033, "threeoldstyle"},
+  {0x00be, "threequarters"},
+  {0xf6de, "threequartersemdash"},
+  {0x00b3, "threesuperior"},
+  {0x02dc, "tilde"},
+  {0x0303, "tildecomb"},
+  {0x0384, "tonos"},
+  {0x2122, "trademark"},
+  {0xf8ea, "trademarksans"},
+  {0xf6db, "trademarkserif"},
+  {0x25bc, "triagdn"},
+  {0x25c4, "triaglf"},
+  {0x25ba, "triagrt"},
+  {0x25b2, "triagup"},
+  {0xf6f3, "tsuperior"},
+  {0x0032, "two"},
+  {0x2025, "twodotenleader"},
+  {0x2082, "twoinferior"},
+  {0x0032, "twooldstyle"},
+  {0x00b2, "twosuperior"},
+  {0x2154, "twothirds"},
+  {0x0075, "u"},
+  {0x00fa, "uacute"},
+  {0x016d, "ubreve"},
+  {0x00fb, "ucircumflex"},
+  {0x00fc, "udieresis"},
+  {0x00f9, "ugrave"},
+  {0x01b0, "uhorn"},
+  {0x0171, "uhungarumlaut"},
+  {0x016b, "umacron"},
+  {0x005f, "underscore"},
+  {0x2017, "underscoredbl"},
+  {0x222a, "union"},
+  {0x2200, "universal"},
+  {0x0173, "uogonek"},
+  {0x2580, "upblock"},
+  {0x03c5, "upsilon"},
+  {0x03cb, "upsilondieresis"},
+  {0x03b0, "upsilondieresistonos"},
+  {0x03cd, "upsilontonos"},
+  {0x016f, "uring"},
+  {0x0169, "utilde"},
+  {0x0076, "v"},
+  {0x0077, "w"},
+  {0x1e83, "wacute"},
+  {0x0175, "wcircumflex"},
+  {0x1e85, "wdieresis"},
+  {0x2118, "weierstrass"},
+  {0x1e81, "wgrave"},
+  {0x0078, "x"},
+  {0x03be, "xi"},
+  {0x0079, "y"},
+  {0x00fd, "yacute"},
+  {0x0177, "ycircumflex"},
+  {0x00ff, "ydieresis"},
+  {0x00a5, "yen"},
+  {0x1ef3, "ygrave"},
+  {0x007a, "z"},
+  {0x017a, "zacute"},
+  {0x017e, "zcaron"},
+  {0x017c, "zdotaccent"},
+  {0x0030, "zero"},
+  {0x2080, "zeroinferior"},
+  {0x0030, "zerooldstyle"},
+  {0x2070, "zerosuperior"},
+  {0x03b6, "zeta"},
+  { 0, NULL }
+};
diff --git a/pdf2swf/xpdf/PSTokenizer.cc b/pdf2swf/xpdf/PSTokenizer.cc
new file mode 100644 (file)
index 0000000..8d654bd
--- /dev/null
@@ -0,0 +1,133 @@
+//========================================================================
+//
+// PSTokenizer.cc
+//
+// Copyright 2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "PSTokenizer.h"
+
+//------------------------------------------------------------------------
+
+// A '1' in this array means the character is white space.  A '1' or
+// '2' means the character ends a name or command.
+static char specialChars[256] = {
+  1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0,   // 0x
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // 1x
+  1, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2,   // 2x
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0,   // 3x
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // 4x
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0,   // 5x
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // 6x
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0,   // 7x
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // 8x
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // 9x
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // ax
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // bx
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // cx
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // dx
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // ex
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0    // fx
+};
+
+//------------------------------------------------------------------------
+
+PSTokenizer::PSTokenizer(int (*getCharFuncA)(void *), void *dataA) {
+  getCharFunc = getCharFuncA;
+  data = dataA;
+  charBuf = -1;
+}
+
+PSTokenizer::~PSTokenizer() {
+}
+
+GBool PSTokenizer::getToken(char *buf, int size, int *length) {
+  GBool comment, backslash;
+  int c;
+  int i;
+
+  // skip whitespace and comments
+  comment = gFalse;
+  while (1) {
+    if ((c = getChar()) == EOF) {
+      buf[0] = '\0';
+      *length = 0;
+      return gFalse;
+    }
+    if (comment) {
+      if (c == '\x0a' || c == '\x0d') {
+       comment = gFalse;
+      }
+    } else if (c == '%') {
+      comment = gTrue;
+    } else if (specialChars[c] != 1) {
+      break;
+    }
+  }
+
+  // read a token
+  i = 0;
+  buf[i++] = c;
+  if (c == '(') {
+    backslash = gFalse;
+    while ((c = lookChar()) != EOF) {
+      if (i < size - 1) {
+       buf[i++] = c;
+      }
+      getChar();
+      if (c == '\\') {
+       backslash = gTrue;
+      } else if (!backslash && c == ')') {
+       break;
+      } else {
+       backslash = gFalse;
+      }
+    }
+  } else if (c == '<') {
+    while ((c = lookChar()) != EOF) {
+      getChar();
+      if (i < size - 1) {
+       buf[i++] = c;
+      }
+      if (c == '>') {
+       break;
+      }
+    }
+  } else if (c != '[' && c != ']') {
+    while ((c = lookChar()) != EOF && !specialChars[c]) {
+      getChar();
+      if (i < size - 1) {
+       buf[i++] = c;
+      }
+    }
+  }
+  buf[i] = '\0';
+  *length = i;
+
+  return gTrue;
+}
+
+int PSTokenizer::lookChar() {
+  if (charBuf < 0) {
+    charBuf = (*getCharFunc)(data);
+  }
+  return charBuf;
+}
+
+int PSTokenizer::getChar() {
+  int c;
+
+  if (charBuf < 0) {
+    charBuf = (*getCharFunc)(data);
+  }
+  c = charBuf;
+  charBuf = -1;
+  return c;
+}
diff --git a/pdf2swf/xpdf/PSTokenizer.h b/pdf2swf/xpdf/PSTokenizer.h
new file mode 100644 (file)
index 0000000..1053c67
--- /dev/null
@@ -0,0 +1,39 @@
+//========================================================================
+//
+// PSTokenizer.h
+//
+// Copyright 2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef PSTOKENIZER_H
+#define PSTOKENIZER_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include "gtypes.h"
+
+//------------------------------------------------------------------------
+
+class PSTokenizer {
+public:
+
+  PSTokenizer(int (*getCharFuncA)(void *), void *dataA);
+  ~PSTokenizer();
+
+  // Get the next PostScript token.  Returns false at end-of-stream.
+  GBool getToken(char *buf, int size, int *length);
+
+private:
+
+  int lookChar();
+  int getChar();
+
+  int (*getCharFunc)(void *);
+  void *data;
+  int charBuf;
+};
+
+#endif
diff --git a/pdf2swf/xpdf/UTF8.h b/pdf2swf/xpdf/UTF8.h
new file mode 100644 (file)
index 0000000..d707e2f
--- /dev/null
@@ -0,0 +1,56 @@
+//========================================================================
+//
+// UTF8.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+static int mapUTF8(Unicode u, char *buf, int bufSize) {
+  if        (u <= 0x0000007f) {
+    if (bufSize < 1) {
+      return 0;
+    }
+    buf[0] = (char)u;
+    return 1;
+  } else if (u <= 0x000007ff) {
+    if (bufSize < 2) {
+      return 0;
+    }
+    buf[0] = (char)(0xc0 + (u >> 6));
+    buf[1] = (char)(0x80 + (u & 0x3f));
+    return 2;
+  } else if (u <= 0x0000ffff) {
+    if (bufSize < 3) {
+      return 0;
+    }
+    buf[0] = (char)(0xe0 + (u >> 12));
+    buf[1] = (char)(0x80 + ((u >> 6) & 0x3f));
+    buf[2] = (char)(0x80 + (u & 0x3f));
+    return 3;
+  } else if (u <= 0x0010ffff) {
+    if (bufSize < 4) {
+      return 0;
+    }
+    buf[0] = (char)(0xf0 + (u >> 18));
+    buf[1] = (char)(0x80 + ((u >> 12) & 0x3f));
+    buf[2] = (char)(0x80 + ((u >> 6) & 0x3f));
+    buf[3] = (char)(0x80 + (u & 0x3f));
+    return 4;
+  } else {
+    return 0;
+  }
+}
+
+static int mapUCS2(Unicode u, char *buf, int bufSize) {
+  if (u <= 0xffff) {
+    if (bufSize < 2) {
+      return 0;
+    }
+    buf[0] = (char)((u >> 8) & 0xff);
+    buf[1] = (char)(u & 0xff);
+    return 2;
+  } else {
+    return 0;
+  }
+}
diff --git a/pdf2swf/xpdf/UnicodeMap.cc b/pdf2swf/xpdf/UnicodeMap.cc
new file mode 100644 (file)
index 0000000..75f23d2
--- /dev/null
@@ -0,0 +1,260 @@
+//========================================================================
+//
+// UnicodeMap.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include <stdio.h>
+#include <string.h>
+#include "gmem.h"
+#include "gfile.h"
+#include "GString.h"
+#include "GList.h"
+#include "Error.h"
+#include "GlobalParams.h"
+#include "UnicodeMap.h"
+
+//------------------------------------------------------------------------
+
+#define maxExtCode 16
+
+struct UnicodeMapExt {
+  Unicode u;                   // Unicode char
+  char code[maxExtCode];
+  Guint nBytes;
+};
+
+//------------------------------------------------------------------------
+
+UnicodeMap *UnicodeMap::parse(GString *encodingNameA) {
+  FILE *f;
+  UnicodeMap *map;
+  UnicodeMapRange *range;
+  UnicodeMapExt *eMap;
+  int size, eMapsSize;
+  char buf[256];
+  int line, nBytes, i, x;
+  char *tok1, *tok2, *tok3;
+
+  if (!(f = globalParams->getUnicodeMapFile(encodingNameA))) {
+    error(-1, "Couldn't find unicodeMap file for the '%s' encoding",
+         encodingNameA->getCString());
+    return NULL;
+  }
+
+  map = new UnicodeMap(encodingNameA->copy());
+
+  size = 8;
+  map->ranges = (UnicodeMapRange *)gmalloc(size * sizeof(UnicodeMapRange));
+  eMapsSize = 0;
+
+  line = 1;
+  while (getLine(buf, sizeof(buf), f)) {
+    if ((tok1 = strtok(buf, " \t\r\n")) &&
+       (tok2 = strtok(NULL, " \t\r\n"))) {
+      if (!(tok3 = strtok(NULL, " \t\r\n"))) {
+       tok3 = tok2;
+       tok2 = tok1;
+      }
+      nBytes = strlen(tok3) / 2;
+      if (nBytes <= 4) {
+       if (map->len == size) {
+         size *= 2;
+         map->ranges = (UnicodeMapRange *)
+           grealloc(map->ranges, size * sizeof(UnicodeMapRange));
+       }
+       range = &map->ranges[map->len];
+       sscanf(tok1, "%x", &range->start);
+       sscanf(tok2, "%x", &range->end);
+       sscanf(tok3, "%x", &range->code);
+       range->nBytes = nBytes;
+       ++map->len;
+      } else if (tok2 == tok1) {
+       if (map->eMapsLen == eMapsSize) {
+         eMapsSize += 16;
+         map->eMaps = (UnicodeMapExt *)
+           grealloc(map->eMaps, eMapsSize * sizeof(UnicodeMapExt));
+       }
+       eMap = &map->eMaps[map->eMapsLen];
+       sscanf(tok1, "%x", &eMap->u);
+       for (i = 0; i < nBytes; ++i) {
+         sscanf(tok3 + i*2, "%2x", &x);
+         eMap->code[i] = (char)x;
+       }
+       eMap->nBytes = nBytes;
+       ++map->eMapsLen;
+      } else {
+       error(-1, "Bad line (%d) in unicodeMap file for the '%s' encoding",
+             line, encodingNameA->getCString());
+      }
+    } else {
+      error(-1, "Bad line (%d) in unicodeMap file for the '%s' encoding",
+           line, encodingNameA->getCString());
+    }
+    ++line;
+  }
+
+  return map;
+}
+
+UnicodeMap::UnicodeMap(GString *encodingNameA) {
+  encodingName = encodingNameA;
+  kind = unicodeMapUser;
+  ranges = NULL;
+  len = 0;
+  eMaps = NULL;
+  eMapsLen = 0;
+  refCnt = 1;
+}
+
+UnicodeMap::UnicodeMap(char *encodingNameA,
+                      UnicodeMapRange *rangesA, int lenA) {
+  encodingName = new GString(encodingNameA);
+  kind = unicodeMapResident;
+  ranges = rangesA;
+  len = lenA;
+  eMaps = NULL;
+  eMapsLen = 0;
+  refCnt = 1;
+}
+
+UnicodeMap::UnicodeMap(char *encodingNameA, UnicodeMapFunc funcA) {
+  encodingName = new GString(encodingNameA);
+  kind = unicodeMapFunc;
+  func = funcA;
+  eMaps = NULL;
+  eMapsLen = 0;
+  refCnt = 1;
+}
+
+UnicodeMap::~UnicodeMap() {
+  delete encodingName;
+  if (kind == unicodeMapUser && ranges) {
+    gfree(ranges);
+  }
+  if (eMaps) {
+    gfree(eMaps);
+  }
+}
+
+void UnicodeMap::incRefCnt() {
+  ++refCnt;
+}
+
+void UnicodeMap::decRefCnt() {
+  if (--refCnt == 0) {
+    delete this;
+  }
+}
+
+GBool UnicodeMap::match(GString *encodingNameA) {
+  return !encodingName->cmp(encodingNameA);
+}
+
+int UnicodeMap::mapUnicode(Unicode u, char *buf, int bufSize) {
+  int a, b, m, n, i, j;
+  Guint code;
+
+  if (kind == unicodeMapFunc) {
+    return (*func)(u, buf, bufSize);
+  }
+
+  a = 0;
+  b = len;
+  if (u < ranges[a].start) {
+    return 0;
+  }
+  // invariant: ranges[a].start <= u < ranges[b].start
+  while (b - a > 1) {
+    m = (a + b) / 2;
+    if (u >= ranges[m].start) {
+      a = m;
+    } else if (u < ranges[m].start) {
+      b = m;
+    }
+  }
+  if (u <= ranges[a].end) {
+    n = ranges[a].nBytes;
+    if (n > bufSize) {
+      return 0;
+    }
+    code = ranges[a].code + (u - ranges[a].start);
+    for (i = n - 1; i >= 0; --i) {
+      buf[i] = (char)(code & 0xff);
+      code >>= 8;
+    }
+    return n;
+  }
+
+  for (i = 0; i < eMapsLen; ++i) {
+    if (eMaps[i].u == u) {
+      n = eMaps[i].nBytes;
+      for (j = 0; j < n; ++j) {
+       buf[j] = eMaps[i].code[j];
+      }
+      return n;
+    }
+  }
+
+  return 0;
+}
+
+//------------------------------------------------------------------------
+
+UnicodeMapCache::UnicodeMapCache() {
+  int i;
+
+  for (i = 0; i < unicodeMapCacheSize; ++i) {
+    cache[i] = NULL;
+  }
+}
+
+UnicodeMapCache::~UnicodeMapCache() {
+  int i;
+
+  for (i = 0; i < unicodeMapCacheSize; ++i) {
+    if (cache[i]) {
+      cache[i]->decRefCnt();
+    }
+  }
+}
+
+UnicodeMap *UnicodeMapCache::getUnicodeMap(GString *encodingName) {
+  UnicodeMap *map;
+  int i, j;
+
+  if (cache[0] && cache[0]->match(encodingName)) {
+    cache[0]->incRefCnt();
+    return cache[0];
+  }
+  for (i = 1; i < unicodeMapCacheSize; ++i) {
+    if (cache[i] && cache[i]->match(encodingName)) {
+      map = cache[i];
+      for (j = i; j >= 1; --j) {
+       cache[j] = cache[j - 1];
+      }
+      cache[0] = map;
+      map->incRefCnt();
+      return map;
+    }
+  }
+  if ((map = UnicodeMap::parse(encodingName))) {
+    if (cache[unicodeMapCacheSize - 1]) {
+      cache[unicodeMapCacheSize - 1]->decRefCnt();
+    }
+    for (j = unicodeMapCacheSize - 1; j >= 1; --j) {
+      cache[j] = cache[j - 1];
+    }
+    cache[0] = map;
+    map->incRefCnt();
+    return map;
+  }
+  return NULL;
+}
diff --git a/pdf2swf/xpdf/UnicodeMap.h b/pdf2swf/xpdf/UnicodeMap.h
new file mode 100644 (file)
index 0000000..274c447
--- /dev/null
@@ -0,0 +1,110 @@
+//========================================================================
+//
+// UnicodeMap.h
+//
+// Mapping from Unicode to an encoding.
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef UNICODEMAP_H
+#define UNICODEMAP_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include "gtypes.h"
+#include "CharTypes.h"
+
+class GString;
+
+//------------------------------------------------------------------------
+
+enum UnicodeMapKind {
+  unicodeMapUser,              // read from a file
+  unicodeMapResident,          // static list of ranges
+  unicodeMapFunc               // function pointer
+};
+
+typedef int (*UnicodeMapFunc)(Unicode u, char *buf, int bufSize);
+
+struct UnicodeMapRange {
+  Unicode start, end;          // range of Unicode chars
+  Guint code, nBytes;          // first output code
+};
+
+struct UnicodeMapExt;
+
+//------------------------------------------------------------------------
+
+class UnicodeMap {
+public:
+
+  // Create the UnicodeMap specified by <encodingName>.  Sets the
+  // initial reference count to 1.  Returns NULL on failure.
+  static UnicodeMap *parse(GString *encodingNameA);
+
+  // Create a resident UnicodeMap.
+  UnicodeMap(char *encodingNameA,
+            UnicodeMapRange *rangesA, int lenA);
+
+  // Create a resident UnicodeMap that uses a function instead of a
+  // list of ranges.
+  UnicodeMap(char *encodingNameA, UnicodeMapFunc funcA);
+
+  ~UnicodeMap();
+
+  void incRefCnt();
+  void decRefCnt();
+
+  GString *getEncodingName() { return encodingName; }
+
+  // Return true if this UnicodeMap matches the specified
+  // <encodingNameA>.
+  GBool match(GString *encodingNameA);
+
+  // Map Unicode to the target encoding.  Fills in <buf> with the
+  // output and returns the number of bytes used.  Output will be
+  // truncated at <bufSize> bytes.  No string terminator is written.
+  // Returns 0 if no mapping is found.
+  int mapUnicode(Unicode u, char *buf, int bufSize);
+
+private:
+
+  UnicodeMap(GString *encodingNameA);
+
+  GString *encodingName;
+  UnicodeMapKind kind;
+  union {
+    UnicodeMapRange *ranges;   // (user, resident)
+    UnicodeMapFunc func;       // (func)
+  };
+  int len;                     // (user, resident)
+  UnicodeMapExt *eMaps;                // (user)
+  int eMapsLen;                        // (user)
+  int refCnt;
+};
+
+//------------------------------------------------------------------------
+
+#define unicodeMapCacheSize 4
+
+class UnicodeMapCache {
+public:
+
+  UnicodeMapCache();
+  ~UnicodeMapCache();
+
+  // Get the UnicodeMap for <encodingName>.  Increments its reference
+  // count; there will be one reference for the cache plus one for the
+  // caller of this function.  Returns NULL on failure.
+  UnicodeMap *getUnicodeMap(GString *encodingName);
+
+private:
+
+  UnicodeMap *cache[unicodeMapCacheSize];
+};
+
+#endif
diff --git a/pdf2swf/xpdf/UnicodeMapTables.h b/pdf2swf/xpdf/UnicodeMapTables.h
new file mode 100644 (file)
index 0000000..51dee98
--- /dev/null
@@ -0,0 +1,361 @@
+//========================================================================
+//
+// UnicodeMapTables.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+static UnicodeMapRange latin1UnicodeMapRanges[] = {
+  { 0x000a, 0x000a, 0x0a, 1 },
+  { 0x000c, 0x000d, 0x0c, 1 },
+  { 0x0020, 0x007e, 0x20, 1 },
+  { 0x00a0, 0x00a0, 0x20, 1 },
+  { 0x00a1, 0x00ac, 0xa1, 1 },
+  { 0x00ae, 0x00ff, 0xae, 1 },
+  { 0x010c, 0x010c, 0x43, 1 },
+  { 0x010d, 0x010d, 0x63, 1 },
+  { 0x0131, 0x0131, 0x69, 1 },
+  { 0x0141, 0x0141, 0x4c, 1 },
+  { 0x0142, 0x0142, 0x6c, 1 },
+  { 0x0152, 0x0152, 0x4f45, 2 },
+  { 0x0153, 0x0153, 0x6f65, 2 },
+  { 0x0160, 0x0160, 0x53, 1 },
+  { 0x0161, 0x0161, 0x73, 1 },
+  { 0x0178, 0x0178, 0x59, 1 },
+  { 0x017d, 0x017d, 0x5a, 1 },
+  { 0x017e, 0x017e, 0x7a, 1 },
+  { 0x02c6, 0x02c6, 0x5e, 1 },
+  { 0x02da, 0x02da, 0xb0, 1 },
+  { 0x02dc, 0x02dc, 0x7e, 1 },
+  { 0x2013, 0x2013, 0xad, 1 },
+  { 0x2014, 0x2014, 0x2d2d, 2 },
+  { 0x2018, 0x2018, 0x60, 1 },
+  { 0x2019, 0x2019, 0x27, 1 },
+  { 0x201a, 0x201a, 0x2c, 1 },
+  { 0x201c, 0x201c, 0x22, 1 },
+  { 0x201d, 0x201d, 0x22, 1 },
+  { 0x201e, 0x201e, 0x2c2c, 2 },
+  { 0x2022, 0x2022, 0xb7, 1 },
+  { 0x2026, 0x2026, 0x2e2e2e, 3 },
+  { 0x2039, 0x2039, 0x3c, 1 },
+  { 0x203a, 0x203a, 0x3e, 1 },
+  { 0x2044, 0x2044, 0x2f, 1 },
+  { 0x2122, 0x2122, 0x544d, 2 },
+  { 0x2212, 0x2212, 0x2d, 1 },
+  { 0xf6f9, 0xf6f9, 0x4c, 1 },
+  { 0xf6fa, 0xf6fa, 0x4f45, 2 },
+  { 0xf6fc, 0xf6fc, 0xb0, 1 },
+  { 0xf6fd, 0xf6fd, 0x53, 1 },
+  { 0xf6fe, 0xf6fe, 0x7e, 1 },
+  { 0xf6ff, 0xf6ff, 0x5a, 1 },
+  { 0xf721, 0xf721, 0x21, 1 },
+  { 0xf724, 0xf724, 0x24, 1 },
+  { 0xf726, 0xf726, 0x26, 1 },
+  { 0xf730, 0xf739, 0x30, 1 },
+  { 0xf73f, 0xf73f, 0x3f, 1 },
+  { 0xf761, 0xf77a, 0x41, 1 },
+  { 0xf7a1, 0xf7a2, 0xa1, 1 },
+  { 0xf7bf, 0xf7bf, 0xbf, 1 },
+  { 0xf7e0, 0xf7f6, 0xc0, 1 },
+  { 0xf7f8, 0xf7fe, 0xd8, 1 },
+  { 0xf7ff, 0xf7ff, 0x59, 1 },
+  { 0xfb00, 0xfb00, 0x6666, 2 },
+  { 0xfb01, 0xfb01, 0x6669, 2 },
+  { 0xfb02, 0xfb02, 0x666c, 2 },
+  { 0xfb03, 0xfb03, 0x666669, 3 },
+  { 0xfb04, 0xfb04, 0x66666c, 3 }
+};
+#define latin1UnicodeMapLen (sizeof(latin1UnicodeMapRanges) / sizeof(UnicodeMapRange))
+
+static UnicodeMapRange ascii7UnicodeMapRanges[] = {
+  { 0x000a, 0x000a, 0x0a, 1 },
+  { 0x000c, 0x000d, 0x0c, 1 },
+  { 0x0020, 0x005f, 0x20, 1 },
+  { 0x0061, 0x007e, 0x61, 1 },
+  { 0x00a6, 0x00a6, 0x7c, 1 },
+  { 0x00a9, 0x00a9, 0x286329, 3 },
+  { 0x00ae, 0x00ae, 0x285229, 3 },
+  { 0x00b7, 0x00b7, 0x2a, 1 },
+  { 0x00bc, 0x00bc, 0x312f34, 3 },
+  { 0x00bd, 0x00bd, 0x312f32, 3 },
+  { 0x00be, 0x00be, 0x332f34, 3 },
+  { 0x00c0, 0x00c0, 0x41, 1 },
+  { 0x00c1, 0x00c1, 0x41, 1 },
+  { 0x00c2, 0x00c2, 0x41, 1 },
+  { 0x00c3, 0x00c3, 0x41, 1 },
+  { 0x00c4, 0x00c4, 0x41, 1 },
+  { 0x00c5, 0x00c5, 0x41, 1 },
+  { 0x00c6, 0x00c6, 0x4145, 2 },
+  { 0x00c7, 0x00c7, 0x43, 1 },
+  { 0x00c8, 0x00c8, 0x45, 1 },
+  { 0x00c9, 0x00c9, 0x45, 1 },
+  { 0x00ca, 0x00ca, 0x45, 1 },
+  { 0x00cb, 0x00cb, 0x45, 1 },
+  { 0x00cc, 0x00cc, 0x49, 1 },
+  { 0x00cd, 0x00cd, 0x49, 1 },
+  { 0x00ce, 0x00ce, 0x49, 1 },
+  { 0x00cf, 0x00cf, 0x49, 1 },
+  { 0x00d1, 0x00d2, 0x4e, 1 },
+  { 0x00d3, 0x00d3, 0x4f, 1 },
+  { 0x00d4, 0x00d4, 0x4f, 1 },
+  { 0x00d5, 0x00d5, 0x4f, 1 },
+  { 0x00d6, 0x00d6, 0x4f, 1 },
+  { 0x00d7, 0x00d7, 0x78, 1 },
+  { 0x00d8, 0x00d8, 0x4f, 1 },
+  { 0x00d9, 0x00d9, 0x55, 1 },
+  { 0x00da, 0x00da, 0x55, 1 },
+  { 0x00db, 0x00db, 0x55, 1 },
+  { 0x00dc, 0x00dc, 0x55, 1 },
+  { 0x00dd, 0x00dd, 0x59, 1 },
+  { 0x00e0, 0x00e0, 0x61, 1 },
+  { 0x00e1, 0x00e1, 0x61, 1 },
+  { 0x00e2, 0x00e2, 0x61, 1 },
+  { 0x00e3, 0x00e3, 0x61, 1 },
+  { 0x00e4, 0x00e4, 0x61, 1 },
+  { 0x00e5, 0x00e5, 0x61, 1 },
+  { 0x00e6, 0x00e6, 0x6165, 2 },
+  { 0x00e7, 0x00e7, 0x63, 1 },
+  { 0x00e8, 0x00e8, 0x65, 1 },
+  { 0x00e9, 0x00e9, 0x65, 1 },
+  { 0x00ea, 0x00ea, 0x65, 1 },
+  { 0x00eb, 0x00eb, 0x65, 1 },
+  { 0x00ec, 0x00ec, 0x69, 1 },
+  { 0x00ed, 0x00ed, 0x69, 1 },
+  { 0x00ee, 0x00ee, 0x69, 1 },
+  { 0x00ef, 0x00ef, 0x69, 1 },
+  { 0x00f1, 0x00f2, 0x6e, 1 },
+  { 0x00f3, 0x00f3, 0x6f, 1 },
+  { 0x00f4, 0x00f4, 0x6f, 1 },
+  { 0x00f5, 0x00f5, 0x6f, 1 },
+  { 0x00f6, 0x00f6, 0x6f, 1 },
+  { 0x00f7, 0x00f7, 0x2f, 1 },
+  { 0x00f8, 0x00f8, 0x6f, 1 },
+  { 0x00f9, 0x00f9, 0x75, 1 },
+  { 0x00fa, 0x00fa, 0x75, 1 },
+  { 0x00fb, 0x00fb, 0x75, 1 },
+  { 0x00fc, 0x00fc, 0x75, 1 },
+  { 0x00fd, 0x00fd, 0x79, 1 },
+  { 0x00ff, 0x00ff, 0x79, 1 },
+  { 0x0131, 0x0131, 0x69, 1 },
+  { 0x0141, 0x0141, 0x4c, 1 },
+  { 0x0152, 0x0152, 0x4f45, 2 },
+  { 0x0153, 0x0153, 0x6f65, 2 },
+  { 0x0160, 0x0160, 0x53, 1 },
+  { 0x0178, 0x0178, 0x59, 1 },
+  { 0x017d, 0x017d, 0x5a, 1 },
+  { 0x2013, 0x2013, 0x2d, 1 },
+  { 0x2014, 0x2014, 0x2d2d, 2 },
+  { 0x2018, 0x2018, 0x60, 1 },
+  { 0x2019, 0x2019, 0x27, 1 },
+  { 0x201c, 0x201c, 0x22, 1 },
+  { 0x201d, 0x201d, 0x22, 1 },
+  { 0x2022, 0x2022, 0x2a, 1 },
+  { 0x2026, 0x2026, 0x2e2e2e, 3 },
+  { 0x2122, 0x2122, 0x544d, 2 },
+  { 0x2212, 0x2212, 0x2d, 1 },
+  { 0xf6f9, 0xf6f9, 0x4c, 1 },
+  { 0xf6fa, 0xf6fa, 0x4f45, 2 },
+  { 0xf6fd, 0xf6fd, 0x53, 1 },
+  { 0xf6fe, 0xf6fe, 0x7e, 1 },
+  { 0xf6ff, 0xf6ff, 0x5a, 1 },
+  { 0xf721, 0xf721, 0x21, 1 },
+  { 0xf724, 0xf724, 0x24, 1 },
+  { 0xf726, 0xf726, 0x26, 1 },
+  { 0xf730, 0xf739, 0x30, 1 },
+  { 0xf73f, 0xf73f, 0x3f, 1 },
+  { 0xf761, 0xf77a, 0x41, 1 },
+  { 0xf7e0, 0xf7e0, 0x41, 1 },
+  { 0xf7e1, 0xf7e1, 0x41, 1 },
+  { 0xf7e2, 0xf7e2, 0x41, 1 },
+  { 0xf7e3, 0xf7e3, 0x41, 1 },
+  { 0xf7e4, 0xf7e4, 0x41, 1 },
+  { 0xf7e5, 0xf7e5, 0x41, 1 },
+  { 0xf7e6, 0xf7e6, 0x4145, 2 },
+  { 0xf7e7, 0xf7e7, 0x43, 1 },
+  { 0xf7e8, 0xf7e8, 0x45, 1 },
+  { 0xf7e9, 0xf7e9, 0x45, 1 },
+  { 0xf7ea, 0xf7ea, 0x45, 1 },
+  { 0xf7eb, 0xf7eb, 0x45, 1 },
+  { 0xf7ec, 0xf7ec, 0x49, 1 },
+  { 0xf7ed, 0xf7ed, 0x49, 1 },
+  { 0xf7ee, 0xf7ee, 0x49, 1 },
+  { 0xf7ef, 0xf7ef, 0x49, 1 },
+  { 0xf7f1, 0xf7f2, 0x4e, 1 },
+  { 0xf7f3, 0xf7f3, 0x4f, 1 },
+  { 0xf7f4, 0xf7f4, 0x4f, 1 },
+  { 0xf7f5, 0xf7f5, 0x4f, 1 },
+  { 0xf7f6, 0xf7f6, 0x4f, 1 },
+  { 0xf7f8, 0xf7f8, 0x4f, 1 },
+  { 0xf7f9, 0xf7f9, 0x55, 1 },
+  { 0xf7fa, 0xf7fa, 0x55, 1 },
+  { 0xf7fb, 0xf7fb, 0x55, 1 },
+  { 0xf7fc, 0xf7fc, 0x55, 1 },
+  { 0xf7fd, 0xf7fd, 0x59, 1 },
+  { 0xf7ff, 0xf7ff, 0x59, 1 },
+  { 0xfb00, 0xfb00, 0x6666, 2 },
+  { 0xfb01, 0xfb01, 0x6669, 2 },
+  { 0xfb02, 0xfb02, 0x666c, 2 },
+  { 0xfb03, 0xfb03, 0x666669, 3 },
+  { 0xfb04, 0xfb04, 0x66666c, 3 }
+};
+#define ascii7UnicodeMapLen (sizeof(ascii7UnicodeMapRanges) / sizeof(UnicodeMapRange))
+
+static UnicodeMapRange symbolUnicodeMapRanges[] = {
+  { 0x0020, 0x0021, 0x20, 1 },
+  { 0x0023, 0x0023, 0x23, 1 },
+  { 0x0025, 0x0026, 0x25, 1 },
+  { 0x0028, 0x0029, 0x28, 1 },
+  { 0x002b, 0x002c, 0x2b, 1 },
+  { 0x002e, 0x003f, 0x2e, 1 },
+  { 0x005b, 0x005b, 0x5b, 1 },
+  { 0x005d, 0x005d, 0x5d, 1 },
+  { 0x005f, 0x005f, 0x5f, 1 },
+  { 0x007b, 0x007d, 0x7b, 1 },
+  { 0x00ac, 0x00ac, 0xd8, 1 },
+  { 0x00b0, 0x00b1, 0xb0, 1 },
+  { 0x00b5, 0x00b5, 0x6d, 1 },
+  { 0x00d7, 0x00d7, 0xb4, 1 },
+  { 0x00f7, 0x00f7, 0xb8, 1 },
+  { 0x0192, 0x0192, 0xa6, 1 },
+  { 0x0391, 0x0392, 0x41, 1 },
+  { 0x0393, 0x0393, 0x47, 1 },
+  { 0x0395, 0x0395, 0x45, 1 },
+  { 0x0396, 0x0396, 0x5a, 1 },
+  { 0x0397, 0x0397, 0x48, 1 },
+  { 0x0398, 0x0398, 0x51, 1 },
+  { 0x0399, 0x0399, 0x49, 1 },
+  { 0x039a, 0x039d, 0x4b, 1 },
+  { 0x039e, 0x039e, 0x58, 1 },
+  { 0x039f, 0x03a0, 0x4f, 1 },
+  { 0x03a1, 0x03a1, 0x52, 1 },
+  { 0x03a3, 0x03a5, 0x53, 1 },
+  { 0x03a6, 0x03a6, 0x46, 1 },
+  { 0x03a7, 0x03a7, 0x43, 1 },
+  { 0x03a8, 0x03a8, 0x59, 1 },
+  { 0x03b1, 0x03b2, 0x61, 1 },
+  { 0x03b3, 0x03b3, 0x67, 1 },
+  { 0x03b4, 0x03b5, 0x64, 1 },
+  { 0x03b6, 0x03b6, 0x7a, 1 },
+  { 0x03b7, 0x03b7, 0x68, 1 },
+  { 0x03b8, 0x03b8, 0x71, 1 },
+  { 0x03b9, 0x03b9, 0x69, 1 },
+  { 0x03ba, 0x03bb, 0x6b, 1 },
+  { 0x03bd, 0x03bd, 0x6e, 1 },
+  { 0x03be, 0x03be, 0x78, 1 },
+  { 0x03bf, 0x03c0, 0x6f, 1 },
+  { 0x03c1, 0x03c1, 0x72, 1 },
+  { 0x03c2, 0x03c2, 0x56, 1 },
+  { 0x03c3, 0x03c5, 0x73, 1 },
+  { 0x03c6, 0x03c6, 0x66, 1 },
+  { 0x03c7, 0x03c7, 0x63, 1 },
+  { 0x03c8, 0x03c8, 0x79, 1 },
+  { 0x03c9, 0x03c9, 0x77, 1 },
+  { 0x03d1, 0x03d1, 0x4a, 1 },
+  { 0x03d2, 0x03d2, 0xa1, 1 },
+  { 0x03d5, 0x03d5, 0x6a, 1 },
+  { 0x03d6, 0x03d6, 0x76, 1 },
+  { 0x2022, 0x2022, 0xb7, 1 },
+  { 0x2026, 0x2026, 0xbc, 1 },
+  { 0x2032, 0x2032, 0xa2, 1 },
+  { 0x2033, 0x2033, 0xb2, 1 },
+  { 0x2044, 0x2044, 0xa4, 1 },
+  { 0x2111, 0x2111, 0xc1, 1 },
+  { 0x2118, 0x2118, 0xc3, 1 },
+  { 0x211c, 0x211c, 0xc2, 1 },
+  { 0x2126, 0x2126, 0x57, 1 },
+  { 0x2135, 0x2135, 0xc0, 1 },
+  { 0x2190, 0x2193, 0xac, 1 },
+  { 0x2194, 0x2194, 0xab, 1 },
+  { 0x21b5, 0x21b5, 0xbf, 1 },
+  { 0x21d0, 0x21d3, 0xdc, 1 },
+  { 0x21d4, 0x21d4, 0xdb, 1 },
+  { 0x2200, 0x2200, 0x22, 1 },
+  { 0x2202, 0x2202, 0xb6, 1 },
+  { 0x2203, 0x2203, 0x24, 1 },
+  { 0x2205, 0x2205, 0xc6, 1 },
+  { 0x2206, 0x2206, 0x44, 1 },
+  { 0x2207, 0x2207, 0xd1, 1 },
+  { 0x2208, 0x2209, 0xce, 1 },
+  { 0x220b, 0x220b, 0x27, 1 },
+  { 0x220f, 0x220f, 0xd5, 1 },
+  { 0x2211, 0x2211, 0xe5, 1 },
+  { 0x2212, 0x2212, 0x2d, 1 },
+  { 0x2217, 0x2217, 0x2a, 1 },
+  { 0x221a, 0x221a, 0xd6, 1 },
+  { 0x221d, 0x221d, 0xb5, 1 },
+  { 0x221e, 0x221e, 0xa5, 1 },
+  { 0x2220, 0x2220, 0xd0, 1 },
+  { 0x2227, 0x2228, 0xd9, 1 },
+  { 0x2229, 0x222a, 0xc7, 1 },
+  { 0x222b, 0x222b, 0xf2, 1 },
+  { 0x2234, 0x2234, 0x5c, 1 },
+  { 0x223c, 0x223c, 0x7e, 1 },
+  { 0x2245, 0x2245, 0x40, 1 },
+  { 0x2248, 0x2248, 0xbb, 1 },
+  { 0x2260, 0x2261, 0xb9, 1 },
+  { 0x2264, 0x2264, 0xa3, 1 },
+  { 0x2265, 0x2265, 0xb3, 1 },
+  { 0x2282, 0x2282, 0xcc, 1 },
+  { 0x2283, 0x2283, 0xc9, 1 },
+  { 0x2284, 0x2284, 0xcb, 1 },
+  { 0x2286, 0x2286, 0xcd, 1 },
+  { 0x2287, 0x2287, 0xca, 1 },
+  { 0x2295, 0x2295, 0xc5, 1 },
+  { 0x2297, 0x2297, 0xc4, 1 },
+  { 0x22a5, 0x22a5, 0x5e, 1 },
+  { 0x22c5, 0x22c5, 0xd7, 1 },
+  { 0x2320, 0x2320, 0xf3, 1 },
+  { 0x2321, 0x2321, 0xf5, 1 },
+  { 0x2329, 0x2329, 0xe1, 1 },
+  { 0x232a, 0x232a, 0xf1, 1 },
+  { 0x25ca, 0x25ca, 0xe0, 1 },
+  { 0x2660, 0x2660, 0xaa, 1 },
+  { 0x2663, 0x2663, 0xa7, 1 },
+  { 0x2665, 0x2665, 0xa9, 1 },
+  { 0x2666, 0x2666, 0xa8, 1 },
+  { 0xf6d9, 0xf6d9, 0xd3, 1 },
+  { 0xf6da, 0xf6da, 0xd2, 1 },
+  { 0xf6db, 0xf6db, 0xd4, 1 },
+  { 0xf8e5, 0xf8e5, 0x60, 1 },
+  { 0xf8e6, 0xf8e7, 0xbd, 1 },
+  { 0xf8e8, 0xf8ea, 0xe2, 1 },
+  { 0xf8eb, 0xf8f4, 0xe6, 1 },
+  { 0xf8f5, 0xf8f5, 0xf4, 1 },
+  { 0xf8f6, 0xf8fe, 0xf6, 1 }
+};
+#define symbolUnicodeMapLen (sizeof(symbolUnicodeMapRanges) / sizeof(UnicodeMapRange))
+
+static UnicodeMapRange zapfDingbatsUnicodeMapRanges[] = {
+  { 0x0020, 0x0020, 0x20, 1 },
+  { 0x2192, 0x2192, 0xd5, 1 },
+  { 0x2194, 0x2195, 0xd6, 1 },
+  { 0x2460, 0x2469, 0xac, 1 },
+  { 0x25a0, 0x25a0, 0x6e, 1 },
+  { 0x25b2, 0x25b2, 0x73, 1 },
+  { 0x25bc, 0x25bc, 0x74, 1 },
+  { 0x25c6, 0x25c6, 0x75, 1 },
+  { 0x25cf, 0x25cf, 0x6c, 1 },
+  { 0x25d7, 0x25d7, 0x77, 1 },
+  { 0x2605, 0x2605, 0x48, 1 },
+  { 0x260e, 0x260e, 0x25, 1 },
+  { 0x261b, 0x261b, 0x2a, 1 },
+  { 0x261e, 0x261e, 0x2b, 1 },
+  { 0x2660, 0x2660, 0xab, 1 },
+  { 0x2663, 0x2663, 0xa8, 1 },
+  { 0x2665, 0x2665, 0xaa, 1 },
+  { 0x2666, 0x2666, 0xa9, 1 },
+  { 0x2701, 0x2704, 0x21, 1 },
+  { 0x2706, 0x2709, 0x26, 1 },
+  { 0x270c, 0x2727, 0x2c, 1 },
+  { 0x2729, 0x274b, 0x49, 1 },
+  { 0x274d, 0x274d, 0x6d, 1 },
+  { 0x274f, 0x2752, 0x6f, 1 },
+  { 0x2756, 0x2756, 0x76, 1 },
+  { 0x2758, 0x275e, 0x78, 1 },
+  { 0x2761, 0x2767, 0xa1, 1 },
+  { 0x2776, 0x2794, 0xb6, 1 },
+  { 0x2798, 0x27af, 0xd8, 1 },
+  { 0x27b1, 0x27be, 0xf1, 1 }
+};
+#define zapfDingbatsUnicodeMapLen (sizeof(zapfDingbatsUnicodeMapRanges) / sizeof(UnicodeMapRange))
diff --git a/pdf2swf/xpdf/aconf.h b/pdf2swf/xpdf/aconf.h
new file mode 100644 (file)
index 0000000..f6ce251
--- /dev/null
@@ -0,0 +1,84 @@
+/* aconf.h.  Generated by configure.  */
+/*
+ * aconf.h
+ *
+ * Copyright 2002 Glyph & Cog, LLC
+ */
+
+#ifndef ACONF_H
+#define ACONF_H
+
+/*
+ * Use A4 paper size instead of Letter for PostScript output.
+ */
+/* #undef A4_PAPER */
+
+/*
+ * Do not allow text selection.
+ */
+/* #undef NO_TEXT_SELECT */
+
+/*
+ * Include support for OPI comments.
+ */
+/* #undef OPI_SUPPORT */
+
+/*
+ * Use gzip instead of uncompress.
+ */
+/* #undef USE_GZIP */
+
+/*
+ * Directory with the Xpdf app-defaults file.
+ */
+/* #undef APPDEFDIR */
+
+/*
+ * Full path for the system-wide xpdfrc file.
+ */
+#define SYSTEM_XPDFRC "/usr/local/etc/xpdfrc"
+
+/*
+ * Various include files and functions.
+ */
+#define HAVE_DIRENT_H 1
+/* #undef HAVE_SYS_NDIR_H */
+/* #undef HAVE_SYS_DIR_H */
+/* #undef HAVE_NDIR_H */
+/* #undef HAVE_SYS_SELECT_H */
+/* #undef HAVE_SYS_BSDTYPES_H */
+#define HAVE_STRINGS_H 1
+/* #undef HAVE_BSTRING_H */
+#define HAVE_POPEN 1
+#define HAVE_MKSTEMP 1
+/* #undef HAVE_MKSTEMPS */
+/* #undef SELECT_TAKES_INT */
+/* #undef HAVE_FSEEK64 */
+
+/*
+ * This is defined if using libXpm.
+ */
+#define HAVE_X11_XPM_H 1
+
+/*
+ * This is defined if using t1lib.
+ */
+#define HAVE_T1LIB_H 1
+
+/*
+ * One of these is defined if using FreeType (version 1 or 2).
+ */
+/* #undef HAVE_FREETYPE_H */
+/* #undef HAVE_FREETYPE_FREETYPE_H */
+
+/*
+ * This is defined if using FreeType version 2.
+ */
+/* #undef FREETYPE2 */
+
+/*
+ * This is defined if using libpaper.
+ */
+/* #undef HAVE_PAPER_H */
+
+#endif