summaryrefslogtreecommitdiff
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
parentf7500b8862ef9bc0874d09158de14e26441b97ea (diff)
downloadmupdf-6f68928302a10fbb9edb365fe3f1a47af4afcc16.tar.xz
Enable hinting hack for dynalab fonts.
-rw-r--r--include/fitz/wld_font.h1
-rw-r--r--mupdf/pdf_font.c4
-rw-r--r--mupdf/pdf_unicode.c10
-rw-r--r--world/res_font.c36
4 files changed, 45 insertions, 6 deletions
diff --git a/include/fitz/wld_font.h b/include/fitz/wld_font.h
index 8bcffb60..705a706a 100644
--- a/include/fitz/wld_font.h
+++ b/include/fitz/wld_font.h
@@ -11,6 +11,7 @@ struct fz_font_s
void *ftface; /* has an FT_Face if used */
int ftsubstitute; /* ... substitute metrics */
+ int fthint; /* ... force hinting for DynaLab fonts */
struct fz_tree_s **t3procs; /* has 256 entries if used */
fz_matrix t3matrix;
diff --git a/mupdf/pdf_font.c b/mupdf/pdf_font.c
index e6234c14..88b85cec 100644
--- a/mupdf/pdf_font.c
+++ b/mupdf/pdf_font.c
@@ -694,6 +694,10 @@ loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *ref,
if (error)
goto cleanup;
+ /* Rudimentary check for DynaLab fonts */
+ if (kind == TRUETYPE && collection && strstr(collection, "Adobe-"))
+ fontdesc->font->fthint = 1;
+
/*
* Horizontal
*/
diff --git a/mupdf/pdf_unicode.c b/mupdf/pdf_unicode.c
index 4001b5b0..a0738020 100644
--- a/mupdf/pdf_unicode.c
+++ b/mupdf/pdf_unicode.c
@@ -61,7 +61,7 @@ pdf_loadtounicode(pdf_fontdesc *font, pdf_xref *xref,
else if (collection)
{
- pdf_logfont("tounicode cid collection\n");
+ pdf_logfont("tounicode cid collection (%s)\n", collection);
error = fz_okay;
@@ -110,7 +110,13 @@ pdf_loadtounicode(pdf_fontdesc *font, pdf_xref *xref,
return fz_okay;
}
- pdf_logfont("tounicode impossible");
+ if (!font->tounicode && !font->cidtoucs)
+ {
+ pdf_logfont("tounicode could not be loaded\n");
+ /* TODO: synthesize a ToUnicode if it's a freetype font with
+ * cmap and/or post tables or if it has glyph names. */
+ }
+
return fz_okay;
}
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));