[poppler] 2 commits - poppler/ArthurOutputDev.cc poppler/GlobalParams.cc poppler/GlobalParams.h poppler/SplashOutputDev.cc poppler/SplashOutputDev.h qt4/src splash/SplashFontEngine.cc splash/SplashFontEngine.h splash/SplashFTFont.cc splash/SplashFTFontEngine.cc splash/SplashFTFontEngine.h splash/SplashFTFont.h

Albert Astals Cid aacid at kemper.freedesktop.org
Mon Oct 5 15:46:13 PDT 2009


 poppler/ArthurOutputDev.cc   |    2 -
 poppler/GlobalParams.cc      |   19 ------------
 poppler/GlobalParams.h       |    3 --
 poppler/SplashOutputDev.cc   |    8 ++++-
 poppler/SplashOutputDev.h    |    3 ++
 qt4/src/poppler-document.cc  |    2 -
 qt4/src/poppler-private.h    |    1 
 qt4/src/poppler-qt4.h        |    3 +-
 splash/SplashFTFont.cc       |   64 +++++++++----------------------------------
 splash/SplashFTFont.h        |    4 +-
 splash/SplashFTFontEngine.cc |    8 ++---
 splash/SplashFTFontEngine.h  |    7 ++--
 splash/SplashFontEngine.cc   |    5 ++-
 splash/SplashFontEngine.h    |    3 +-
 14 files changed, 44 insertions(+), 88 deletions(-)

New commits:
commit fef89acebf5312324c104fb52e629563fbc2de76
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Oct 6 00:42:52 2009 +0200

    Add the possibility of enabling hinting

diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
index 1e4715e..c2563f4 100644
--- a/qt4/src/poppler-document.cc
+++ b/qt4/src/poppler-document.cc
@@ -513,7 +513,7 @@ namespace Poppler {
 
         // the only way to set antialiasing for Splash is on creation
         if ( m_doc->m_backend == Document::SplashBackend &&
-             ( hint & ( Document::Antialiasing || Document::TextAntialiasing ) ) )
+             ( hint & ( Document::Antialiasing || Document::TextAntialiasing || Document::TextHinting ) ) )
         {
             delete m_doc->m_outputDev;
             m_doc->m_outputDev = NULL;
diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h
index acf3124..2bd7a81 100644
--- a/qt4/src/poppler-private.h
+++ b/qt4/src/poppler-private.h
@@ -139,6 +139,7 @@ namespace Poppler {
 			GBool AA = m_hints & Document::TextAntialiasing ? gTrue : gFalse;
 			SplashOutputDev * splashOutputDev = new SplashOutputDev(splashModeXBGR8, 4, gFalse, bgColor, gTrue, AA);
 			splashOutputDev->setVectorAntialias(m_hints & Document::Antialiasing ? gTrue : gFalse);
+			splashOutputDev->setFreeTypeHinting(m_hints & Document::TextHinting ? gTrue : gFalse);
 			splashOutputDev->startDoc(doc->getXRef());
 			m_outputDev = splashOutputDev;
 #endif
diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index e174e0e..fcce658 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -679,7 +679,8 @@ delete it;
 	*/
 	enum RenderHint {
 	    Antialiasing = 0x00000001,      ///< Antialiasing for graphics
-	    TextAntialiasing = 0x00000002   ///< Antialiasing for text
+	    TextAntialiasing = 0x00000002,  ///< Antialiasing for text
+	    TextHinting = 0x00000004        ///< Hinting for text \since 0.12.1
 	};
 	Q_DECLARE_FLAGS( RenderHints, RenderHint )
 
commit 485252844b5e0964ee724b74e2a7ba2b820b259e
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Oct 6 00:41:57 2009 +0200

    rework how hinting is used in the splash backend
    
    Basically we default to no hinting now with the possibility to enable it

diff --git a/poppler/ArthurOutputDev.cc b/poppler/ArthurOutputDev.cc
index ea00f59..fbc8b01 100644
--- a/poppler/ArthurOutputDev.cc
+++ b/poppler/ArthurOutputDev.cc
@@ -106,7 +106,7 @@ void ArthurOutputDev::startDoc(XRef *xrefA) {
 #endif
 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
   globalParams->getEnableFreeType(),
-  globalParams->getForceNoFTAutoHinting(),
+  gFalse,
 #endif
   m_painter->testRenderHint(QPainter::TextAntialiasing));
 }
diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 0155132..2813b98 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -622,7 +622,6 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir)
   enableFreeType = gTrue;
   antialias = gTrue;
   vectorAntialias = gTrue;
-  forceNoFTAutoHinting = gFalse;
   strokeAdjust = gTrue;
   screenType = screenUnset;
   screenSize = -1;
@@ -1408,15 +1407,6 @@ GBool GlobalParams::getVectorAntialias() {
   return f;
 }
 
-GBool GlobalParams::getForceNoFTAutoHinting() {
-  GBool f;
-
-  lockGlobalParams;
-  f = forceNoFTAutoHinting;
-  unlockGlobalParams;
-  return f;
-}
-
 GBool GlobalParams::getStrokeAdjust() {
   GBool f;
 
@@ -1749,15 +1739,6 @@ GBool GlobalParams::setVectorAntialias(char *s) {
   return ok;
 }
 
-GBool GlobalParams::setForceNoFTAutoHinting(char *s) {
-  GBool ok;
-
-  lockGlobalParams;
-  ok = parseYesNo2(s, &forceNoFTAutoHinting);
-  unlockGlobalParams;
-  return ok;
-}
-
 void GlobalParams::setStrokeAdjust(GBool adjust)
 {
   lockGlobalParams;
diff --git a/poppler/GlobalParams.h b/poppler/GlobalParams.h
index cb2aa85..b422e0c 100644
--- a/poppler/GlobalParams.h
+++ b/poppler/GlobalParams.h
@@ -206,7 +206,6 @@ public:
   GBool getEnableFreeType();
   GBool getAntialias();
   GBool getVectorAntialias();
-  GBool getForceNoFTAutoHinting();
   GBool getStrokeAdjust();
   ScreenType getScreenType();
   int getScreenSize();
@@ -251,7 +250,6 @@ public:
   GBool setEnableFreeType(char *s);
   GBool setAntialias(char *s);
   GBool setVectorAntialias(char *s);
-  GBool setForceNoFTAutoHinting(char *s);
   void setStrokeAdjust(GBool strokeAdjust);
   void setScreenType(ScreenType st);
   void setScreenSize(int size);
@@ -336,7 +334,6 @@ private:
   GBool enableFreeType;		// FreeType enable flag
   GBool antialias;		// anti-aliasing enable flag
   GBool vectorAntialias;	// vector anti-aliasing enable flag
-  GBool forceNoFTAutoHinting;  // force to disable FT autohinting
   GBool strokeAdjust;		// stroke adjustment enable flag
   ScreenType screenType;	// halftone screen type
   int screenSize;		// screen matrix size
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 139760b..4d51a42 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -829,6 +829,7 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA,
   vectorAntialias = allowAntialias &&
 		      globalParams->getVectorAntialias() &&
 		      colorMode != splashModeMono1;
+  enableFreeTypeHinting = gFalse;
   setupScreenParams(72.0, 72.0);
   reverseVideo = reverseVideoA;
   if (paperColorA != NULL) {
@@ -938,7 +939,7 @@ void SplashOutputDev::startDoc(XRef *xrefA) {
 #endif
 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
 				    globalParams->getEnableFreeType(),
-				    globalParams->getForceNoFTAutoHinting(),
+				    enableFreeTypeHinting,
 #endif
 				    allowAntialias &&
 				      globalParams->getAntialias() &&
@@ -3106,3 +3107,8 @@ void SplashOutputDev::setVectorAntialias(GBool vaa) {
   splash->setVectorAntialias(vaa);
 }
 #endif
+
+void SplashOutputDev::setFreeTypeHinting(GBool enable)
+{
+  enableFreeTypeHinting = enable;
+}
diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h
index eec6516..df33850 100644
--- a/poppler/SplashOutputDev.h
+++ b/poppler/SplashOutputDev.h
@@ -223,6 +223,8 @@ public:
   virtual void setVectorAntialias(GBool vaa);
 #endif
 
+  void setFreeTypeHinting(GBool enable);
+
 private:
 
   void setupScreenParams(double hDPI, double vDPI);
@@ -253,6 +255,7 @@ private:
   GBool bitmapTopDown;
   GBool allowAntialias;
   GBool vectorAntialias;
+  GBool enableFreeTypeHinting;
   GBool reverseVideo;		// reverse video mode
   SplashColor paperColor;	// paper color
   SplashScreenParams screenParams;
diff --git a/splash/SplashFTFont.cc b/splash/SplashFTFont.cc
index 4c62dc6..d4675f7 100644
--- a/splash/SplashFTFont.cc
+++ b/splash/SplashFTFont.cc
@@ -56,7 +56,7 @@ static int glyphPathCubicTo(const FT_Vector *ctrl1, const FT_Vector *ctrl2,
 SplashFTFont::SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA,
 			   SplashCoord *textMatA):
   SplashFont(fontFileA, matA, textMatA, fontFileA->engine->aa), 
-  noah(fontFileA->engine->noah)
+  enableFreeTypeHinting(fontFileA->engine->enableFreeTypeHinting)
 {
   FT_Face face;
   double div;
@@ -168,6 +168,14 @@ GBool SplashFTFont::getGlyph(int c, int xFrac, int yFrac,
   return SplashFont::getGlyph(c, xFrac, 0, bitmap, x0, y0, clip, clipRes);
 }
 
+static FT_Int32 getFTLoadFlags(GBool aa, GBool enableFreeTypeHinting)
+{
+  if (aa && enableFreeTypeHinting) return FT_LOAD_NO_BITMAP;
+  else if (aa && !enableFreeTypeHinting) return FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP;
+  else if (!aa && enableFreeTypeHinting) return FT_LOAD_DEFAULT;
+  else return FT_LOAD_NO_HINTING;
+}
+
 GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac,
 			      SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) {
   SplashFTFontFile *ff;
@@ -196,30 +204,8 @@ GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac,
     return gFalse;
   }
 
-  if (noah) {
-    if (FT_Load_Glyph(ff->face, gid,
-                      aa ? FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP
-                         : FT_LOAD_DEFAULT)) {
-      return gFalse;
-    }
-  } else {
-    // if we have the FT2 bytecode interpreter, autohinting won't be used
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
-    if (FT_Load_Glyph(ff->face, gid,
-                      aa ? FT_LOAD_NO_BITMAP : FT_LOAD_DEFAULT)) {
-      return gFalse;
-    }
-#else
-    // FT2's autohinting doesn't always work very well (especially with
-    // font subsets), so turn it off if anti-aliasing is enabled; if
-    // anti-aliasing is disabled, this seems to be a tossup - some fonts
-    // look better with hinting, some without, so leave hinting on
-    if (FT_Load_Glyph(ff->face, gid,
-		      aa ? FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP
-                         : FT_LOAD_DEFAULT)) {
-      return gFalse;
-    }
-#endif
+  if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting))) {
+    return gFalse;
   }
 
   FT_Glyph_Metrics *glyphMetrics = &(ff->face->glyph->metrics);
@@ -296,30 +282,8 @@ double SplashFTFont::getGlyphAdvance(int c)
     return -1;
   }
 
-  if (noah) {
-    if (FT_Load_Glyph(ff->face, gid,
-                      aa ? FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP
-                         : FT_LOAD_DEFAULT)) {
-      return -1;
-    }
-  } else {
-    // if we have the FT2 bytecode interpreter, autohinting won't be used
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
-    if (FT_Load_Glyph(ff->face, gid,
-		      aa ? FT_LOAD_NO_BITMAP : FT_LOAD_DEFAULT)) {
-      return -1;
-    }
-#else
-    // FT2's autohinting doesn't always work very well (especially with
-    // font subsets), so turn it off if anti-aliasing is enabled; if
-    // anti-aliasing is disabled, this seems to be a tossup - some fonts
-    // look better with hinting, some without, so leave hinting on
-    if (FT_Load_Glyph(ff->face, gid,
-		      aa ? FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP
-                         : FT_LOAD_DEFAULT)) {
-      return -1;
-    }
-#endif
+  if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting))) {
+    return -1;
   }
 
   // 64.0 is 1 in 26.6 format
@@ -366,7 +330,7 @@ SplashPath *SplashFTFont::getGlyphPath(int c) {
     // skip the TrueType notdef glyph
     return NULL;
   }
-  if (FT_Load_Glyph(ff->face, gid, FT_LOAD_NO_BITMAP)) {
+  if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting))) {
     return NULL;
   }
   if (FT_Get_Glyph(slot, &glyph)) {
diff --git a/splash/SplashFTFont.h b/splash/SplashFTFont.h
index 1881d8e..cf82504 100644
--- a/splash/SplashFTFont.h
+++ b/splash/SplashFTFont.h
@@ -11,7 +11,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2007-2008 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2007-2009 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2009 Petr Gajdos <pgajdos at novell.com>
 //
 // To see a description of the changes please see the Changelog file that
@@ -68,7 +68,7 @@ private:
   FT_Matrix textMatrix;
   SplashCoord textScale;
   double size;
-  GBool noah;
+  GBool enableFreeTypeHinting;
 };
 
 #endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
diff --git a/splash/SplashFTFontEngine.cc b/splash/SplashFTFontEngine.cc
index e7e3197..7cf4f06 100644
--- a/splash/SplashFTFontEngine.cc
+++ b/splash/SplashFTFontEngine.cc
@@ -58,11 +58,11 @@ static void fileWrite(void *stream, char *data, int len) {
 // SplashFTFontEngine
 //------------------------------------------------------------------------
 
-SplashFTFontEngine::SplashFTFontEngine(GBool aaA, GBool noahA, FT_Library libA) {
+SplashFTFontEngine::SplashFTFontEngine(GBool aaA, GBool enableFreeTypeHintingA, FT_Library libA) {
   FT_Int major, minor, patch;
 
   aa = aaA;
-  noah = noahA;
+  enableFreeTypeHinting = enableFreeTypeHintingA;
   lib = libA;
 
   // as of FT 2.1.8, CID fonts are indexed by CID instead of GID
@@ -71,13 +71,13 @@ SplashFTFontEngine::SplashFTFontEngine(GBool aaA, GBool noahA, FT_Library libA)
             (major == 2 && (minor > 1 || (minor == 1 && patch > 7)));
 }
 
-SplashFTFontEngine *SplashFTFontEngine::init(GBool aaA, GBool noahA) {
+SplashFTFontEngine *SplashFTFontEngine::init(GBool aaA, GBool enableFreeTypeHintingA) {
   FT_Library libA;
 
   if (FT_Init_FreeType(&libA)) {
     return NULL;
   }
-  return new SplashFTFontEngine(aaA, noahA, libA);
+  return new SplashFTFontEngine(aaA, enableFreeTypeHintingA, libA);
 }
 
 SplashFTFontEngine::~SplashFTFontEngine() {
diff --git a/splash/SplashFTFontEngine.h b/splash/SplashFTFontEngine.h
index 2d4699c..5acb415 100644
--- a/splash/SplashFTFontEngine.h
+++ b/splash/SplashFTFontEngine.h
@@ -13,6 +13,7 @@
 //
 // Copyright (C) 2006 Takashi Iwai <tiwai at suse.de>
 // Copyright (C) 2009 Petr Gajdos <pgajdos at novell.com>
+// 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
@@ -43,7 +44,7 @@ class SplashFontSrc;
 class SplashFTFontEngine {
 public:
 
-  static SplashFTFontEngine *init(GBool aaA, GBool noahA);
+  static SplashFTFontEngine *init(GBool aaA, GBool enableFreeTypeHintingA);
 
   ~SplashFTFontEngine();
 
@@ -58,10 +59,10 @@ public:
 
 private:
 
-  SplashFTFontEngine(GBool aaA, GBool noahA, FT_Library libA);
+  SplashFTFontEngine(GBool aaA, GBool enableFreeTypeHintingA, FT_Library libA);
 
   GBool aa;
-  GBool noah;
+  GBool enableFreeTypeHinting;
   FT_Library lib;
   GBool useCIDs;
 
diff --git a/splash/SplashFontEngine.cc b/splash/SplashFontEngine.cc
index fb1a950..3c96bfb 100644
--- a/splash/SplashFontEngine.cc
+++ b/splash/SplashFontEngine.cc
@@ -14,6 +14,7 @@
 // Copyright (C) 2006 Takashi Iwai <tiwai at suse.de>
 // Copyright (C) 2009 Petr Gajdos <pgajdos at novell.com>
 // Copyright (C) 2009 Kovid Goyal <kovid at kovidgoyal.net>
+// 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
@@ -67,7 +68,7 @@ SplashFontEngine::SplashFontEngine(
 #endif
 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
 				   GBool enableFreeType,
-				   GBool noah,
+				   GBool enableFreeTypeHinting,
 #endif
 				   GBool aa) {
   int i;
@@ -85,7 +86,7 @@ SplashFontEngine::SplashFontEngine(
 #endif
 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
   if (enableFreeType) {
-    ftEngine = SplashFTFontEngine::init(aa, noah);
+    ftEngine = SplashFTFontEngine::init(aa, enableFreeTypeHinting);
   } else {
     ftEngine = NULL;
   }
diff --git a/splash/SplashFontEngine.h b/splash/SplashFontEngine.h
index 009de60..a9d51f0 100644
--- a/splash/SplashFontEngine.h
+++ b/splash/SplashFontEngine.h
@@ -13,6 +13,7 @@
 //
 // Copyright (C) 2006 Takashi Iwai <tiwai at suse.de>
 // Copyright (C) 2009 Petr Gajdos <pgajdos at novell.com>
+// 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
@@ -55,7 +56,7 @@ public:
 #endif
 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
 		   GBool enableFreeType,
-		   GBool noah,
+		   GBool enableFreeTypeHinting,
 #endif
 		   GBool aa);
 


More information about the poppler mailing list