texlive[50236] Build/source/texk/dvipdfm-x: Fix 'null character(s)'

commits+kakuto at tug.org commits+kakuto at tug.org
Tue Mar 5 07:57:52 CET 2019


Revision: 50236
          http://tug.org/svn/texlive?view=revision&revision=50236
Author:   kakuto
Date:     2019-03-05 07:57:52 +0100 (Tue, 05 Mar 2019)
Log Message:
-----------
Fix 'null character(s)' warning (Clerk Ma)

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

Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog	2019-03-05 04:31:21 UTC (rev 50235)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog	2019-03-05 06:57:52 UTC (rev 50236)
@@ -1,3 +1,8 @@
+2019-03-05  Clerk Ma  <maqiyuan130324 at vip.qq.com>
+
+	* tt_table.c: Fix 'null character(s)' warning which caused by
+	fonts like Roboto (Android) or YuMincho (Windows 10).
+
 2019-02-25  Hironobu Yamashita  <h.y.acetaminophen at gmail.com>
 
 	* tt_cmap.c (is_PUA_or_presentation):

Modified: trunk/Build/source/texk/dvipdfm-x/tt_table.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/tt_table.c	2019-03-05 04:31:21 UTC (rev 50235)
+++ trunk/Build/source/texk/dvipdfm-x/tt_table.c	2019-03-05 06:57:52 UTC (rev 50236)
@@ -432,9 +432,12 @@
   USHORT length = 0;
   USHORT num_names, string_offset;
   ULONG  name_offset;
-  int    i;
+  int    i, j;
+  int    is_utf16_be;
 
   name_offset = sfnt_locate_table (sfont, "name");
+  is_utf16_be = (plat_id == 3) && (enco_id == 1) &&
+                (lang_id == 0x0409u) && (name_id == 6);
 
   if (sfnt_get_ushort(sfont)) 
     ERROR ("Expecting zero");
@@ -453,13 +456,23 @@
     offset = sfnt_get_ushort(sfont);
     /* language ID value 0xffffu for `accept any language ID' */
     if ((p_id == plat_id) && (e_id == enco_id) &&
-	(lang_id == 0xffffu || l_id == lang_id) && (n_id == name_id)) {
+        (lang_id == 0xffffu || l_id == lang_id) && (n_id == name_id)) {
+      if (is_utf16_be) {
+          length /= 2;
+      }
       if (length > destlen - 1) {
-	WARN ("Name string too long (%u), truncating to %u", length, destlen);
-	length = destlen - 1;
+        WARN ("Name string too long (%u), truncating to %u", length, destlen);
+        length = destlen - 1;
       }
       sfnt_seek_set (sfont, name_offset+string_offset+offset);
-      sfnt_read((unsigned char*)dest, length, sfont);
+      if (is_utf16_be) {
+        for (j=0;j<length;j++) {
+          dest[j] = (unsigned char)(sfnt_get_ushort(sfont) & 0x00FF);
+        }
+      }
+      else {
+        sfnt_read((unsigned char*)dest, length, sfont);
+      }
       dest[length] = '\0';
       break;
     }



More information about the tex-live-commits mailing list