summaryrefslogtreecommitdiff
path: root/world/res_font.c
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2009-02-27 15:54:08 +0100
committerTor Andersson <tor@ghostscript.com>2009-02-27 15:54:08 +0100
commit6f68928302a10fbb9edb365fe3f1a47af4afcc16 (patch)
tree65f347db7063df8ca3a83394a47e6217d840cc09 /world/res_font.c
parentf7500b8862ef9bc0874d09158de14e26441b97ea (diff)
downloadmupdf-6f68928302a10fbb9edb365fe3f1a47af4afcc16.tar.xz
Enable hinting hack for dynalab fonts.
Diffstat (limited to 'world/res_font.c')
-rw-r--r--world/res_font.c36
1 files changed, 32 insertions, 4 deletions
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, "<unknown>");
- 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));