texlive[56064] Build/source/texk/dvipdfm-x: Use uint32_t for TTC

commits+kakuto at tug.org commits+kakuto at tug.org
Fri Aug 7 23:28:08 CEST 2020


Revision: 56064
          http://tug.org/svn/texlive?view=revision&revision=56064
Author:   kakuto
Date:     2020-08-07 23:28:08 +0200 (Fri, 07 Aug 2020)
Log Message:
-----------
Use uint32_t for TTC index. (S. Hirata)

Modified Paths:
--------------
    trunk/Build/source/texk/dvipdfm-x/ChangeLog
    trunk/Build/source/texk/dvipdfm-x/fontmap.c
    trunk/Build/source/texk/dvipdfm-x/fontmap.h
    trunk/Build/source/texk/dvipdfm-x/pdffont.c
    trunk/Build/source/texk/dvipdfm-x/pdffont.h
    trunk/Build/source/texk/dvipdfm-x/tt_aux.c
    trunk/Build/source/texk/dvipdfm-x/tt_aux.h
    trunk/Build/source/texk/dvipdfm-x/tt_cmap.c
    trunk/Build/source/texk/dvipdfm-x/tt_cmap.h

Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-08-06 23:53:34 UTC (rev 56063)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-08-07 21:28:08 UTC (rev 56064)
@@ -1,3 +1,8 @@
+2020-08-08  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
+
+	* fontmap.[ch], pdffont.[ch], tt_aux.[ch], tt_cmap.[ch]:
+	Use uint32_t for TTC index.
+
 2020-07-31  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
 
 	* cid.c: Avoid accessing array elements exceeding max array index.

Modified: trunk/Build/source/texk/dvipdfm-x/fontmap.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/fontmap.c	2020-08-06 23:53:34 UTC (rev 56063)
+++ trunk/Build/source/texk/dvipdfm-x/fontmap.c	2020-08-07 21:28:08 UTC (rev 56064)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
     
     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -401,11 +401,7 @@
         WARN("Missing TTC index number...");
         return  -1;
       }
-      mrec->opt.index = atoi(q);
-      if (mrec->opt.index < 0) {
-        WARN("Invalid TTC index number: %s", q);
-        return  -1;
-      }
+      mrec->opt.index = strtoul(q, NULL, 10);
       RELEASE(q);
       break;
 
@@ -1222,7 +1218,7 @@
   opt->flags     = 0;
 
   if (*p == ':' && isdigit((unsigned char)*(p+1))) {
-    opt->index = (int) strtoul(p+1, &next, 10);
+    opt->index = strtoul(p+1, &next, 10);
     if (*next == ':')
       p = next + 1;
     else {

Modified: trunk/Build/source/texk/dvipdfm-x/fontmap.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/fontmap.h	2020-08-06 23:53:34 UTC (rev 56063)
+++ trunk/Build/source/texk/dvipdfm-x/fontmap.h	2020-08-07 21:28:08 UTC (rev 56064)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
     
     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -38,20 +38,20 @@
 /* Options */
 typedef struct fontmap_opt {
   /* Synthetic font */
-  double slant, extend, bold;
+  double    slant, extend, bold;
   /* comaptibility and other flags */
-  int    mapc,  flags;
+  int       mapc,  flags;
 
-  char  *otl_tags;    /* currently unused */
-  char  *tounicode;   /* not implemented yet */
+  char     *otl_tags;
+  char     *tounicode;   /* not implemented yet */
 
-  double design_size; /* unused */
+  double    design_size; /* unused */
 
-  char  *charcoll;    /* Adobe-Japan1-4, etc. */
-  int    index;       /* TTC index */
-  int    style;       /* ,Bold, etc. */
-  int    stemv;       /* StemV value especially for CJK fonts */
-  int    use_glyph_encoding; /* XeTeX support */
+  char     *charcoll;    /* Adobe-Japan1-4, etc. */
+  uint32_t  index;       /* TTC index */
+  int       style;       /* ,Bold, etc. */
+  int       stemv;       /* StemV value especially for CJK fonts */
+  int       use_glyph_encoding; /* XeTeX support */
 } fontmap_opt;
 
 typedef struct fontmap_rec {

Modified: trunk/Build/source/texk/dvipdfm-x/pdffont.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdffont.c	2020-08-06 23:53:34 UTC (rev 56063)
+++ trunk/Build/source/texk/dvipdfm-x/pdffont.c	2020-08-07 21:28:08 UTC (rev 56064)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2008-2018 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
+    Copyright (C) 2002-2020 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
     the dvipdfmx project team.
     
     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -102,7 +102,7 @@
   int      font_id;
 
   /* For simple font */
-  int      index;
+  uint32_t index;
   char    *fontname;
   char     uniqueID[7];
 
@@ -795,7 +795,7 @@
   return ((font->reference) ? 1 : 0);
 }
 
-int
+uint32_t
 pdf_font_get_index (pdf_font *font)
 {
   ASSERT(font);

Modified: trunk/Build/source/texk/dvipdfm-x/pdffont.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdffont.h	2020-08-06 23:53:34 UTC (rev 56063)
+++ trunk/Build/source/texk/dvipdfm-x/pdffont.h	2020-08-07 21:28:08 UTC (rev 56064)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
     
     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -87,7 +87,7 @@
 #endif /* 0 */
 extern double   pdf_font_get_param      (pdf_font *font, int type);
 
-extern int      pdf_font_get_index      (pdf_font *font);
+extern uint32_t pdf_font_get_index      (pdf_font *font);
 
 extern int      pdf_font_set_fontname   (pdf_font *font, const char *fontname);
 extern int      pdf_font_set_flags      (pdf_font *font, int flags);

Modified: trunk/Build/source/texk/dvipdfm-x/tt_aux.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/tt_aux.c	2020-08-06 23:53:34 UTC (rev 56063)
+++ trunk/Build/source/texk/dvipdfm-x/tt_aux.c	2020-08-07 21:28:08 UTC (rev 56064)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
     
     This program is free software; you can redistribute it and/or modify
@@ -35,7 +35,7 @@
 #include "tt_post.h"
 #include "tt_aux.h"
 
-ULONG ttc_read_offset (sfnt *sfont, int ttc_idx)
+ULONG ttc_read_offset (sfnt *sfont, ULONG ttc_idx)
 {
   ULONG offset = 0, num_dirs = 0;
   
@@ -49,7 +49,7 @@
 
   /* version = */ sfnt_get_ulong(sfont);
   num_dirs = sfnt_get_ulong(sfont);
-  if (ttc_idx < 0 || ttc_idx > num_dirs - 1)
+  if (ttc_idx > num_dirs - 1)
     ERROR("Invalid TTC index number");
 
   sfnt_seek_set (sfont, 12 + ttc_idx * 4);

Modified: trunk/Build/source/texk/dvipdfm-x/tt_aux.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/tt_aux.h	2020-08-06 23:53:34 UTC (rev 56063)
+++ trunk/Build/source/texk/dvipdfm-x/tt_aux.h	2020-08-07 21:28:08 UTC (rev 56064)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
     
     This program is free software; you can redistribute it and/or modify
@@ -24,10 +24,8 @@
 #include "pdfobj.h"
 #include "sfnt.h"
 
-extern int always_embed; /* flag declared in dvipdfmx.c */
-
 /* TTC (TrueType Collection) */
-extern ULONG    ttc_read_offset (sfnt *sfont, int ttc_idx);
+extern ULONG    ttc_read_offset (sfnt *sfont, ULONG ttc_idx);
 
 /* FontDescriptor */
 extern pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int stemv, int type, const char* fontname);

Modified: trunk/Build/source/texk/dvipdfm-x/tt_cmap.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/tt_cmap.c	2020-08-06 23:53:34 UTC (rev 56063)
+++ trunk/Build/source/texk/dvipdfm-x/tt_cmap.c	2020-08-07 21:28:08 UTC (rev 56064)
@@ -1066,7 +1066,7 @@
 
 pdf_obj *
 otf_create_ToUnicode_stream (const char *font_name,
-                             int         ttc_index, /* 0 for non-TTC */
+                             uint32_t    ttc_index, /* 0 for non-TTC */
                              const char *basefont,
                              const char *used_chars)
 {
@@ -1147,10 +1147,13 @@
    * case.
    */
   {
-    char *cmap_add_name;
+    char   *cmap_add_name;
+    size_t  len;
 
-    cmap_add_name = NEW(strlen(font_name)+strlen(",000-UCS32-Add")+1, char);
-    sprintf(cmap_add_name, "%s,%03d-UCS32-Add", font_name, ttc_index);
+    len = strlen(font_name)+strlen("-UCS32-Add")+32;
+    cmap_add_name = NEW(len, char);
+    snprintf(cmap_add_name, len, "%s:%d-UCS32-Add", font_name, ttc_index);
+    cmap_add_name[len-1] = '\0';
     cmap_add_id = CMap_cache_find(cmap_add_name);
     RELEASE(cmap_add_name);
     if (cmap_add_id < 0) {
@@ -1295,7 +1298,7 @@
 }
 
 int
-otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC font */
+otf_load_Unicode_CMap (const char *map_name, uint32_t ttc_index, /* 0 for non-TTC font */
                        const char *otl_tags, int wmode)
 {
   int         cmap_id     = -1;
@@ -1311,24 +1314,26 @@
   if (!map_name)
     return -1;
 
-  if (ttc_index > 999 || ttc_index < 0) {
-    return -1; /* Sorry for this... */
-  }
-
   /* First look for cache if it was already loaded */
-  cmap_name = NEW(strlen(map_name)+strlen("-UCS4-H")+5, char);
   if (otl_tags) {
-    cmap_name = NEW(strlen(map_name)+strlen(otl_tags)+strlen("-UCS4-H")+6, char);
+    size_t len;
+    len = strlen(map_name)+strlen("-UCS4-H")+strlen(otl_tags)+32;
+    cmap_name = NEW(len, char);
     if (wmode)
-      sprintf(cmap_name, "%s,%03d,%s-UCS4-V", map_name, ttc_index, otl_tags);
+      snprintf(cmap_name, len, "%s:%d:%s-UCS4-V", map_name, ttc_index, otl_tags);
     else
-      sprintf(cmap_name, "%s,%03d,%s-UCS4-H", map_name, ttc_index, otl_tags);
+      snprintf(cmap_name, len, "%s:%d:%s-UCS4-H", map_name, ttc_index, otl_tags);
+    cmap_name[len-1] = '\0';
   } else {
+    size_t len;
+    len = strlen(map_name)+strlen("-UCS4-H")+32;
+    cmap_name = NEW(len, char);
     if (wmode)
-      sprintf(cmap_name, "%s,%03d-UCS4-V", map_name, ttc_index);
+      snprintf(cmap_name, len, "%s:%d-UCS4-V", map_name, ttc_index);
     else {
-      sprintf(cmap_name, "%s,%03d-UCS4-H", map_name, ttc_index);
+      snprintf(cmap_name, len, "%s:%d-UCS4-H", map_name, ttc_index);
     }
+    cmap_name[len-1] = '\0';
   }
   cmap_id = CMap_cache_find(cmap_name);
   if (cmap_id >= 0) {
@@ -1542,12 +1547,15 @@
     tt_cmap_release(ttcmap);
  
     if (otl_tags) {
-      CMap *tounicode = NULL;
-      char *tounicode_name;
-      int   tounicode_id;
+      CMap  *tounicode = NULL;
+      char  *tounicode_name;
+      int    tounicode_id;
+      size_t name_len;
 
-      tounicode_name = NEW(strlen(map_name)+strlen(",000-UCS32-Add")+1, char);
-      sprintf(tounicode_name, "%s,%03d-UCS32-Add", map_name, ttc_index);
+      name_len = strlen(map_name)+strlen("-UCS32-Add")+32;
+      tounicode_name = NEW(name_len, char);
+      snprintf(tounicode_name, name_len, "%s:%d-UCS32-Add", map_name, ttc_index);
+      tounicode_name[name_len-1] = '\0';
       tounicode_id = CMap_cache_find(tounicode_name);
       if (tounicode_id >= 0)
         tounicode = CMap_cache_get(tounicode_id);
@@ -1598,7 +1606,7 @@
 }
 
 int
-otf_try_load_GID_to_CID_map (const char *map_name, int ttc_index, int wmode)
+otf_try_load_GID_to_CID_map (const char *map_name, uint32_t ttc_index, int wmode)
 {
   int         cmap_id     = -1;
   sfnt       *sfont       = NULL;
@@ -1610,10 +1618,6 @@
   if (!map_name)
     return -1;
 
-  if (ttc_index > 0xFFFFFFFFu || ttc_index < 0) {
-    return -1;
-  }
-
   /* Check if already loaded */
   len = strlen(map_name) + 32;
   cmap_name = NEW(len, char);

Modified: trunk/Build/source/texk/dvipdfm-x/tt_cmap.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/tt_cmap.h	2020-08-06 23:53:34 UTC (rev 56063)
+++ trunk/Build/source/texk/dvipdfm-x/tt_cmap.h	2020-08-07 21:28:08 UTC (rev 56064)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
     
     This program is free software; you can redistribute it and/or modify
@@ -65,12 +65,10 @@
 
 /* Indirect reference */
 extern pdf_obj *otf_create_ToUnicode_stream (const char *map_name,
-                                             int ttc_index,
+                                             uint32_t    ttc_index,
                                              const char *basefont,
                                              const char *used_chars);
 /* CMap ID */
-extern int  otf_load_Unicode_CMap (const char *map_name,
-					                         int ttc_index,
-					                         const char *otl_opts, int wmode);
-extern int  otf_try_load_GID_to_CID_map (const char *map_name, int ttc_index, int wmode);
+extern int  otf_load_Unicode_CMap (const char *map_name, uint32_t ttc_index, const char *otl_opts, int wmode);
+extern int  otf_try_load_GID_to_CID_map (const char *map_name, uint32_t ttc_index, int wmode);
 #endif /* _TT_CMAP_H_ */



More information about the tex-live-commits mailing list.