summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvipdfm-x
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-08-07 21:28:08 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-08-07 21:28:08 +0000
commit275f43d792961c3e02cbf06b46eb3f99d105ec6f (patch)
treef31f639d2a79199a7c956aff0f2b267dae9d20ea /Build/source/texk/dvipdfm-x
parent151be1c527f048ec037f1ccd83e08857bb9726cd (diff)
Use uint32_t for TTC index. (S. Hirata)
git-svn-id: svn://tug.org/texlive/trunk@56064 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdfm-x')
-rw-r--r--Build/source/texk/dvipdfm-x/ChangeLog5
-rw-r--r--Build/source/texk/dvipdfm-x/fontmap.c10
-rw-r--r--Build/source/texk/dvipdfm-x/fontmap.h22
-rw-r--r--Build/source/texk/dvipdfm-x/pdffont.c6
-rw-r--r--Build/source/texk/dvipdfm-x/pdffont.h4
-rw-r--r--Build/source/texk/dvipdfm-x/tt_aux.c6
-rw-r--r--Build/source/texk/dvipdfm-x/tt_aux.h6
-rw-r--r--Build/source/texk/dvipdfm-x/tt_cmap.c56
-rw-r--r--Build/source/texk/dvipdfm-x/tt_cmap.h10
9 files changed, 63 insertions, 62 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog
index 1a3acabefee..a63ceeb00fe 100644
--- a/Build/source/texk/dvipdfm-x/ChangeLog
+++ b/Build/source/texk/dvipdfm-x/ChangeLog
@@ -1,3 +1,8 @@
+2020-08-08 Shunsaku Hirata <shunsaku.hirata74@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@gmail.com>
* cid.c: Avoid accessing array elements exceeding max array index.
diff --git a/Build/source/texk/dvipdfm-x/fontmap.c b/Build/source/texk/dvipdfm-x/fontmap.c
index 92e6b7d8829..9647fe453da 100644
--- a/Build/source/texk/dvipdfm-x/fontmap.c
+++ b/Build/source/texk/dvipdfm-x/fontmap.c
@@ -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@kettering.edu>
@@ -401,11 +401,7 @@ fontmap_parse_mapdef_dpm (fontmap_rec *mrec,
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 @@ strip_options (const char *map_name, fontmap_opt *opt)
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 {
diff --git a/Build/source/texk/dvipdfm-x/fontmap.h b/Build/source/texk/dvipdfm-x/fontmap.h
index a144aa418c6..64932127e89 100644
--- a/Build/source/texk/dvipdfm-x/fontmap.h
+++ b/Build/source/texk/dvipdfm-x/fontmap.h
@@ -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@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 {
diff --git a/Build/source/texk/dvipdfm-x/pdffont.c b/Build/source/texk/dvipdfm-x/pdffont.c
index d957977e05c..5e38733d3c8 100644
--- a/Build/source/texk/dvipdfm-x/pdffont.c
+++ b/Build/source/texk/dvipdfm-x/pdffont.c
@@ -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@kettering.edu>
@@ -102,7 +102,7 @@ struct pdf_font
int font_id;
/* For simple font */
- int index;
+ uint32_t index;
char *fontname;
char uniqueID[7];
@@ -795,7 +795,7 @@ pdf_font_is_in_use (pdf_font *font)
return ((font->reference) ? 1 : 0);
}
-int
+uint32_t
pdf_font_get_index (pdf_font *font)
{
ASSERT(font);
diff --git a/Build/source/texk/dvipdfm-x/pdffont.h b/Build/source/texk/dvipdfm-x/pdffont.h
index de6b9cf2b3e..65ba9d6fda0 100644
--- a/Build/source/texk/dvipdfm-x/pdffont.h
+++ b/Build/source/texk/dvipdfm-x/pdffont.h
@@ -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@kettering.edu>
@@ -87,7 +87,7 @@ extern int pdf_font_get_flags (pdf_font *font);
#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);
diff --git a/Build/source/texk/dvipdfm-x/tt_aux.c b/Build/source/texk/dvipdfm-x/tt_aux.c
index 06b9c0b4a21..2d4b352cff7 100644
--- a/Build/source/texk/dvipdfm-x/tt_aux.c
+++ b/Build/source/texk/dvipdfm-x/tt_aux.c
@@ -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 @@ ULONG ttc_read_offset (sfnt *sfont, int ttc_idx)
/* 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);
diff --git a/Build/source/texk/dvipdfm-x/tt_aux.h b/Build/source/texk/dvipdfm-x/tt_aux.h
index 33e8e7c2d95..cc41fd18e92 100644
--- a/Build/source/texk/dvipdfm-x/tt_aux.h
+++ b/Build/source/texk/dvipdfm-x/tt_aux.h
@@ -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);
diff --git a/Build/source/texk/dvipdfm-x/tt_cmap.c b/Build/source/texk/dvipdfm-x/tt_cmap.c
index 113d11699a5..17c1e9924dd 100644
--- a/Build/source/texk/dvipdfm-x/tt_cmap.c
+++ b/Build/source/texk/dvipdfm-x/tt_cmap.c
@@ -1066,7 +1066,7 @@ static cmap_plat_enc_rec cmap_plat_encs[] = {
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 @@ otf_create_ToUnicode_stream (const char *font_name,
* 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 @@ load_cmap12 (struct cmap12 *map, uint16_t *GIDToCIDMap, USHORT num_glyphs,
}
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 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon
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 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon
tt_cmap_release(ttcmap);
if (otl_tags) {
- CMap *tounicode = NULL;
- char *tounicode_name;
- int tounicode_id;
-
- tounicode_name = NEW(strlen(map_name)+strlen(",000-UCS32-Add")+1, char);
- sprintf(tounicode_name, "%s,%03d-UCS32-Add", map_name, ttc_index);
+ CMap *tounicode = NULL;
+ char *tounicode_name;
+ int tounicode_id;
+ size_t name_len;
+
+ 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 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon
}
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 @@ otf_try_load_GID_to_CID_map (const char *map_name, int ttc_index, int wmode)
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);
diff --git a/Build/source/texk/dvipdfm-x/tt_cmap.h b/Build/source/texk/dvipdfm-x/tt_cmap.h
index 08333d6afb5..439108c4797 100644
--- a/Build/source/texk/dvipdfm-x/tt_cmap.h
+++ b/Build/source/texk/dvipdfm-x/tt_cmap.h
@@ -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 @@ extern void tt_cmap_release (tt_cmap *cmap);
/* 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_ */