From ae7b70dce175e02f5eab4b960267c8fba4a02b22 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 1 May 2013 13:49:31 +0200 Subject: Try to use ToUnicode cmap to encode identity-encoded substitute fonts. --- pdf/pdf_font.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c index b1621657..de43796f 100644 --- a/pdf/pdf_font.c +++ b/pdf/pdf_font.c @@ -868,6 +868,17 @@ load_cid_font(pdf_document *xref, pdf_obj *dict, pdf_obj *encoding, pdf_obj *to_ pdf_load_to_unicode(xref, fontdesc, NULL, collection, to_unicode); + /* If we have an identity encoding, we're supposed to use the glyph ids directly. + * If we only have a substitute font, that won't work. + * Make a last ditch attempt by using + * the ToUnicode table if it exists to map via the substitute font's cmap. */ + if (strstr(fontdesc->encoding->cmap_name, "Identity-") && fontdesc->font->ft_substitute) + { + fz_warn(ctx, "non-embedded font using identity encoding: %s", basefont); + if (fontdesc->to_unicode && !fontdesc->to_ttf_cmap) + fontdesc->to_ttf_cmap = pdf_keep_cmap(ctx, fontdesc->to_unicode); + } + /* Horizontal */ dw = 1000; -- cgit v1.2.3