From a5f499f4bf951ea37b2db47198fa21c11a5f8645 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Thu, 6 Sep 2018 00:10:18 +0000 Subject: Fix broken ToUnicode CMap support (S. Hirata) git-svn-id: svn://tug.org/texlive/trunk@48595 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipdfm-x/pdfencoding.c | 39 +++++++++++++++++-------------- 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'Build/source/texk/dvipdfm-x/pdfencoding.c') diff --git a/Build/source/texk/dvipdfm-x/pdfencoding.c b/Build/source/texk/dvipdfm-x/pdfencoding.c index 1d2a5812f90..0617d2c19dd 100644 --- a/Build/source/texk/dvipdfm-x/pdfencoding.c +++ b/Build/source/texk/dvipdfm-x/pdfencoding.c @@ -639,6 +639,10 @@ pdf_encoding_get_tounicode (int encoding_id) * Note: The PDF 1.4 reference is not consistent: Section 5.9 describes * the Unicode mapping of PDF 1.3 and Section 9.7.2 (in the context of * Tagged PDF) the one of PDF 1.5. + * + * CHANGED: 20180906 + * Always create ToUnicode CMap unless there is missing mapping. + * Change made on rev.7557 broke ToUnicode CMap support. Now reverted. */ pdf_obj * pdf_create_ToUnicode_CMap (const char *enc_name, @@ -646,7 +650,7 @@ pdf_create_ToUnicode_CMap (const char *enc_name, { pdf_obj *stream; CMap *cmap; - int code, all_predef; + int code, total_fail; char *cmap_name; unsigned char *p, *endptr; @@ -664,32 +668,31 @@ pdf_create_ToUnicode_CMap (const char *enc_name, CMap_add_codespacerange(cmap, range_min, range_max, 1); - all_predef = 1; + total_fail = 0; for (code = 0; code <= 0xff; code++) { if (is_used && !is_used[code]) continue; if (enc_vec[code]) { - int32_t len; + size_t len; int fail_count = 0; - agl_name *agln = agl_lookup_list(enc_vec[code]); - /* Adobe glyph naming conventions are not used by viewers, - * hence even ligatures (e.g, "f_i") must be explicitly defined - */ - if (pdf_check_version(1, 5) < 0 || !agln || !agln->is_predef) { - wbuf[0] = (code & 0xff); - p = wbuf + 1; - endptr = wbuf + WBUF_SIZE; - len = agl_sput_UTF16BE(enc_vec[code], &p, endptr, &fail_count); - if (len >= 1 && !fail_count) { - CMap_add_bfchar(cmap, wbuf, 1, wbuf + 1, len); - all_predef &= agln && agln->is_predef; - } - } + wbuf[0] = (code & 0xff); + p = wbuf + 1; + endptr = wbuf + WBUF_SIZE; + len = agl_sput_UTF16BE(enc_vec[code], &p, endptr, &fail_count); + if (len < 1 && fail_count > 0) { + total_fail++; + } else { + CMap_add_bfchar(cmap, wbuf, 1, wbuf + 1, len); + } } } - stream = all_predef ? NULL : CMap_create_stream(cmap); + if (total_fail > 0) { + if (verbose) + WARN("Glyphs with no Unicode mapping found. Removing ToUnicode CMap."); + } + stream = total_fail > 0 ? NULL : CMap_create_stream(cmap); CMap_release(cmap); RELEASE(cmap_name); -- cgit v1.2.3