From 7bc7c6ad12be2d2ae1c800398ce0593dad063ef9 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Sun, 21 Jun 2020 02:26:45 +0000 Subject: Lower priority of Soft-hyphen when generating ToUnicode. Show an error when "CFF " table could not be found for a PS OpenType font. (S. Hirata) git-svn-id: svn://tug.org/texlive/trunk@55615 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipdfm-x/ChangeLog | 8 ++++++++ Build/source/texk/dvipdfm-x/tt_cmap.c | 28 +++++++++++++++++++++++++--- Build/source/texk/dvipdfm-x/type1c.c | 4 ++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index dd4b5eef5fd..e7ded141cb1 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,3 +1,11 @@ +2020-06-21 Shunsaku Hirata + + * tt_cmap.c: Lower priority for Soft-hyphen U+00AD when + generating ToUnicode CMap. + * tt_cmap.c, type1c.c: Cause an error when "CFF " table is not + found. (Possibly due to variable font which uses unsupported + "CFF2" table) + 2020-06-09 Hironobu Yamashita * pdfdev.c: Another workaround for fake-bold issue. diff --git a/Build/source/texk/dvipdfm-x/tt_cmap.c b/Build/source/texk/dvipdfm-x/tt_cmap.c index 539024ed6e5..cff28f2b690 100644 --- a/Build/source/texk/dvipdfm-x/tt_cmap.c +++ b/Build/source/texk/dvipdfm-x/tt_cmap.c @@ -705,6 +705,7 @@ create_GIDToCIDMap (uint16_t *GIDToCIDMap, uint16_t num_glyphs, cff_font *cffont return; } +/* Soft-hyphen (U+00AD) to lower its priority... added here for convenience */ static int is_PUA_or_presentation (unsigned int uni) { /* Some of CJK Radicals Supplement and Kangxi Radicals @@ -714,7 +715,8 @@ static int is_PUA_or_presentation (unsigned int uni) return ((uni >= 0x2E80 && uni <= 0x2EF3) || (uni >= 0x2F00 && uni <= 0x2FD5) || (uni >= 0xE000 && uni <= 0xF8FF) || (uni >= 0xFB00 && uni <= 0xFB4F) || (uni >= 0xF900 && uni <= 0xFAFF) || (uni >= 0x2F800 && uni <= 0x2FA1F) || - (uni >= 0xF0000 && uni <= 0xFFFFD) || (uni >= 0x100000 && uni <= 0x10FFFD)); + (uni >= 0xF0000 && uni <= 0xFFFFD) || (uni >= 0x100000 && uni <= 0x10FFFD) || + (uni == 0x00AD)); } static char * @@ -937,6 +939,10 @@ create_ToUnicode_cmap (tt_cmap *ttcmap, if (sfont->type == SFNT_TYPE_POSTSCRIPT) { ULONG offset; offset = sfnt_find_table_pos(sfont, "CFF "); + /* "CFF " table must exist here. Just abort... */ + if (offset == 0) { + ERROR("\"CFF \" table not found. Must be found before... Can't continue."); + } cffont = cff_open(sfont->stream, offset, 0); cff_read_charsets(cffont); } @@ -1410,7 +1416,16 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon cff_font *cffont; card16 gid; - offset = sfnt_find_table_pos(sfont, "CFF "); + offset = sfnt_find_table_pos(sfont, "CFF "); + /* Possibly "CFF2" table for variable font: not supported. */ + if (offset == 0) { + WARN("PS OpenType but no \"CFF \" table.. Maybe variable font? (not supported)"); + RELEASE(cmap_name); + RELEASE(GIDToCIDMap); + sfnt_close(sfont); + DPXFCLOSE(fp); + return -1; + } cffont = cff_open(sfont->stream, offset, 0); if (!cffont) { RELEASE(cmap_name); @@ -1682,7 +1697,14 @@ otf_try_load_GID_to_CID_map (const char *map_name, int ttc_index, int wmode) num_glyphs = (card16) maxp->numGlyphs; RELEASE(maxp); - offset = sfnt_find_table_pos(sfont, "CFF "); + offset = sfnt_find_table_pos(sfont, "CFF "); + if (offset == 0) { + WARN("PS OpenType but no \"CFF \" table.. Maybe variable font? (not supported)"); + RELEASE(cmap_name); + sfnt_close(sfont); + DPXFCLOSE(fp); + return -1; + } cffont = cff_open(sfont->stream, offset, 0); if (cffont && cffont->flag & FONTTYPE_CIDFONT) { CMap *cmap; diff --git a/Build/source/texk/dvipdfm-x/type1c.c b/Build/source/texk/dvipdfm-x/type1c.c index fb45f9c9422..b7619af6138 100644 --- a/Build/source/texk/dvipdfm-x/type1c.c +++ b/Build/source/texk/dvipdfm-x/type1c.c @@ -94,7 +94,7 @@ pdf_font_open_type1c (pdf_font *font) offset = sfnt_find_table_pos(sfont, "CFF "); if (offset < 1) { - ERROR("No \"CFF \" table found; not a CFF/OpenType font (10)?"); + ERROR("No \"CFF \" table found; not a CFF/OpenType font (or variable font?) (10)?"); } cffont = cff_open(sfont->stream, offset, 0); @@ -296,7 +296,7 @@ pdf_font_load_type1c (pdf_font *font) } if (sfont->type != SFNT_TYPE_POSTSCRIPT || (offset = sfnt_find_table_pos(sfont, "CFF ")) == 0) { - ERROR("Not a CFF/OpenType font (11)?"); + ERROR("Not a CFF/OpenType font (or variable font?) (11)?"); } cffont = cff_open(fp, offset, 0); -- cgit v1.2.3