Commit af32d56a authored by Petr Gajdos's avatar Petr Gajdos Committed by Albert Astals Cid
Browse files

Add the possibility of forcing no hinting of fonts

parent 1a69d963
......@@ -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));
}
......
......@@ -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;
......
......@@ -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
......
......@@ -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() &&
......
......@@ -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;
......
......@@ -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
......
......@@ -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() {
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
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