Commit 48525284 authored by Albert Astals Cid's avatar Albert Astals Cid

rework how hinting is used in the splash backend

Basically we default to no hinting now with the possibility to enable it
parent 8194c156
......@@ -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));
}
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
}
......@@ -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;
......
......@@ -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)) {
......
......@@ -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@kde.org>
// Copyright (C) 2007-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
......@@ -68,7 +68,7 @@ private:
FT_Matrix textMatrix;
SplashCoord textScale;
double size;
GBool noah;
GBool enableFreeTypeHinting;
};
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
......
......@@ -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() {
......
......@@ -13,6 +13,7 @@
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com>
// Copyright (C) 2009 Albert Astals Cid <aacid@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;
......
......@@ -14,6 +14,7 @@
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com>
// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
// Copyright (C) 2009 Albert Astals Cid <aacid@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;
}
......
......@@ -13,6 +13,7 @@
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com>
// Copyright (C) 2009 Albert Astals Cid <aacid@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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment