diff options
Diffstat (limited to 'Build/source/texk/dvipdfm-x/src/tt_cmap.c')
-rw-r--r-- | Build/source/texk/dvipdfm-x/src/tt_cmap.c | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/Build/source/texk/dvipdfm-x/src/tt_cmap.c b/Build/source/texk/dvipdfm-x/src/tt_cmap.c index 9761e92de25..da68af19787 100644 --- a/Build/source/texk/dvipdfm-x/src/tt_cmap.c +++ b/Build/source/texk/dvipdfm-x/src/tt_cmap.c @@ -860,9 +860,41 @@ handle_subst_glyphs (CMap *cmap, if (!is_used_char2(used_glyphs, gid)) continue; - if (!cmap_add) + if (!cmap_add) { +#if XETEX + if (FT_HAS_GLYPH_NAMES(sfont->ft_face)) { + /* JK: try to look up Unicode values from the glyph name... */ +#define MAX_UNICODES 16 +#define MAX_NAME 256 + static char name[MAX_NAME] = "(none)"; + long unicodes[MAX_UNICODES]; + int unicode_count = -1; + FT_Error err = FT_Get_Glyph_Name(sfont->ft_face, gid, name, MAX_NAME); + if (!err) { + unicode_count = agl_get_unicodes(name, unicodes, MAX_UNICODES); + } +#undef MAX_UNICODES +#undef MAX_NAME + if (unicode_count == -1) { + MESG("No Unicode mapping available: GID=%u, name=%s\n", gid, name); + } else { + /* the Unicode characters go into wbuf[2] and following, in UTF16BE */ + /* we rely on WBUF_SIZE being more than adequate for MAX_UNICODES */ + unsigned char* p = wbuf + 2; + int k; + len = 0; + for (k = 0; k < unicode_count; ++k) { + len += UC_sput_UTF16BE(unicodes[k], &p, wbuf+WBUF_SIZE); + } + wbuf[0] = (gid >> 8) & 0xff; + wbuf[1] = gid & 0xff; + CMap_add_bfchar(cmap, wbuf, 2, wbuf + 2, len); + } + } +#else WARN("No Unicode mapping available: GID=%u", gid); - else { +#endif + } else { wbuf[0] = (gid >> 8) & 0xff; wbuf[1] = gid & 0xff; inbuf = wbuf; @@ -1018,6 +1050,21 @@ create_ToUnicode_cmap12 (struct cmap12 *map, return stream; } +#ifdef XETEX +typedef struct { + short platform; + short encoding; +} cmap_plat_enc_rec; + +static cmap_plat_enc_rec cmap_plat_encs[] = { + { 3, 10 }, + { 0, 3 }, + { 0, 0 }, + { 3, 1 }, + { 0, 1 } +}; +#endif + pdf_obj * otf_create_ToUnicode_stream (const char *font_name, int ttc_index, /* 0 for non-TTC */ @@ -1039,7 +1086,6 @@ otf_create_ToUnicode_stream (const char *font_name, long offset = 0; int i; - /* replace slash in map name with dash to make the output cmap name valid, * happens when XeTeX embeds full font path * https://sourceforge.net/p/xetex/bugs/52/ @@ -1638,6 +1684,10 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon return -1; /* Sorry for this... */ } +#ifdef XETEX + fprintf(stderr, "otf_load_Unicode_CMap(%s, %d)\n", map_name, ttc_index); + sfont = NULL; /* FIXME */ +#else fp = DPXFOPEN(map_name, DPX_RES_TYPE_TTFONT); if (!fp) { fp = DPXFOPEN(map_name, DPX_RES_TYPE_OTFONT); @@ -1649,6 +1699,7 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon } else { sfont = sfnt_open(fp); } +#endif if (!sfont) { ERROR("Could not open OpenType/TrueType/dfont font file \"%s\"", map_name); |