summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/dvipdfm-x/ChangeLog6
-rw-r--r--Build/source/texk/dvipdfm-x/tt_cmap.c8
-rw-r--r--Build/source/texk/dvipdfm-x/unicode.c20
3 files changed, 22 insertions, 12 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog
index 2ddcc83c16e..1cbf71d70fc 100644
--- a/Build/source/texk/dvipdfm-x/ChangeLog
+++ b/Build/source/texk/dvipdfm-x/ChangeLog
@@ -1,3 +1,9 @@
+2019-05-07 Shunsaku Hirata <shunsaku.hirata74@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@gmail.com>
* pdfdoc.c: g option affects only annotations created by
diff --git a/Build/source/texk/dvipdfm-x/tt_cmap.c b/Build/source/texk/dvipdfm-x/tt_cmap.c
index a05adca7fc7..539024ed6e5 100644
--- a/Build/source/texk/dvipdfm-x/tt_cmap.c
+++ b/Build/source/texk/dvipdfm-x/tt_cmap.c
@@ -640,7 +640,6 @@ create_GIDToCIDMap (uint16_t *GIDToCIDMap, uint16_t num_glyphs, cff_font *cffont
memset(GIDToCIDMap, 0, num_glyphs*sizeof(uint16_t));
- cff_read_charsets(cffont);
charset = cffont->charsets;
if (!charset)
return;
@@ -939,6 +938,7 @@ create_ToUnicode_cmap (tt_cmap *ttcmap,
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 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon
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 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon
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 @@ otf_try_load_GID_to_CID_map (const char *map_name, int ttc_index, int wmode)
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);
diff --git a/Build/source/texk/dvipdfm-x/unicode.c b/Build/source/texk/dvipdfm-x/unicode.c
index 24f0e0af067..981fc123aac 100644
--- a/Build/source/texk/dvipdfm-x/unicode.c
+++ b/Build/source/texk/dvipdfm-x/unicode.c
@@ -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@kettering.edu>
@@ -123,7 +123,7 @@ UC_UTF16BE_encode_char (int32_t ucv, unsigned char **pp, unsigned char *endptr)
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 @@ UC_UTF16BE_encode_char (int32_t ucv, unsigned char **pp, unsigned char *endptr)
} 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 @@ UC_UTF16BE_encode_char (int32_t ucv, unsigned char **pp, unsigned char *endptr)
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,25 +207,25 @@ UC_UTF8_encode_char (int32_t ucv, unsigned char **pp, unsigned char *endptr)
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));
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 @@ UC_UTF8_encode_char (int32_t ucv, unsigned char **pp, unsigned char *endptr)
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 @@ UC_UTF8_encode_char (int32_t ucv, unsigned char **pp, unsigned char *endptr)
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));