[poppler] Branch 'xpdf303merge' - 7 commits - poppler/FontInfo.cc poppler/GfxFont.cc poppler/GfxFont.h poppler/PSOutputDev.cc poppler/TextOutputDev.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Thu Oct 20 06:02:22 PDT 2011


 poppler/FontInfo.cc      |    4 -
 poppler/GfxFont.cc       |   96 +++++++++++++++++++++++++++++++++++++----------
 poppler/GfxFont.h        |   43 ++++++++++++++++++---
 poppler/PSOutputDev.cc   |    8 +--
 poppler/TextOutputDev.cc |    5 --
 5 files changed, 122 insertions(+), 34 deletions(-)

New commits:
commit aa83d4fe942ef0685c5990ddf3eccc2fbdf82292
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Oct 20 00:59:57 2011 +0200

    xpdf303: Add readFromStream

diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 8749a82..a5006f0 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -182,6 +182,12 @@ GfxFontLoc::~GfxFontLoc() {
 }
 
 //------------------------------------------------------------------------
+
+static int readFromStream(void *data) {
+  return ((Stream *)data)->getChar();
+}
+
+//------------------------------------------------------------------------
 // GfxFont
 //------------------------------------------------------------------------
 
commit 74d771d58a4d1868669117709eb6811ec28bf840
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Oct 20 00:56:58 2011 +0200

    xpdf303: Add base14SubstFonts

diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 3947d1d..8749a82 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -133,6 +133,30 @@ static const Base14FontMapEntry base14FontMap[] = {
   { "ZapfDingbats",                 "ZapfDingbats" }
 };
 
+//------------------------------------------------------------------------
+
+// index: {fixed:0, sans-serif:4, serif:8} + bold*2 + italic
+// NB: must be in same order as psSubstFonts in PSOutputDev.cc
+static const char *base14SubstFonts[14] = {
+  "Courier",
+  "Courier-Oblique",
+  "Courier-Bold",
+  "Courier-BoldOblique",
+  "Helvetica",
+  "Helvetica-Oblique",
+  "Helvetica-Bold",
+  "Helvetica-BoldOblique",
+  "Times-Roman",
+  "Times-Italic",
+  "Times-Bold",
+  "Times-BoldItalic",
+  // the last two are never used for substitution
+  "Symbol",
+  "ZapfDingbats"
+};
+
+//------------------------------------------------------------------------
+
 static int parseCharName(char *charName, Unicode *uBuf, int uLen,
 			 GBool names, GBool ligatures, 
 			 GBool numeric, GBool hex, GBool variants);
commit 71260f987161d5b122caced6af14e9d64be46e4d
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Oct 20 00:55:42 2011 +0200

    xpdf303: GfxFontLoc implementation

diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 2dbce59..3947d1d 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -138,6 +138,26 @@ static int parseCharName(char *charName, Unicode *uBuf, int uLen,
 			 GBool numeric, GBool hex, GBool variants);
 
 //------------------------------------------------------------------------
+// GfxFontLoc
+//------------------------------------------------------------------------
+
+GfxFontLoc::GfxFontLoc() {
+  path = NULL;
+  fontNum = 0;
+  encoding = NULL;
+  substIdx = -1;
+}
+
+GfxFontLoc::~GfxFontLoc() {
+  if (path) {
+    delete path;
+  }
+  if (encoding) {
+    delete encoding;
+  }
+}
+
+//------------------------------------------------------------------------
 // GfxFont
 //------------------------------------------------------------------------
 
commit 586430137985fd303ce87bdb9b902ee9a01341e8
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Oct 20 00:54:09 2011 +0200

    xpdf303: More stuff into base14FontMap

diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index ae9e9c9..2dbce59 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -77,9 +77,13 @@ static const Base14FontMapEntry base14FontMap[] = {
   { "Arial-Italic",                 "Helvetica-Oblique" },
   { "Arial-ItalicMT",               "Helvetica-Oblique" },
   { "ArialMT",                      "Helvetica" },
+  { "Courier",                      "Courier" },
   { "Courier,Bold",                 "Courier-Bold" },
   { "Courier,BoldItalic",           "Courier-BoldOblique" },
   { "Courier,Italic",               "Courier-Oblique" },
+  { "Courier-Bold",                 "Courier-Bold" },
+  { "Courier-BoldOblique",          "Courier-BoldOblique" },
+  { "Courier-Oblique",              "Courier-Oblique" },
   { "CourierNew",                   "Courier" },
   { "CourierNew,Bold",              "Courier-Bold" },
   { "CourierNew,BoldItalic",        "Courier-BoldOblique" },
@@ -91,14 +95,23 @@ static const Base14FontMapEntry base14FontMap[] = {
   { "CourierNewPS-BoldMT",          "Courier-Bold" },
   { "CourierNewPS-ItalicMT",        "Courier-Oblique" },
   { "CourierNewPSMT",               "Courier" },
+  { "Helvetica",                    "Helvetica" },
   { "Helvetica,Bold",               "Helvetica-Bold" },
   { "Helvetica,BoldItalic",         "Helvetica-BoldOblique" },
   { "Helvetica,Italic",             "Helvetica-Oblique" },
+  { "Helvetica-Bold",               "Helvetica-Bold" },
   { "Helvetica-BoldItalic",         "Helvetica-BoldOblique" },
+  { "Helvetica-BoldOblique",        "Helvetica-BoldOblique" },
   { "Helvetica-Italic",             "Helvetica-Oblique" },
+  { "Helvetica-Oblique",            "Helvetica-Oblique" },
+  { "Symbol",                       "Symbol" },
   { "Symbol,Bold",                  "Symbol" },
   { "Symbol,BoldItalic",            "Symbol" },
   { "Symbol,Italic",                "Symbol" },
+  { "Times-Bold",                   "Times-Bold" },
+  { "Times-BoldItalic",             "Times-BoldItalic" },
+  { "Times-Italic",                 "Times-Italic" },
+  { "Times-Roman",                  "Times-Roman" },
   { "TimesNewRoman",                "Times-Roman" },
   { "TimesNewRoman,Bold",           "Times-Bold" },
   { "TimesNewRoman,BoldItalic",     "Times-BoldItalic" },
@@ -116,7 +129,8 @@ static const Base14FontMapEntry base14FontMap[] = {
   { "TimesNewRomanPSMT",            "Times-Roman" },
   { "TimesNewRomanPSMT,Bold",       "Times-Bold" },
   { "TimesNewRomanPSMT,BoldItalic", "Times-BoldItalic" },
-  { "TimesNewRomanPSMT,Italic",     "Times-Italic" }
+  { "TimesNewRomanPSMT,Italic",     "Times-Italic" },
+  { "ZapfDingbats",                 "ZapfDingbats" }
 };
 
 static int parseCharName(char *charName, Unicode *uBuf, int uLen,
commit c0affb1845c339f89ca67608cb9fd9134ff902f5
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Oct 20 00:51:31 2011 +0200

    xpdf303: GfxFont::getOrignName/getName rework

diff --git a/poppler/FontInfo.cc b/poppler/FontInfo.cc
index 7352ed1..9c6a97e 100644
--- a/poppler/FontInfo.cc
+++ b/poppler/FontInfo.cc
@@ -172,9 +172,9 @@ FontInfo::FontInfo(GfxFont *font, PDFDoc *doc) {
   fontRef = *font->getID();
 
   // font name
-  origName = font->getOrigName();
+  origName = font->getName();
   if (origName != NULL) {
-    name = font->getOrigName()->copy();
+    name = font->getName()->copy();
   } else {
     name = NULL;
   }
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index abb8614..ae9e9c9 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -168,7 +168,6 @@ GfxFont::GfxFont(const char *tagA, Ref idA, GooString *nameA) {
   tag = new GooString(tagA);
   id = idA;
   name = nameA;
-  origName = nameA;
   embFontName = NULL;
   extFontFile = NULL;
   family = NULL;
@@ -182,9 +181,6 @@ GfxFont::GfxFont(const char *tagA, Ref idA, GooString *nameA) {
 GfxFont::~GfxFont() {
   delete tag;
   delete family;
-  if (origName && origName != name) {
-    delete origName;
-  }
   if (name) {
     delete name;
   }
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index 8172352..2207b9f 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -187,9 +187,6 @@ public:
   // Does this font match the tag?
   GBool matches(char *tagA) { return !tag->cmp(tagA); }
 
-  // Get base font name.
-  GooString *getName() { return name; }
-  
   // Get font family name.
   GooString *getFamily() { return family; }
   
@@ -201,7 +198,7 @@ public:
 
   // Get the original font name (ignornig any munging that might have
   // been done to map to a canonical Base-14 font name).
-  GooString *getOrigName() { return origName; }
+  GooString *getName() { return name; }
 
   // Get font type.
   GfxFontType getType() { return type; }
@@ -281,7 +278,6 @@ protected:
   GooString *family;		// font family
   Stretch stretch;			// font stretch
   Weight weight;			// font weight
-  GooString *origName;		// original font name
   GfxFontType type;		// type of font
   int flags;			// font descriptor flags
   GooString *embFontName;		// name of embedded font
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 2a2388a..37e4bb6 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -1708,20 +1708,20 @@ void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) {
   } else if (globalParams->getPSEmbedType1() &&
 	     font->getType() == fontType1C &&
 	     font->getEmbeddedFontID(&fontFileID) &&
-	     font->getOrigName()) {
+	     font->getName()) {
     // use the PDF font name because the embedded font name might
     // not include the subset prefix
-    psName = font->getOrigName()->sanitizedName(gTrue /* ps mode */);
+    psName = font->getName()->sanitizedName(gTrue /* ps mode */);
     setupEmbeddedType1CFont(font, &fontFileID, psName);
 
   // check for embedded OpenType - Type 1C font
   } else if (globalParams->getPSEmbedType1() &&
 	     font->getType() == fontType1COT &&
 	     font->getEmbeddedFontID(&fontFileID) &&
-	     font->getOrigName()) {
+	     font->getName()) {
     // use the PDF font name because the embedded font name might
     // not include the subset prefix
-    psName = font->getOrigName()->sanitizedName(gTrue /* ps mode */);
+    psName = font->getName()->sanitizedName(gTrue /* ps mode */);
     setupEmbeddedOpenTypeT1CFont(font, &fontFileID, psName);
 
   // check for external Type 1 font file
diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index 5de089f..570d53d 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -205,9 +205,8 @@ TextFontInfo::TextFontInfo(GfxState *state) {
   if (gfxFont)
     gfxFont->incRefCnt();
 #if TEXTOUT_WORD_LIST
-  fontName = (gfxFont && gfxFont->getOrigName())
-                 ? gfxFont->getOrigName()->copy()
-                 : (GooString *)NULL;
+  fontName = (gfxFont && gfxFont->getName()) ? gfxFont->getName()->copy()
+                                             : (GooString *)NULL;
   flags = gfxFont ? gfxFont->getFlags() : 0;
 #endif
 }
commit c5c513b5b72e03f6f0a94d04f7d8a22fe9bdaa80
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Oct 20 00:45:30 2011 +0200

    xpdf303: GfxFontLoc

diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index 09c0bf1..8172352 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -97,6 +97,41 @@ struct GfxFontCIDWidths {
 };
 
 //------------------------------------------------------------------------
+// GfxFontLoc
+//------------------------------------------------------------------------
+
+enum GfxFontLocType {
+  gfxFontLocEmbedded,		// font embedded in PDF file
+  gfxFontLocExternal,		// external font file
+  gfxFontLocResident		// font resident in PS printer
+};
+
+class GfxFontLoc {
+public:
+
+  GfxFontLoc();
+  ~GfxFontLoc();
+
+  GfxFontLocType locType;
+  GfxFontType fontType;
+  Ref embFontID;		// embedded stream obj ID
+				//   (if locType == gfxFontLocEmbedded)
+  GooString *path;		// font file path
+				//   (if locType == gfxFontLocExternal)
+				// PS font name
+				//   (if locType == gfxFontLocResident)
+  int fontNum;			// for TrueType collections
+				//   (if locType == gfxFontLocExternal)
+  GooString *encoding;		// PS font encoding, only for 16-bit fonts
+				//   (if locType == gfxFontLocResident)
+  int wMode;			// writing mode, only for 16-bit fonts
+				//   (if locType == gfxFontLocResident)
+  int substIdx;			// substitute font index
+				//   (if locType == gfxFontLocExternal,
+				//   and a Base-14 substitution was made)
+};
+
+//------------------------------------------------------------------------
 // GfxFont
 //------------------------------------------------------------------------
 
commit 4ec5e5e6d4785eb7a60744ae7e33c7ba3f603e8e
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Oct 20 00:34:10 2011 +0200

    xpdf303: StdFontMapEntry renaming

diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index d81cf4f..abb8614 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -60,17 +60,12 @@
 
 //------------------------------------------------------------------------
 
-struct StdFontMapEntry {
+struct Base14FontMapEntry {
   const char *altName;
-  const char *properName;
+  const char *base14Name;
 };
 
-// Acrobat 4.0 and earlier substituted Base14-compatible fonts without
-// providing Widths and a FontDescriptor, so we munge the names into
-// the proper Base14 names.  This table is from implementation note 44
-// in the PDF 1.4 spec, with some additions based on empirical
-// evidence.
-static const StdFontMapEntry stdFontMap[] = {
+static const Base14FontMapEntry base14FontMap[] = {
   { "Arial",                        "Helvetica" },
   { "Arial,Bold",                   "Helvetica-Bold" },
   { "Arial,BoldItalic",             "Helvetica-BoldOblique" },
@@ -548,6 +543,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
 
   // do font name substitution for various aliases of the Base 14 font
   // names
+  base14 = NULL;
   if (name) {
     name2 = name->copy();
     i = 0;
@@ -559,27 +555,27 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
       }
     }
     a = 0;
-    b = sizeof(stdFontMap) / sizeof(StdFontMapEntry);
-    // invariant: stdFontMap[a].altName <= name2 < stdFontMap[b].altName
+    b = sizeof(base14FontMap) / sizeof(Base14FontMapEntry);
+    // invariant: base14FontMap[a].altName <= name2 < base14FontMap[b].altName
     while (b - a > 1) {
       m = (a + b) / 2;
-      if (name2->cmp(stdFontMap[m].altName) >= 0) {
+      if (name2->cmp(base14FontMap[m].altName) >= 0) {
 	a = m;
       } else {
 	b = m;
       }
     }
-    if (!name2->cmp(stdFontMap[a].altName)) {
-      name = new GooString(stdFontMap[a].properName);
+    if (!name2->cmp(base14FontMap[a].altName)) {
+      base14 = &base14FontMap[a];
     }
     delete name2;
   }
 
   // is it a built-in font?
   builtinFont = NULL;
-  if (name) {
+  if (base14) {
     for (i = 0; i < nBuiltinFonts; ++i) {
-      if (!name->cmp(builtinFonts[i].name)) {
+      if (!strcmp(base14->base14Name, builtinFonts[i].name)) {
 	builtinFont = &builtinFonts[i];
 	break;
       }
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index bf26c13..09c0bf1 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -45,6 +45,7 @@ class CharCodeToUnicode;
 class FoFiTrueType;
 class DisplayFontParam;
 struct GfxFontCIDWidths;
+struct Base14FontMapEntry;
 
 //------------------------------------------------------------------------
 // GfxFontType
@@ -309,6 +310,7 @@ public:
 private:
   virtual ~Gfx8BitFont();
 
+  const Base14FontMapEntry *base14;	// for Base-14 fonts only; NULL otherwise
   char *enc[256];		// char code --> char name
   char encFree[256];		// boolean for each char name: if set,
 				//   the string is malloc'ed


More information about the poppler mailing list