From 15099174daf3ddebb6c81f9fcafcbc1256f9435e Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 30 Mar 2012 14:08:48 +0200 Subject: Retry loading a hinted glyph without hinting if freetype returns an error. Allows us to render files with broken font hinting programs when hinting is enabled(whether by no-AA or DynaLab detection). Fix bug 692949. --- fitz/res_font.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'fitz') diff --git a/fitz/res_font.c b/fitz/res_font.c index ca76fcfe..a0c2fc2a 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -423,7 +423,7 @@ fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, int a if (aa == 0) { - /* If you really want grid fitting, enable this code. */ + /* enable grid fitting for non-antialiased rendering */ float scale = fz_matrix_expansion(trm); m.xx = trm.a * 65536 / scale; m.xy = trm.b * 65536 / scale; @@ -437,8 +437,10 @@ fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, int a fz_warn(ctx, "freetype setting character size: %s", ft_error_string(fterr)); FT_Set_Transform(face, &m, &v); fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP | FT_LOAD_TARGET_MONO); - if (fterr) - fz_warn(ctx, "freetype load glyph (gid %d): %s", gid, ft_error_string(fterr)); + if (fterr) { + fz_warn(ctx, "freetype load hinted glyph (gid %d): %s", gid, ft_error_string(fterr)); + goto retry_unhinted; + } } else if (font->ft_hint) { @@ -450,11 +452,14 @@ fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, int a so that we get the correct outline shape. */ fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP); - if (fterr) - fz_warn(ctx, "freetype load glyph (gid %d): %s", gid, ft_error_string(fterr)); + if (fterr) { + fz_warn(ctx, "freetype load hinted glyph (gid %d): %s", gid, ft_error_string(fterr)); + goto retry_unhinted; + } } else { +retry_unhinted: fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING); if (fterr) { -- cgit v1.2.3