summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2011-02-23 14:29:22 +0000
committerTor Andersson <tor@ghostscript.com>2011-02-23 14:29:22 +0000
commit448fcbab4658f24b6067d82162b88c0631567387 (patch)
tree4cc95dd532cbf90d8e91998a4930318a8b1df8ea
parentc889fcd06f1256571342368d40d375e44045dcd3 (diff)
downloadmupdf-448fcbab4658f24b6067d82162b88c0631567387.tar.xz
Revert to using fthint since we cannot rely on FreeType's trickyness detection on some subset fonts.
-rw-r--r--fitz/fitz.h1
-rw-r--r--fitz/res_font.c58
-rw-r--r--mupdf/pdf_font.c9
3 files changed, 45 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)
diff --git a/mupdf/pdf_font.c b/mupdf/pdf_font.c
index cd080ee6..9019c8a9 100644
--- a/mupdf/pdf_font.c
+++ b/mupdf/pdf_font.c
@@ -602,6 +602,15 @@ loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *enco
else
fz_setfontbbox(fontdesc->font, bbox.x0, bbox.y0, bbox.x1, bbox.y1);
+ /* Check for DynaLab fonts that must use hinting */
+ if (kind == TRUETYPE)
+ {
+ if (FT_IS_TRICKY(face))
+ fontdesc->font->fthint = 1;
+ if (strstr(collection, "Adobe-"))
+ fontdesc->font->fthint = 1;
+ }
+
/* Encoding */
error = fz_okay;