summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Gajdos <pgajdos@novell.com>2009-05-21 00:37:18 +0200
committerAlbert Astals Cid <aacid@kde.org>2009-05-21 00:37:18 +0200
commitaf32d56af779edcc539b680e634755941d1bf45c (patch)
tree3cae467cb263ee7e8df8f235bbc58af71ba4ead0
parent1a69d9638214943b3c2278f570694d9722a5de15 (diff)
Add the possibility of forcing no hinting of fonts
-rw-r--r--poppler/ArthurOutputDev.cc2
-rw-r--r--poppler/GlobalParams.cc20
-rw-r--r--poppler/GlobalParams.h4
-rw-r--r--poppler/SplashOutputDev.cc2
-rw-r--r--splash/SplashFTFont.cc76
-rw-r--r--splash/SplashFTFont.h2
-rw-r--r--splash/SplashFTFontEngine.cc8
-rw-r--r--splash/SplashFTFontEngine.h6
-rw-r--r--splash/SplashFontEngine.cc4
-rw-r--r--splash/SplashFontEngine.h2
10 files changed, 91 insertions, 35 deletions
diff --git a/poppler/ArthurOutputDev.cc b/poppler/ArthurOutputDev.cc
index 22660c63..306fbfac 100644
--- a/poppler/ArthurOutputDev.cc
+++ b/poppler/ArthurOutputDev.cc
@@ -17,6 +17,7 @@
// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2008 Pino Toscano <pino@kde.org>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
+// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.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
@@ -105,6 +106,7 @@ void ArthurOutputDev::startDoc(XRef *xrefA) {
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
globalParams->getEnableFreeType(),
+ globalParams->getForceNoFTAutoHinting(),
#endif
m_painter->testRenderHint(QPainter::TextAntialiasing));
}
diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 9c42f361..13a54d22 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -19,6 +19,7 @@
// Copyright (C) 2006 Ed Catmur <ed@catmur.co.uk>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2007, 2009 Jonathan Kew <jonathan_kew@sil.org>
+// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.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
@@ -618,6 +619,7 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir)
enableFreeType = gTrue;
antialias = gTrue;
vectorAntialias = gTrue;
+ forceNoFTAutoHinting = gFalse;
strokeAdjust = gTrue;
screenType = screenUnset;
screenSize = -1;
@@ -1393,6 +1395,15 @@ GBool GlobalParams::getVectorAntialias() {
return f;
}
+GBool GlobalParams::getForceNoFTAutoHinting() {
+ GBool f;
+
+ lockGlobalParams;
+ f = forceNoFTAutoHinting;
+ unlockGlobalParams;
+ return f;
+}
+
GBool GlobalParams::getStrokeAdjust() {
GBool f;
@@ -1719,6 +1730,15 @@ 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 a0e4ff07..ebc16fb2 100644
--- a/poppler/GlobalParams.h
+++ b/poppler/GlobalParams.h
@@ -19,6 +19,7 @@
// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2009 Jonathan Kew <jonathan_kew@sil.org>
+// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.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
@@ -202,6 +203,7 @@ public:
GBool getEnableFreeType();
GBool getAntialias();
GBool getVectorAntialias();
+ GBool getForceNoFTAutoHinting();
GBool getStrokeAdjust();
ScreenType getScreenType();
int getScreenSize();
@@ -245,6 +247,7 @@ 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);
@@ -327,6 +330,7 @@ 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 dc4661a9..ca446826 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -19,6 +19,7 @@
// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2006 Scott Turner <scotty1024@mac.com>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp>
+// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.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
@@ -708,6 +709,7 @@ void SplashOutputDev::startDoc(XRef *xrefA) {
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
globalParams->getEnableFreeType(),
+ globalParams->getForceNoFTAutoHinting(),
#endif
allowAntialias &&
globalParams->getAntialias() &&
diff --git a/splash/SplashFTFont.cc b/splash/SplashFTFont.cc
index 7d5e3084..4c62dc68 100644
--- a/splash/SplashFTFont.cc
+++ b/splash/SplashFTFont.cc
@@ -13,6 +13,7 @@
//
// Copyright (C) 2005, 2007-2009 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006 Kristian Høgsberg <krh@bitplanet.net>
+// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.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
@@ -54,7 +55,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)
+ SplashFont(fontFileA, matA, textMatA, fontFileA->engine->aa),
+ noah(fontFileA->engine->noah)
{
FT_Face face;
double div;
@@ -194,23 +196,31 @@ GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac,
return gFalse;
}
- // if we have the FT2 bytecode interpreter, autohinting won't be used
+ 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;
- }
+ 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;
- }
+ // 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
+ }
FT_Glyph_Metrics *glyphMetrics = &(ff->face->glyph->metrics);
// prelimirary values from FT_Glyph_Metrics
@@ -286,23 +296,31 @@ double SplashFTFont::getGlyphAdvance(int c)
return -1;
}
- // if we have the FT2 bytecode interpreter, autohinting won't be used
+ 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;
- }
+ 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;
- }
+ // 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
+ }
// 64.0 is 1 in 26.6 format
return ff->face->glyph->metrics.horiAdvance / 64.0 / size;
diff --git a/splash/SplashFTFont.h b/splash/SplashFTFont.h
index 804d89f5..1881d8eb 100644
--- a/splash/SplashFTFont.h
+++ b/splash/SplashFTFont.h
@@ -12,6 +12,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2007-2008 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.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
@@ -67,6 +68,7 @@ private:
FT_Matrix textMatrix;
SplashCoord textScale;
double size;
+ GBool noah;
};
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
diff --git a/splash/SplashFTFontEngine.cc b/splash/SplashFTFontEngine.cc
index 2296f5dd..e7e3197e 100644
--- a/splash/SplashFTFontEngine.cc
+++ b/splash/SplashFTFontEngine.cc
@@ -13,6 +13,7 @@
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.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
@@ -57,10 +58,11 @@ static void fileWrite(void *stream, char *data, int len) {
// SplashFTFontEngine
//------------------------------------------------------------------------
-SplashFTFontEngine::SplashFTFontEngine(GBool aaA, FT_Library libA) {
+SplashFTFontEngine::SplashFTFontEngine(GBool aaA, GBool noahA, FT_Library libA) {
FT_Int major, minor, patch;
aa = aaA;
+ noah = noahA;
lib = libA;
// as of FT 2.1.8, CID fonts are indexed by CID instead of GID
@@ -69,13 +71,13 @@ SplashFTFontEngine::SplashFTFontEngine(GBool aaA, FT_Library libA) {
(major == 2 && (minor > 1 || (minor == 1 && patch > 7)));
}
-SplashFTFontEngine *SplashFTFontEngine::init(GBool aaA) {
+SplashFTFontEngine *SplashFTFontEngine::init(GBool aaA, GBool noahA) {
FT_Library libA;
if (FT_Init_FreeType(&libA)) {
return NULL;
}
- return new SplashFTFontEngine(aaA, libA);
+ return new SplashFTFontEngine(aaA, noahA, libA);
}
SplashFTFontEngine::~SplashFTFontEngine() {
diff --git a/splash/SplashFTFontEngine.h b/splash/SplashFTFontEngine.h
index 5bfe14a0..2d4699c4 100644
--- a/splash/SplashFTFontEngine.h
+++ b/splash/SplashFTFontEngine.h
@@ -12,6 +12,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
+// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.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
@@ -42,7 +43,7 @@ class SplashFontSrc;
class SplashFTFontEngine {
public:
- static SplashFTFontEngine *init(GBool aaA);
+ static SplashFTFontEngine *init(GBool aaA, GBool noahA);
~SplashFTFontEngine();
@@ -57,9 +58,10 @@ public:
private:
- SplashFTFontEngine(GBool aaA, FT_Library libA);
+ SplashFTFontEngine(GBool aaA, GBool noahA, FT_Library libA);
GBool aa;
+ GBool noah;
FT_Library lib;
GBool useCIDs;
diff --git a/splash/SplashFontEngine.cc b/splash/SplashFontEngine.cc
index 74872242..b089c885 100644
--- a/splash/SplashFontEngine.cc
+++ b/splash/SplashFontEngine.cc
@@ -12,6 +12,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
+// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.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
@@ -65,6 +66,7 @@ SplashFontEngine::SplashFontEngine(
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
GBool enableFreeType,
+ GBool noah,
#endif
GBool aa) {
int i;
@@ -82,7 +84,7 @@ SplashFontEngine::SplashFontEngine(
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
if (enableFreeType) {
- ftEngine = SplashFTFontEngine::init(aa);
+ ftEngine = SplashFTFontEngine::init(aa, noah);
} else {
ftEngine = NULL;
}
diff --git a/splash/SplashFontEngine.h b/splash/SplashFontEngine.h
index a28813dc..009de60a 100644
--- a/splash/SplashFontEngine.h
+++ b/splash/SplashFontEngine.h
@@ -12,6 +12,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
+// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.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
@@ -54,6 +55,7 @@ public:
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
GBool enableFreeType,
+ GBool noah,
#endif
GBool aa);