[poppler] 2 commits - poppler/GfxState.h poppler/GlobalParams.cc poppler/GlobalParams.h poppler/PSOutputDev.cc poppler/PSOutputDev.h utils/pdftops.1 utils/pdftops.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sat Aug 1 06:28:48 PDT 2009


 poppler/GfxState.h      |    1 
 poppler/GlobalParams.cc |   17 +++++++++++++
 poppler/GlobalParams.h  |    4 +++
 poppler/PSOutputDev.cc  |   59 ++++++++++++++++++++++++++----------------------
 poppler/PSOutputDev.h   |    2 +
 utils/pdftops.1         |    8 +++++-
 utils/pdftops.cc        |    7 +++++
 7 files changed, 71 insertions(+), 27 deletions(-)

New commits:
commit e21a3e40bf6f4365064cea751ae186580d8f81f5
Author: William Bader <williambader at hotmail.com>
Date:   Sat Aug 1 15:23:03 2009 +0200

    Add the possibility of disabling font substitution in pdftops
    
    Bug #23030

diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 177bc8a..1cf7208 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -20,6 +20,7 @@
 // Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk at gmail.com>
 // Copyright (C) 2007, 2009 Jonathan Kew <jonathan_kew at sil.org>
 // Copyright (C) 2009 Petr Gajdos <pgajdos at novell.com>
+// Copyright (C) 2009 William Bader <williambader at hotmail.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -602,6 +603,7 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir)
   psEmbedTrueType = gTrue;
   psEmbedCIDPostScript = gTrue;
   psEmbedCIDTrueType = gTrue;
+  psSubstFonts = gTrue;
   psPreload = gFalse;
   psOPI = gFalse;
   psASCIIHex = gFalse;
@@ -1280,6 +1282,15 @@ GBool GlobalParams::getPSEmbedCIDTrueType() {
   return e;
 }
 
+GBool GlobalParams::getPSSubstFonts() {
+  GBool e;
+
+  lockGlobalParams;
+  e = psSubstFonts;
+  unlockGlobalParams;
+  return e;
+}
+
 GBool GlobalParams::getPSPreload() {
   GBool preload;
 
@@ -1649,6 +1660,12 @@ void GlobalParams::setPSEmbedCIDTrueType(GBool embed) {
   unlockGlobalParams;
 }
 
+void GlobalParams::setPSSubstFonts(GBool substFonts) {
+  lockGlobalParams;
+  psSubstFonts = substFonts;
+  unlockGlobalParams;
+}
+
 void GlobalParams::setPSPreload(GBool preload) {
   lockGlobalParams;
   psPreload = preload;
diff --git a/poppler/GlobalParams.h b/poppler/GlobalParams.h
index 5a724af..27a41cc 100644
--- a/poppler/GlobalParams.h
+++ b/poppler/GlobalParams.h
@@ -20,6 +20,7 @@
 // Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk at gmail.com>
 // Copyright (C) 2009 Jonathan Kew <jonathan_kew at sil.org>
 // Copyright (C) 2009 Petr Gajdos <pgajdos at novell.com>
+// Copyright (C) 2009 William Bader <williambader at hotmail.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -193,6 +194,7 @@ public:
   GBool getPSEmbedTrueType();
   GBool getPSEmbedCIDPostScript();
   GBool getPSEmbedCIDTrueType();
+  GBool getPSSubstFonts();
   GBool getPSPreload();
   GBool getPSOPI();
   GBool getPSASCIIHex();
@@ -238,6 +240,7 @@ public:
   void setPSEmbedTrueType(GBool embed);
   void setPSEmbedCIDPostScript(GBool embed);
   void setPSEmbedCIDTrueType(GBool embed);
+  void setPSSubstFonts(GBool substFonts);
   void setPSPreload(GBool preload);
   void setPSOPI(GBool opi);
   void setPSASCIIHex(GBool hex);
@@ -317,6 +320,7 @@ private:
   GBool psEmbedTrueType;	// embed TrueType fonts?
   GBool psEmbedCIDPostScript;	// embed CID PostScript fonts?
   GBool psEmbedCIDTrueType;	// embed CID TrueType fonts?
+  GBool psSubstFonts;		// substitute missing fonts?
   GBool psPreload;		// preload PostScript images and forms into
 				//   memory
   GBool psOPI;			// generate PostScript OPI comments?
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 881427f..bebe48a 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -23,6 +23,7 @@
 // Copyright (C) 2009 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2009 Till Kamppeter <till.kamppeter at gmail.com>
 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
+// Copyright (C) 2009 William Bader <williambader at hotmail.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -1106,6 +1107,7 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
       paperHeight = 1;
     }
   }
+  substFonts = globalParams->getPSSubstFonts();
   preload = globalParams->getPSPreload();
   if (imgLLX == 0 && imgURX == 0 && imgLLY == 0 && imgURY == 0) {
     imgLLX = imgLLY = 0;
@@ -1751,34 +1753,39 @@ void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) {
       }
     }
     if (!psName) {
-      if (font->isFixedWidth()) {
-	i = 8;
-      } else if (font->isSerif()) {
-	i = 4;
-      } else {
-	i = 0;
-      }
-      if (font->isBold()) {
-	i += 2;
-      }
-      if (font->isItalic()) {
-	i += 1;
-      }
-      psName = new GooString(psSubstFonts[i].psName);
-      for (code = 0; code < 256; ++code) {
-	if ((charName = ((Gfx8BitFont *)font)->getCharName(code)) &&
-	    charName[0] == 'm' && charName[1] == '\0') {
-	  break;
+      if (substFonts) {
+	if (font->isFixedWidth()) {
+	  i = 8;
+	} else if (font->isSerif()) {
+	  i = 4;
+	} else {
+	  i = 0;
+	}
+	if (font->isBold()) {
+	  i += 2;
+	}
+	if (font->isItalic()) {
+	  i += 1;
+	}
+	psName = new GooString(psSubstFonts[i].psName);
+	for (code = 0; code < 256; ++code) {
+	  if ((charName = ((Gfx8BitFont *)font)->getCharName(code)) &&
+	      charName[0] == 'm' && charName[1] == '\0') {
+	    break;
+	  }
+	}
+	if (code < 256) {
+	  w1 = ((Gfx8BitFont *)font)->getWidth(code);
+	} else {
+	  w1 = 0;
+	}
+	w2 = psSubstFonts[i].mWidth;
+	xs = w1 / w2;
+	if (xs < 0.1) {
+	  xs = 1;
 	}
-      }
-      if (code < 256) {
-	w1 = ((Gfx8BitFont *)font)->getWidth(code);
       } else {
-	w1 = 0;
-      }
-      w2 = psSubstFonts[i].mWidth;
-      xs = w1 / w2;
-      if (xs < 0.1) {
+	psName = new GooString(name);
 	xs = 1;
       }
       if (font->getType() == fontType3) {
diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h
index 5fc3edd..e8bf29f 100644
--- a/poppler/PSOutputDev.h
+++ b/poppler/PSOutputDev.h
@@ -20,6 +20,7 @@
 // Copyright (C) 2009 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2009 Till Kamppeter <till.kamppeter at gmail.com>
 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
+// Copyright (C) 2009 William Bader <williambader at hotmail.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -358,6 +359,7 @@ private:
                                 // (only psModePSOrigPageSizes output mode)
   int imgLLX, imgLLY,		// imageable area, in pts
       imgURX, imgURY;
+  GBool substFonts;		// substitute missing fonts
   GBool preload;		// load all images into memory, and
 				//   predefine forms
 
diff --git a/utils/pdftops.1 b/utils/pdftops.1
index 45e8399..6c4ef61 100644
--- a/utils/pdftops.1
+++ b/utils/pdftops.1
@@ -1,5 +1,5 @@
 .\" Copyright 1996-2004 Glyph & Cog, LLC
-.TH pdftops 1 "22 January 2004"
+.TH pdftops 1 "31 July 2009"
 .SH NAME
 pdftops \- Portable Document Format (PDF) to PostScript converter
 (version 3.00)
@@ -120,6 +120,12 @@ are copied into the PostScript file.  This option disables that
 embedding.  No attempt is made to substitute for non-embedded CID
 TrueType fonts.
 .TP
+.B \-passfonts
+By default, references to non-embedded 8-bit fonts in the PDF file are
+substituted with the closest "Helvetica", "Times-Roman", or "Courier" font.
+This option passes references to non-embedded fonts
+through to the PostScript file.
+.TP
 .B \-preload
 preload images and forms
 .TP
diff --git a/utils/pdftops.cc b/utils/pdftops.cc
index 4670d22..69d5c32 100644
--- a/utils/pdftops.cc
+++ b/utils/pdftops.cc
@@ -19,6 +19,7 @@
 // Copyright (C) 2007-2008 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2009 Till Kamppeter <till.kamppeter at gmail.com>
 // Copyright (C) 2009 Sanjoy Mahajan <sanjoy at mit.edu>
+// Copyright (C) 2009 William Bader <williambader at hotmail.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -86,6 +87,7 @@ static GBool noEmbedT1Fonts = gFalse;
 static GBool noEmbedTTFonts = gFalse;
 static GBool noEmbedCIDPSFonts = gFalse;
 static GBool noEmbedCIDTTFonts = gFalse;
+static GBool noSubstFonts = gFalse;
 static GBool preload = gFalse;
 static char paperSize[15] = "";
 static int paperWidth = -1;
@@ -136,6 +138,8 @@ static const ArgDesc argDesc[] = {
    "don't embed CID PostScript fonts"},
   {"-noembcidtt", argFlag, &noEmbedCIDTTFonts,  0,
    "don't embed CID TrueType fonts"},
+  {"-passfonts",  argFlag,        &noSubstFonts,0,
+   "don't substitute missing fonts"},
   {"-preload",    argFlag,     &preload,        0,
    "preload images and forms"},
   {"-paper",      argString,   paperSize,       sizeof(paperSize),
@@ -269,6 +273,9 @@ int main(int argc, char *argv[]) {
   if (noEmbedCIDTTFonts) {
     globalParams->setPSEmbedCIDTrueType(!noEmbedCIDTTFonts);
   }
+  if (noSubstFonts) {
+    globalParams->setPSSubstFonts(!noSubstFonts);
+  }
   if (preload) {
     globalParams->setPSPreload(preload);
   }
commit bd68c90338cbf16f468e5db59722610300a629e1
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Aug 1 15:19:48 2009 +0200

    Forgot to add my copyright

diff --git a/poppler/GfxState.h b/poppler/GfxState.h
index 51a317d..411d0ef 100644
--- a/poppler/GfxState.h
+++ b/poppler/GfxState.h
@@ -17,6 +17,7 @@
 // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff at infidigm.net>
 // Copyright (C) 2006 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2009 Koji Otani <sho at bbr.jp>
+// Copyright (C) 2009 Albert Astals Cid <aacid at kde.org>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git


More information about the poppler mailing list