From 6f68928302a10fbb9edb365fe3f1a47af4afcc16 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 27 Feb 2009 15:54:08 +0100 Subject: Enable hinting hack for dynalab fonts. --- world/res_font.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'world/res_font.c') diff --git a/world/res_font.c b/world/res_font.c index 299f0d50..ad0d05f9 100644 --- a/world/res_font.c +++ b/world/res_font.c @@ -17,8 +17,9 @@ fz_newfont(void) font->refs = 1; strcpy(font->name, ""); - font->ftsubstitute = 0; font->ftface = nil; + font->ftsubstitute = 0; + font->fthint = 0; font->t3matrix = fz_identity(); font->t3procs = nil; @@ -238,11 +239,38 @@ fz_renderftglyph(fz_glyph *glyph, fz_font *font, int gid, fz_matrix trm) FT_Set_Char_Size(face, 65536, 65536, 72, 72); /* should be 64, 64 */ FT_Set_Transform(face, &m, &v); - fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING); - if (fterr) + 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 USE_HINTING + /* 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; + FT_Set_Char_Size(face, 64 * scale, 64 * scale, 72, 72); + FT_Set_Transform(face, &m, &v); +#endif + fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP); + if (fterr) fz_warn("freetype load glyph: %s", ft_errorstring(fterr)); - fterr = FT_Render_Glyph(face->glyph, ft_render_mode_normal); + } + else + { + fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING); + if (fterr) + fz_warn("freetype load glyph: %s", ft_errorstring(fterr)); + } + fterr = FT_Render_Glyph(face->glyph, ft_render_mode_normal); if (fterr) fz_warn("freetype render glyph: %s", ft_errorstring(fterr)); -- cgit v1.2.3