cpp/poppler-page-renderer.cpp | 2 +- poppler/ArthurOutputDev.cc | 11 +++++++++-- poppler/ArthurOutputDev.h | 15 ++++++++++++++- poppler/SplashOutputDev.cc | 6 +++++- poppler/SplashOutputDev.h | 4 +++- qt4/src/poppler-private.h | 3 ++- qt4/src/poppler-qt4.h | 4 +++- splash/SplashFTFont.cc | 27 ++++++++++++++++++--------- splash/SplashFTFont.h | 2 ++ splash/SplashFTFontEngine.cc | 10 +++++++--- splash/SplashFTFontEngine.h | 6 ++++-- splash/SplashFontEngine.cc | 4 +++- splash/SplashFontEngine.h | 2 ++ 13 files changed, 73 insertions(+), 23 deletions(-)
New commits: commit 88812e716c1a0c87a504118d47eb4cc6f52962fa Author: Andreas Hartmetz <[email protected]> Date: Fri Jan 21 23:33:47 2011 +0000 Add Hinting API to ArthurOutputDev diff --git a/poppler/ArthurOutputDev.cc b/poppler/ArthurOutputDev.cc index 71faeb5..d065d9b 100644 --- a/poppler/ArthurOutputDev.cc +++ b/poppler/ArthurOutputDev.cc @@ -19,6 +19,7 @@ // Copyright (C) 2009 Carlos Garcia Campos <[email protected]> // Copyright (C) 2009 Petr Gajdos <[email protected]> // Copyright (C) 2010 Matthias Fauconneau <[email protected]> +// Copyright (C) 2011 Andreas Hartmetz <[email protected]> // // 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,7 +87,8 @@ private: //------------------------------------------------------------------------ ArthurOutputDev::ArthurOutputDev(QPainter *painter): - m_painter(painter) + m_painter(painter), + m_fontHinting(NoHinting) { m_currentBrush = QBrush(Qt::SolidPattern); m_fontEngine = 0; @@ -104,13 +106,18 @@ void ArthurOutputDev::startDoc(XRef *xrefA) { xref = xrefA; #ifdef HAVE_SPLASH delete m_fontEngine; + + const bool isHintingEnabled = m_fontHinting != NoHinting; + const bool isSlightHinting = m_fontHinting == SlightHinting; + m_fontEngine = new SplashFontEngine( #if HAVE_T1LIB_H globalParams->getEnableT1lib(), #endif #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H globalParams->getEnableFreeType(), - gFalse, + isHintingEnabled, + isSlightHinting, #endif m_painter->testRenderHint(QPainter::TextAntialiasing)); #endif diff --git a/poppler/ArthurOutputDev.h b/poppler/ArthurOutputDev.h index 3fa586b..fc00c71 100644 --- a/poppler/ArthurOutputDev.h +++ b/poppler/ArthurOutputDev.h @@ -16,7 +16,8 @@ // Copyright (C) 2005 Brad Hards <[email protected]> // Copyright (C) 2005 Albert Astals Cid <[email protected]> // Copyright (C) 2009 Carlos Garcia Campos <[email protected]> -// Copyright (C) 2010, 2010 Pino Toscano <[email protected]> +// Copyright (C) 2010 Pino Toscano <[email protected]> +// Copyright (C) 2011 Andreas Hartmetz <[email protected]> // // 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 @@ -51,6 +52,15 @@ struct SplashGlyphBitmap; class ArthurOutputDev: public OutputDev { public: + /** + * Describes how fonts are distorted (aka hinted) to fit the pixel grid. + * More hinting means sharper edges and less adherence to the true letter shapes. + */ + enum FontHinting { + NoHinting = 0, ///< Font shapes are left unchanged + SlightHinting, ///< Font shapes are distorted vertically only + FullHinting ///< Font shapes are distorted horizontally and vertically + }; // Constructor. ArthurOutputDev(QPainter *painter ); @@ -58,6 +68,8 @@ public: // Destructor. virtual ~ArthurOutputDev(); + void setFontHinting(FontHinting hinting) { m_fontHinting = hinting; } + //----- get info about output device // Does this device use upside-down coordinates? @@ -147,6 +159,7 @@ public: private: QPainter *m_painter; + FontHinting m_fontHinting; QFont m_currentFont; QPen m_currentPen; QBrush m_currentBrush; commit dc5ec4668bdfe3b6ba41f0a2e551bbc07f8839ba Author: Andreas Hartmetz <[email protected]> Date: Fri Jan 21 23:32:50 2011 +0000 support slight hinting in Splash backend diff --git a/cpp/poppler-page-renderer.cpp b/cpp/poppler-page-renderer.cpp index 47678b7..5e07954 100644 --- a/cpp/poppler-page-renderer.cpp +++ b/cpp/poppler-page-renderer.cpp @@ -174,7 +174,7 @@ image page_renderer::render_page(const page *p, const GBool text_AA = d->hints & text_antialiasing ? gTrue : gFalse; SplashOutputDev splashOutputDev(splashModeXBGR8, 4, gFalse, bgColor, gTrue, text_AA); splashOutputDev.setVectorAntialias(d->hints & antialiasing ? gTrue : gFalse); - splashOutputDev.setFreeTypeHinting(d->hints & text_hinting ? gTrue : gFalse); + splashOutputDev.setFreeTypeHinting(d->hints & text_hinting ? gTrue : gFalse, gFalse); splashOutputDev.startDoc(pdfdoc->getXRef()); pdfdoc->displayPageSlice(&splashOutputDev, pp->index + 1, xres, yres, int(rotate) * 90, diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index 0b3722a..c3ae695 100644 --- a/poppler/SplashOutputDev.cc +++ b/poppler/SplashOutputDev.cc @@ -27,6 +27,7 @@ // Copyright (C) 2010 Brian Cameron <[email protected]> // Copyright (C) 2010 PaweÅ Wiejacha <[email protected]> // Copyright (C) 2010 Christian Feuersänger <[email protected]> +// Copyright (C) 2011 Andreas Hartmetz <[email protected]> // // 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 @@ -964,6 +965,7 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA, globalParams->getVectorAntialias() && colorMode != splashModeMono1; enableFreeTypeHinting = gFalse; + enableSlightHinting = gFalse; setupScreenParams(72.0, 72.0); reverseVideo = reverseVideoA; if (paperColorA != NULL) { @@ -1074,6 +1076,7 @@ void SplashOutputDev::startDoc(XRef *xrefA) { #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H globalParams->getEnableFreeType(), enableFreeTypeHinting, + enableSlightHinting, #endif allowAntialias && globalParams->getAntialias() && @@ -3318,9 +3321,10 @@ void SplashOutputDev::setVectorAntialias(GBool vaa) { } #endif -void SplashOutputDev::setFreeTypeHinting(GBool enable) +void SplashOutputDev::setFreeTypeHinting(GBool enable, GBool enableSlightHintingA) { enableFreeTypeHinting = enable; + enableSlightHinting = enableSlightHintingA; } GBool SplashOutputDev::gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h index 570d036..47161c0 100644 --- a/poppler/SplashOutputDev.h +++ b/poppler/SplashOutputDev.h @@ -17,6 +17,7 @@ // Copyright (C) 2009, 2010 Thomas Freitag <[email protected]> // Copyright (C) 2009 Carlos Garcia Campos <[email protected]> // Copyright (C) 2010 Christian Feuersänger <[email protected]> +// Copyright (C) 2011 Andreas Hartmetz <[email protected]> // // 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 @@ -288,7 +289,7 @@ public: virtual void setVectorAntialias(GBool vaa); #endif - void setFreeTypeHinting(GBool enable); + void setFreeTypeHinting(GBool enable, GBool enableSlightHinting); private: @@ -320,6 +321,7 @@ private: GBool allowAntialias; GBool vectorAntialias; GBool enableFreeTypeHinting; + GBool enableSlightHinting; GBool reverseVideo; // reverse video mode SplashColor paperColor; // paper color SplashScreenParams screenParams; diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h index f148dbc..e3493fa 100644 --- a/qt4/src/poppler-private.h +++ b/qt4/src/poppler-private.h @@ -3,6 +3,7 @@ * Copyright (C) 2005, 2008, Brad Hards <[email protected]> * Copyright (C) 2006-2009 by Albert Astals Cid <[email protected]> * Copyright (C) 2007-2009 by Pino Toscano <[email protected]> + * Copyright (C) 2011 Andreas Hartmetz <[email protected]> * Inspired on code by * Copyright (C) 2004 by Albert Astals Cid <[email protected]> * Copyright (C) 2004 by Enrico Ros <[email protected]> @@ -139,7 +140,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->setFreeTypeHinting(m_hints & Document::TextHinting ? gTrue : gFalse, m_hints & Document::TextSlightHinting ? 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 576c53e..b43a3dd 100644 --- a/qt4/src/poppler-qt4.h +++ b/qt4/src/poppler-qt4.h @@ -7,6 +7,7 @@ * Copyright (C) 2009 Shawn Rutledge <[email protected]> * Copyright (C) 2010 Suzuki Toshiya <[email protected]> * Copyright (C) 2010 Matthias Fauconneau <[email protected]> + * Copyright (C) 2011 Andreas Hartmetz <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -800,7 +801,8 @@ delete it; enum RenderHint { Antialiasing = 0x00000001, ///< Antialiasing for graphics TextAntialiasing = 0x00000002, ///< Antialiasing for text - TextHinting = 0x00000004 ///< Hinting for text \since 0.12.1 + TextHinting = 0x00000004, ///< Hinting for text \since 0.12.1 + TextSlightHinting = 0x00000008 ///< Lighter hinting for text when combined with TextHinting \since 0.18 }; Q_DECLARE_FLAGS( RenderHints, RenderHint ) diff --git a/splash/SplashFTFont.cc b/splash/SplashFTFont.cc index 5e86311..a69da6e 100644 --- a/splash/SplashFTFont.cc +++ b/splash/SplashFTFont.cc @@ -15,6 +15,7 @@ // Copyright (C) 2006 Kristian Høgsberg <[email protected]> // Copyright (C) 2009 Petr Gajdos <[email protected]> // Copyright (C) 2010 Suzuki Toshiya <[email protected]> +// Copyright (C) 2011 Andreas Hartmetz <[email protected]> // // 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 @@ -57,7 +58,8 @@ 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), - enableFreeTypeHinting(fontFileA->engine->enableFreeTypeHinting) + enableFreeTypeHinting(fontFileA->engine->enableFreeTypeHinting), + enableSlightHinting(fontFileA->engine->enableSlightHinting) { FT_Face face; double div; @@ -169,12 +171,19 @@ 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) +static FT_Int32 getFTLoadFlags(GBool aa, GBool enableFreeTypeHinting, GBool enableSlightHinting) { - 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; + int ret = FT_LOAD_DEFAULT; + if (aa) + ret |= FT_LOAD_NO_BITMAP; + + if (enableFreeTypeHinting) { + if (enableSlightHinting) + ret |= FT_LOAD_TARGET_LIGHT; + } else { + ret |= FT_LOAD_NO_HINTING; + } + return ret; } GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac, @@ -201,7 +210,7 @@ GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac, gid = (FT_UInt)c; } - if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting))) { + if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting, enableSlightHinting))) { return gFalse; } @@ -284,7 +293,7 @@ double SplashFTFont::getGlyphAdvance(int c) return -1; } - if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting))) { + if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting, enableSlightHinting))) { return -1; } @@ -332,7 +341,7 @@ SplashPath *SplashFTFont::getGlyphPath(int c) { // skip the TrueType notdef glyph return NULL; } - if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting))) { + if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting, enableSlightHinting))) { return NULL; } if (FT_Get_Glyph(slot, &glyph)) { diff --git a/splash/SplashFTFont.h b/splash/SplashFTFont.h index cf82504..8311907 100644 --- a/splash/SplashFTFont.h +++ b/splash/SplashFTFont.h @@ -13,6 +13,7 @@ // // Copyright (C) 2007-2009 Albert Astals Cid <[email protected]> // Copyright (C) 2009 Petr Gajdos <[email protected]> +// Copyright (C) 2011 Andreas Hartmetz <[email protected]> // // 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 @@ -69,6 +70,7 @@ private: SplashCoord textScale; double size; GBool enableFreeTypeHinting; + GBool enableSlightHinting; }; #endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H diff --git a/splash/SplashFTFontEngine.cc b/splash/SplashFTFontEngine.cc index 7cf4f06..61a92cc 100644 --- a/splash/SplashFTFontEngine.cc +++ b/splash/SplashFTFontEngine.cc @@ -14,6 +14,7 @@ // Copyright (C) 2006 Takashi Iwai <[email protected]> // Copyright (C) 2009 Albert Astals Cid <[email protected]> // Copyright (C) 2009 Petr Gajdos <[email protected]> +// Copyright (C) 2011 Andreas Hartmetz <[email protected]> // // 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 @@ -58,11 +59,13 @@ static void fileWrite(void *stream, char *data, int len) { // SplashFTFontEngine //------------------------------------------------------------------------ -SplashFTFontEngine::SplashFTFontEngine(GBool aaA, GBool enableFreeTypeHintingA, FT_Library libA) { +SplashFTFontEngine::SplashFTFontEngine(GBool aaA, GBool enableFreeTypeHintingA, + GBool enableSlightHintingA, FT_Library libA) { FT_Int major, minor, patch; aa = aaA; enableFreeTypeHinting = enableFreeTypeHintingA; + enableSlightHinting = enableSlightHintingA; lib = libA; // as of FT 2.1.8, CID fonts are indexed by CID instead of GID @@ -71,13 +74,14 @@ SplashFTFontEngine::SplashFTFontEngine(GBool aaA, GBool enableFreeTypeHintingA, (major == 2 && (minor > 1 || (minor == 1 && patch > 7))); } -SplashFTFontEngine *SplashFTFontEngine::init(GBool aaA, GBool enableFreeTypeHintingA) { +SplashFTFontEngine *SplashFTFontEngine::init(GBool aaA, GBool enableFreeTypeHintingA, + GBool enableSlightHintingA) { FT_Library libA; if (FT_Init_FreeType(&libA)) { return NULL; } - return new SplashFTFontEngine(aaA, enableFreeTypeHintingA, libA); + return new SplashFTFontEngine(aaA, enableFreeTypeHintingA, enableSlightHintingA, libA); } SplashFTFontEngine::~SplashFTFontEngine() { diff --git a/splash/SplashFTFontEngine.h b/splash/SplashFTFontEngine.h index 5acb415..42207fb 100644 --- a/splash/SplashFTFontEngine.h +++ b/splash/SplashFTFontEngine.h @@ -14,6 +14,7 @@ // Copyright (C) 2006 Takashi Iwai <[email protected]> // Copyright (C) 2009 Petr Gajdos <[email protected]> // Copyright (C) 2009 Albert Astals Cid <[email protected]> +// Copyright (C) 2011 Andreas Hartmetz <[email protected]> // // 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 @@ -44,7 +45,7 @@ class SplashFontSrc; class SplashFTFontEngine { public: - static SplashFTFontEngine *init(GBool aaA, GBool enableFreeTypeHintingA); + static SplashFTFontEngine *init(GBool aaA, GBool enableFreeTypeHintingA, GBool enableSlightHinting); ~SplashFTFontEngine(); @@ -59,10 +60,11 @@ public: private: - SplashFTFontEngine(GBool aaA, GBool enableFreeTypeHintingA, FT_Library libA); + SplashFTFontEngine(GBool aaA, GBool enableFreeTypeHintingA, GBool enableSlightHintingA, FT_Library libA); GBool aa; GBool enableFreeTypeHinting; + GBool enableSlightHinting; FT_Library lib; GBool useCIDs; diff --git a/splash/SplashFontEngine.cc b/splash/SplashFontEngine.cc index 3c96bfb..5fe8aeb 100644 --- a/splash/SplashFontEngine.cc +++ b/splash/SplashFontEngine.cc @@ -15,6 +15,7 @@ // Copyright (C) 2009 Petr Gajdos <[email protected]> // Copyright (C) 2009 Kovid Goyal <[email protected]> // Copyright (C) 2009 Albert Astals Cid <[email protected]> +// Copyright (C) 2011 Andreas Hartmetz <[email protected]> // // 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 @@ -69,6 +70,7 @@ SplashFontEngine::SplashFontEngine( #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H GBool enableFreeType, GBool enableFreeTypeHinting, + GBool enableSlightHinting, #endif GBool aa) { int i; @@ -86,7 +88,7 @@ SplashFontEngine::SplashFontEngine( #endif #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H if (enableFreeType) { - ftEngine = SplashFTFontEngine::init(aa, enableFreeTypeHinting); + ftEngine = SplashFTFontEngine::init(aa, enableFreeTypeHinting, enableSlightHinting); } else { ftEngine = NULL; } diff --git a/splash/SplashFontEngine.h b/splash/SplashFontEngine.h index a9d51f0..bf900de 100644 --- a/splash/SplashFontEngine.h +++ b/splash/SplashFontEngine.h @@ -14,6 +14,7 @@ // Copyright (C) 2006 Takashi Iwai <[email protected]> // Copyright (C) 2009 Petr Gajdos <[email protected]> // Copyright (C) 2009 Albert Astals Cid <[email protected]> +// Copyright (C) 2011 Andreas Hartmetz <[email protected]> // // 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 @@ -57,6 +58,7 @@ public: #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H GBool enableFreeType, GBool enableFreeTypeHinting, + GBool enableSlightHinting, #endif GBool aa);
_______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
