diff options
-rw-r--r-- | Build/source/texk/dvipdfm-x/ChangeLog | 8 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/cidtype2.c | 100 | ||||
-rwxr-xr-x | Build/source/texk/dvipdfm-x/configure | 22 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/configure.ac | 2 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/tt_cmap.c | 2 |
5 files changed, 80 insertions, 54 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index 1f50eb42466..5382f93a745 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,3 +1,11 @@ +2020-10-14 Shunsaku Hirata <shunsaku.hirata74@gmail.com> + + * tt_cmap.c: Fix a bug that checking array indices is wrong. + * cidtype2.c: Warning message when CID is mapped to a sequence + of several Unicode characters is corrected. Fix a wrong + assumption introduced by xdvipdfmx. + * configure.ac: Version 20201014. + 2020-10-08 Shunsaku Hirata <shunsaku.hirata74@gmail.com> * dvi.c: Fix problems introduced by the changes on 2020/10/03. diff --git a/Build/source/texk/dvipdfm-x/cidtype2.c b/Build/source/texk/dvipdfm-x/cidtype2.c index f6913d1673f..899ae2202f6 100644 --- a/Build/source/texk/dvipdfm-x/cidtype2.c +++ b/Build/source/texk/dvipdfm-x/cidtype2.c @@ -34,6 +34,8 @@ #include "dpxconf.h" #include "dpxfile.h" +#include "unicode.h" + #include "pdfobj.h" /* pseudo unique tag */ #include "pdffont.h" @@ -434,8 +436,8 @@ fix_CJK_symbols (unsigned short code) return alt_code; } -static int -cid_to_code (CMap *cmap, CID cid) +static int32_t +cid_to_code (CMap *cmap, CID cid, int unicode_cmap) { unsigned char inbuf[2], outbuf[32]; int inbytesleft = 2, outbytesleft = 32; @@ -452,22 +454,29 @@ cid_to_code (CMap *cmap, CID cid) CMap_decode_char(cmap, &p, &inbytesleft, &q, &outbytesleft); if (inbytesleft != 0) - return 0; + return -1; else if (outbytesleft == 31) - return (int) outbuf[0]; + return (int32_t) outbuf[0]; else if (outbytesleft == 30) - return (int) (outbuf[0] << 8|outbuf[1]); - else if (outbytesleft == 28) { /* We assume the output encoding is UTF-16. */ - CID hi, lo; - hi = outbuf[0] << 8|outbuf[1]; - lo = outbuf[2] << 8|outbuf[3]; - if (hi >= 0xd800 && hi <= 0xdbff && lo >= 0xdc00 && lo <= 0xdfff) - return (int) ((hi - 0xd800) * 0x400 + 0x10000 + lo - 0xdc00); - else - return (int) (hi << 16|lo); + return (int32_t) (outbuf[0] << 8|outbuf[1]); + else if (outbytesleft == 28) { + if (unicode_cmap) { + /* We assume the output encoding is UTF-16. */ + int32_t uc; + const unsigned char *endptr; + + p = outbuf; + endptr = p + 4; + uc = UC_UTF16BE_decode_char(&p, endptr); + if (p != endptr) + WARN("CID=%u mapped to non-single Unicode characters...", cid); + return p == endptr ? uc : -1; + } else { + return (outbuf[0] << 24)|(outbuf[1] << 16)|(outbuf[2] << 8)|outbuf[3]; + } } - return 0; + return -1; } /* #define NO_GHOSTSCRIPT_BUG 1 */ @@ -693,8 +702,8 @@ CIDFont_type2_dofont (pdf_font *font) if (h_used_chars) { used_chars = h_used_chars; for (cid = 1; cid <= last_cid; cid++) { - int code; - unsigned short gid; + int32_t code; + uint16_t gid = 0; if (!is_used_char2(h_used_chars, cid)) continue; @@ -703,25 +712,29 @@ CIDFont_type2_dofont (pdf_font *font) gid = cid; code = cid; } else { - code = cid_to_code(cmap, cid); - gid = tt_cmap_lookup(ttcmap, code); + code = cid_to_code(cmap, cid, unicode_cmap); + if (code < 0) { + WARN("Unable to map CID to code: CID=%u", cid); + } else { + gid = tt_cmap_lookup(ttcmap, code); #ifdef FIX_CJK_UNIOCDE_SYMBOLS - if (gid == 0 && unicode_cmap) { - int alt_code; + if (gid == 0 && unicode_cmap) { + int alt_code; - alt_code = fix_CJK_symbols((unsigned short)code); - if (alt_code != code) { - gid = tt_cmap_lookup(ttcmap, alt_code); - if (gid != 0) { - WARN("Unicode char U+%04x replaced with U+%04x.", code, alt_code); + alt_code = fix_CJK_symbols((unsigned short)code); + if (alt_code != code) { + gid = tt_cmap_lookup(ttcmap, alt_code); + if (gid != 0) { + WARN("Unicode char U+%04x replaced with U+%04x.", code, alt_code); + } } } - } #endif /* FIX_CJK_UNIOCDE_SYMBOLS */ + } } - if (gid == 0) { - WARN("Glyph missing in font. (CID=%u, code=0x%04x)", cid, code); + if (code >= 0) + WARN("Glyph missing in font. (CID=%u, code=0x%04x)", cid, code); } /* TODO: duplicated glyph */ @@ -764,8 +777,8 @@ CIDFont_type2_dofont (pdf_font *font) } for (cid = 1; cid <= last_cid; cid++) { - int code; - unsigned short gid; + int32_t code; + uint16_t gid = 0; if (!is_used_char2(v_used_chars, cid)) continue; @@ -782,24 +795,29 @@ CIDFont_type2_dofont (pdf_font *font) gid = cid; code = cid; } else { - code = cid_to_code(cmap, cid); - gid = tt_cmap_lookup(ttcmap, code); + code = cid_to_code(cmap, cid, unicode_cmap); + if (code < 0) { + WARN("Unable to map CID to code: CID=%u", cid); + } else { + gid = tt_cmap_lookup(ttcmap, code); #ifdef FIX_CJK_UNIOCDE_SYMBOLS - if (gid == 0 && unicode_cmap) { - int alt_code; + if (gid == 0 && unicode_cmap) { + int alt_code; - alt_code = fix_CJK_symbols((unsigned short)code); - if (alt_code != code) { - gid = tt_cmap_lookup(ttcmap, alt_code); - if (gid != 0) { - WARN("Unicode char U+%04x replaced with U+%04x.", code, alt_code); + alt_code = fix_CJK_symbols((unsigned short)code); + if (alt_code != code) { + gid = tt_cmap_lookup(ttcmap, alt_code); + if (gid != 0) { + WARN("Unicode char U+%04x replaced with U+%04x.", code, alt_code); + } } } - } #endif /* FIX_CJK_UNIOCDE_SYMBOLS */ + } } if (gid == 0) { - WARN("Glyph missing in font. (CID=%u, code=0x%04x)", cid, code); + if (code >= 0) + WARN("Glyph missing in font. (CID=%u, code=0x%04x)", cid, code); } else if (gsub_list) { otl_gsub_apply(gsub_list, &gid); } diff --git a/Build/source/texk/dvipdfm-x/configure b/Build/source/texk/dvipdfm-x/configure index db7f26a1d7b..ec83ce19801 100755 --- a/Build/source/texk/dvipdfm-x/configure +++ b/Build/source/texk/dvipdfm-x/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20201008. +# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20201014. # # Report bugs to <dvipdfmx@tug.org>. # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='dvipdfm-x (TeX Live)' PACKAGE_TARNAME='dvipdfm-x--tex-live-' -PACKAGE_VERSION='20201008' -PACKAGE_STRING='dvipdfm-x (TeX Live) 20201008' +PACKAGE_VERSION='20201014' +PACKAGE_STRING='dvipdfm-x (TeX Live) 20201014' PACKAGE_BUGREPORT='dvipdfmx@tug.org' PACKAGE_URL='' @@ -1350,7 +1350,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures dvipdfm-x (TeX Live) 20201008 to adapt to many kinds of systems. +\`configure' configures dvipdfm-x (TeX Live) 20201014 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1421,7 +1421,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20201008:";; + short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20201014:";; esac cat <<\_ACEOF @@ -1551,7 +1551,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dvipdfm-x (TeX Live) configure 20201008 +dvipdfm-x (TeX Live) configure 20201014 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2390,7 +2390,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by dvipdfm-x (TeX Live) $as_me 20201008, which was +It was created by dvipdfm-x (TeX Live) $as_me 20201014, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -8077,7 +8077,7 @@ fi # Define the identity of the package. PACKAGE='dvipdfm-x--tex-live-' - VERSION='20201008' + VERSION='20201014' cat >>confdefs.h <<_ACEOF @@ -14746,7 +14746,7 @@ Usage: $0 [OPTIONS] Report bugs to <bug-libtool@gnu.org>." lt_cl_version="\ -dvipdfm-x (TeX Live) config.lt 20201008 +dvipdfm-x (TeX Live) config.lt 20201014 configured by $0, generated by GNU Autoconf 2.69. Copyright (C) 2011 Free Software Foundation, Inc. @@ -16636,7 +16636,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by dvipdfm-x (TeX Live) $as_me 20201008, which was +This file was extended by dvipdfm-x (TeX Live) $as_me 20201014, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16706,7 +16706,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -dvipdfm-x (TeX Live) config.status 20201008 +dvipdfm-x (TeX Live) config.status 20201014 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/Build/source/texk/dvipdfm-x/configure.ac b/Build/source/texk/dvipdfm-x/configure.ac index f75a75b1e0b..70ffd410dd0 100644 --- a/Build/source/texk/dvipdfm-x/configure.ac +++ b/Build/source/texk/dvipdfm-x/configure.ac @@ -8,7 +8,7 @@ dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl -AC_INIT([dvipdfm-x (TeX Live)], [20201008], [dvipdfmx@tug.org]) +AC_INIT([dvipdfm-x (TeX Live)], [20201014], [dvipdfmx@tug.org]) AC_PREREQ([2.65]) AC_CONFIG_SRCDIR([agl.c]) AC_CONFIG_AUX_DIR([../../build-aux]) diff --git a/Build/source/texk/dvipdfm-x/tt_cmap.c b/Build/source/texk/dvipdfm-x/tt_cmap.c index 17c1e9924dd..cb8afb69812 100644 --- a/Build/source/texk/dvipdfm-x/tt_cmap.c +++ b/Build/source/texk/dvipdfm-x/tt_cmap.c @@ -434,7 +434,7 @@ lookup_cmap12 (struct cmap12 *map, ULONG cccc) int i; i = map->nGroups; - while (i-- >= 0 && + while (i-- > 0 && cccc <= map->groups[i].endCharCode) { if (cccc >= map->groups[i].startCharCode) { gid = (USHORT) ((cccc - |