diff options
author | Tor Andersson <tor@ghostscript.com> | 2011-02-23 14:29:22 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2011-02-23 14:29:22 +0000 |
commit | 448fcbab4658f24b6067d82162b88c0631567387 (patch) | |
tree | 4cc95dd532cbf90d8e91998a4930318a8b1df8ea /fitz | |
parent | c889fcd06f1256571342368d40d375e44045dcd3 (diff) | |
download | mupdf-448fcbab4658f24b6067d82162b88c0631567387.tar.xz |
Revert to using fthint since we cannot rely on FreeType's trickyness detection on some subset fonts.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/fitz.h | 1 | ||||
-rw-r--r-- | fitz/res_font.c | 58 |
2 files changed, 36 insertions, 23 deletions
diff --git a/fitz/fitz.h b/fitz/fitz.h index d8b1e401..685a75f3 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -681,6 +681,7 @@ struct fz_font_s void *ftface; /* has an FT_Face if used */ int ftsubstitute; /* ... substitute metrics */ + int fthint; /* ... force hinting for DynaLab fonts */ /* origin of font data */ char *ftfile; diff --git a/fitz/res_font.c b/fitz/res_font.c index 4efdd0e4..1df8b2e6 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -17,6 +17,7 @@ fz_newfont(void) font->ftface = nil; font->ftsubstitute = 0; + font->fthint = 0; font->ftfile = nil; font->ftdata = nil; @@ -286,32 +287,43 @@ fz_renderftglyph(fz_font *font, int gid, fz_matrix trm) fz_warn("freetype setting character size: %s", ft_errorstring(fterr)); FT_Set_Transform(face, &m, &v); + if (font->fthint) + { + /* + Enable hinting, but keep the huge char size so that + it is hinted for a character. This will in effect nullify + the effect of grid fitting. This form of hinting should + only be used for DynaLab and similar tricky TrueType fonts, + so that we get the correct outline shape. + */ #ifdef GRIDFIT - /* If you really want grid fitting, enable this code. */ - float scale = fz_matrixexpansion(trm); - m.xx = trm.a * 65536 / scale; - m.xy = trm.b * 65536 / scale; - m.yx = trm.c * 65536 / scale; - m.yy = trm.d * 65536 / scale; - v.x = 0; - v.y = 0; - - fterr = FT_Set_Char_Size(face, 64 * scale, 64 * scale, 72, 72); - if (fterr) - fz_warn("freetype setting character size: %s", ft_errorstring(fterr)); - FT_Set_Transform(face, &m, &v); - - fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP); - if (fterr) - fz_warn("freetype load glyph (gid %d): %s", gid, ft_errorstring(fterr)); -#else - fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING); - if (fterr) + /* If you really want grid fitting, enable this code. */ + float scale = fz_matrixexpansion(trm); + m.xx = trm.a * 65536 / scale; + m.xy = trm.b * 65536 / scale; + m.yx = trm.c * 65536 / scale; + m.yy = trm.d * 65536 / scale; + v.x = 0; + v.y = 0; + + fterr = FT_Set_Char_Size(face, 64 * scale, 64 * scale, 72, 72); + if (fterr) + fz_warn("freetype setting character size: %s", ft_errorstring(fterr)); + FT_Set_Transform(face, &m, &v); +#endif + fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP); + if (fterr) + fz_warn("freetype load glyph (gid %d): %s", gid, ft_errorstring(fterr)); + } + else { - fz_warn("freetype load glyph (gid %d): %s", gid, ft_errorstring(fterr)); - return nil; + fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING); + if (fterr) + { + fz_warn("freetype load glyph (gid %d): %s", gid, ft_errorstring(fterr)); + return nil; + } } -#endif fterr = FT_Render_Glyph(face->glyph, ft_render_mode_normal); if (fterr) |