summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-font.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2014-05-29 15:17:47 +0200
committerTor Andersson <tor.andersson@artifex.com>2014-05-29 15:18:20 +0200
commit0f0653cac62c7dbcd4b4cd2ea57640769271365c (patch)
tree944517414cd5c41297e436ed5c5b34d97e7e313b /source/pdf/pdf-font.c
parent803294993c0ec927678f80ffb317770a8785f83b (diff)
downloadmupdf-0f0653cac62c7dbcd4b4cd2ea57640769271365c.tar.xz
Fix 694093: add vertical variant of CJK fallback font.
Replace the DroidSansFallback TTF files with a TTC that has two fonts: The original and a copy where the OpenType 'vert' substitution lookup has been pre-applied by copying the uniXXXX.vert glyph data to uniXXXX.
Diffstat (limited to 'source/pdf/pdf-font.c')
-rw-r--r--source/pdf/pdf-font.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index 3f6d5601..c6dc7123 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -233,8 +233,9 @@ pdf_load_substitute_cjk_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fon
if (!data)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find builtin CJK font");
- /* a glyph bbox cache is too big for droid sans fallback (51k glyphs!) */
- fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, 0, 0);
+ /* The DroidSansFallback fonts have both H and V variants in the TTC */
+ /* A glyph bbox cache is too big for DroidSansFallback (51k glyphs!) */
+ fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, fontdesc->wmode, 0);
}
fontdesc->font->ft_substitute = 1;
@@ -848,6 +849,7 @@ load_cid_font(pdf_document *doc, pdf_obj *dict, pdf_obj *encoding, pdf_obj *to_u
pdf_obj *widths;
pdf_obj *descriptor;
pdf_font_desc *fontdesc = NULL;
+ pdf_cmap *cmap;
FT_Face face;
char collection[256];
char *basefont;
@@ -889,40 +891,44 @@ load_cid_font(pdf_document *doc, pdf_obj *dict, pdf_obj *encoding, pdf_obj *to_u
fz_strlcat(collection, tmpstr, sizeof collection);
}
- /* Load font file */
-
- fontdesc = pdf_new_font_desc(ctx);
-
- descriptor = pdf_dict_gets(dict, "FontDescriptor");
- if (!descriptor)
- fz_throw(ctx, FZ_ERROR_GENERIC, "syntaxerror: missing font descriptor");
- pdf_load_font_descriptor(fontdesc, doc, descriptor, collection, basefont, 1);
-
- face = fontdesc->font->ft_face;
-
/* Encoding */
if (pdf_is_name(encoding))
{
if (!strcmp(pdf_to_name(encoding), "Identity-H"))
- fontdesc->encoding = pdf_new_identity_cmap(ctx, 0, 2);
+ cmap = pdf_new_identity_cmap(ctx, 0, 2);
else if (!strcmp(pdf_to_name(encoding), "Identity-V"))
- fontdesc->encoding = pdf_new_identity_cmap(ctx, 1, 2);
+ cmap = pdf_new_identity_cmap(ctx, 1, 2);
else
- fontdesc->encoding = pdf_load_system_cmap(ctx, pdf_to_name(encoding));
+ cmap = pdf_load_system_cmap(ctx, pdf_to_name(encoding));
}
else if (pdf_is_indirect(encoding))
{
- fontdesc->encoding = pdf_load_embedded_cmap(doc, encoding);
+ cmap = pdf_load_embedded_cmap(doc, encoding);
}
else
{
fz_throw(ctx, FZ_ERROR_GENERIC, "syntaxerror: font missing encoding");
}
+
+ /* Load font file */
+
+ fontdesc = pdf_new_font_desc(ctx);
+
+ fontdesc->encoding = cmap;
fontdesc->size += pdf_cmap_size(ctx, fontdesc->encoding);
pdf_set_font_wmode(ctx, fontdesc, pdf_cmap_wmode(ctx, fontdesc->encoding));
+ descriptor = pdf_dict_gets(dict, "FontDescriptor");
+ if (!descriptor)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "syntaxerror: missing font descriptor");
+ pdf_load_font_descriptor(fontdesc, doc, descriptor, collection, basefont, 1);
+
+ face = fontdesc->font->ft_face;
+
+ /* Apply encoding */
+
cidtogidmap = pdf_dict_gets(dict, "CIDToGIDMap");
if (pdf_is_indirect(cidtogidmap))
{