texlive[51027] Build/source/texk/dvipdfm-x: Fix a bug that CFF

commits+kakuto at tug.org commits+kakuto at tug.org
Mon May 6 23:07:34 CEST 2019


Revision: 51027
          http://tug.org/svn/texlive?view=revision&revision=51027
Author:   kakuto
Date:     2019-05-06 23:07:33 +0200 (Mon, 06 May 2019)
Log Message:
-----------
Fix a  bug that CFF charset data was not read. (S. Hirata)

Modified Paths:
--------------
    trunk/Build/source/texk/dvipdfm-x/ChangeLog
    trunk/Build/source/texk/dvipdfm-x/tt_cmap.c
    trunk/Build/source/texk/dvipdfm-x/unicode.c

Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog	2019-05-06 21:06:09 UTC (rev 51026)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog	2019-05-06 21:07:33 UTC (rev 51027)
@@ -1,3 +1,9 @@
+2019-05-07  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
+
+	* tt_cmap.c: Fix a  bug that CFF charset data was not read.
+	* unicode.c: Fix a  bug that end-of-buffer calculation was
+	wrong.
+
 2019-05-05  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
 
 	* pdfdoc.c: g option affects only annotations created by

Modified: trunk/Build/source/texk/dvipdfm-x/tt_cmap.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/tt_cmap.c	2019-05-06 21:06:09 UTC (rev 51026)
+++ trunk/Build/source/texk/dvipdfm-x/tt_cmap.c	2019-05-06 21:07:33 UTC (rev 51027)
@@ -640,7 +640,6 @@
 
   memset(GIDToCIDMap, 0, num_glyphs*sizeof(uint16_t));
 
-  cff_read_charsets(cffont);
   charset = cffont->charsets;
   if (!charset)
     return;
@@ -939,6 +938,7 @@
       ULONG offset;
       offset = sfnt_find_table_pos(sfont, "CFF ");
       cffont = cff_open(sfont->stream, offset, 0);
+      cff_read_charsets(cffont);   
     }
     is_cidfont = cffont && (cffont->flag & FONTTYPE_CIDFONT);
 
@@ -1440,6 +1440,7 @@
         csi.ordering   = cff_get_string(cffont, ord);
         csi.supplement = (int) cff_dict_get(cffont->topdict, "ROS", 2);
       }
+      cff_read_charsets(cffont);
       create_GIDToCIDMap(GIDToCIDMap, num_glyphs, cffont);
     }
     cff_close(cffont);
@@ -1559,7 +1560,9 @@
             src[0] = (cid >> 8) & 0xff;
             src[1] =  cid & 0xff;
             len = UC_UTF16BE_encode_char(ch, &p, endptr);
-            CMap_add_bfchar(tounicode, src, 2, dst, len);
+            if (len > 0) {
+              CMap_add_bfchar(tounicode, src, 2, dst, len);
+            }
           }
         }
       }
@@ -1700,6 +1703,7 @@
         csi.ordering   = cff_get_string(cffont, ord);
         csi.supplement = (int) cff_dict_get(cffont->topdict, "ROS", 2);
       }
+      cff_read_charsets(cffont);     
       GIDToCIDMap = NEW(num_glyphs, uint16_t);
       memset(GIDToCIDMap, 0, num_glyphs*sizeof(uint16_t));      
       create_GIDToCIDMap(GIDToCIDMap, num_glyphs, cffont);

Modified: trunk/Build/source/texk/dvipdfm-x/unicode.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/unicode.c	2019-05-06 21:06:09 UTC (rev 51026)
+++ trunk/Build/source/texk/dvipdfm-x/unicode.c	2019-05-06 21:07:33 UTC (rev 51027)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2002-2019 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
 
     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -123,7 +123,7 @@
   unsigned char *p = *pp;
 
   if (ucv >= 0 && ucv <= 0xFFFF) {
-    if (p + 2 >= endptr)
+    if (p + 2 > endptr)
       return 0;
     p[0] = (ucv >> 8) & 0xff;
     p[1] = ucv & 0xff;
@@ -131,7 +131,7 @@
   } else if (ucv >= 0x010000 && ucv <= 0x10FFFF) {
     unsigned short high, low;
 
-    if (p + 4 >= endptr)
+    if (p + 4 > endptr)
       return 0;
     ucv  -= 0x00010000;
     high = (ucv >> UC_SUR_SHIFT) + UC_SUR_HIGH_START;
@@ -142,7 +142,7 @@
     p[3] = (low & 0xff);
     count = 4;
   } else {
-    if (p + 2 >= endptr)
+    if (p + 2 > endptr)
       return 0;
     p[0] = (UC_REPLACEMENT_CHAR >> 8) & 0xff;
     p[1] = (UC_REPLACEMENT_CHAR & 0xff);
@@ -207,18 +207,18 @@
     return 0;
 
   if (ucv < 0x7f) {
-    if (p >= endptr - 1)
+    if (p + 1 > endptr)
       return 0;
     p[0]  = (unsigned char) ucv;
     count = 1;
   } else if (ucv <= 0x7ff) {
-    if (p >= endptr -2)
+    if (p + 2 > endptr)
       return 0;
     p[0] = (unsigned char) (0xc0 | (ucv >> 6));
     p[1] = (unsigned char) (0x80 | (ucv & 0x3f));
     count = 2;
   } else if (ucv <= 0xffff) {
-    if (p >= endptr - 3)
+    if (p + 3 > endptr)
       return 0;
     p[0] = (unsigned char) (0xe0 | (ucv >> 12));
     p[1] = (unsigned char) (0x80 | ((ucv >> 6) & 0x3f));
@@ -225,7 +225,7 @@
     p[2] = (unsigned char) (0x80 | (ucv & 0x3f));
     count = 3;
   } else if (ucv <= 0x1fffff) {
-    if (p >= endptr - 4)
+    if (p + 4 > endptr)
       return 0;
     p[0] = (unsigned char) (0xf0 | (ucv >> 18));
     p[1] = (unsigned char) (0x80 | ((ucv >> 12) & 0x3f));
@@ -233,7 +233,7 @@
     p[3] = (unsigned char) (0x80 | (ucv & 0x3f));
     count = 4;
   } else if (ucv <= 0x3ffffff) {
-    if (p >= endptr - 5)
+    if (p + 5 > endptr)
       return 0;
     p[0] = (unsigned char) (0xf8 | (ucv >> 24));
     p[1] = (unsigned char) (0x80 | ((ucv >> 18) & 0x3f));
@@ -242,7 +242,7 @@
     p[4] = (unsigned char) (0x80 | (ucv & 0x3f));
     count = 5;
   } else if (ucv <= 0x7fffffff) {
-     if (p >= endptr - 6)
+     if (p + 6 > endptr)
       return 0;
     p[0] = (unsigned char) (0xfc | (ucv >> 30));
     p[1] = (unsigned char) (0x80 | ((ucv >> 24) & 0x3f));



More information about the tex-live-commits mailing list