summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2013-02-21 18:25:07 +0000
committerKhaled Hosny <khaledhosny@eglug.org>2013-02-21 18:25:07 +0000
commit95680f656950d7174b0db6bdc1bacc38e92ebd65 (patch)
tree0c0a7a2424ce87103d777cc6f4a0b67cce1c2656 /Build
parent03686fa0451b803da7a3aed60b3f41ffadb5e63a (diff)
Get glyph name from FreeType
Instead of reading 'post' table directly, this should handle CFF fonts where the 'post' table has no glyph names. git-svn-id: svn://tug.org/texlive/trunk@29188 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/xdvipdfmx/ChangeLog5
-rw-r--r--Build/source/texk/xdvipdfmx/src/tt_cmap.c79
2 files changed, 45 insertions, 39 deletions
diff --git a/Build/source/texk/xdvipdfmx/ChangeLog b/Build/source/texk/xdvipdfmx/ChangeLog
index 1db8ddeddf6..de8443704a8 100644
--- a/Build/source/texk/xdvipdfmx/ChangeLog
+++ b/Build/source/texk/xdvipdfmx/ChangeLog
@@ -1,3 +1,8 @@
+2013-02-21 Khaled Hosny <khaledhosny@eglug.org>
+
+ * src/tt_cmap.c: Use FT_Get_Glyph_Name() instead of reading 'post' table
+ directly, to handle CFF fonts where the 'post' table has no glyph names.
+
2013-02-15 Khaled Hosny <khaledhosny@eglug.org>
* src/cidtype2.c: Fix loading *.dfont files on non-Mac platforms.
diff --git a/Build/source/texk/xdvipdfmx/src/tt_cmap.c b/Build/source/texk/xdvipdfmx/src/tt_cmap.c
index 614d26ad72e..441789239f6 100644
--- a/Build/source/texk/xdvipdfmx/src/tt_cmap.c
+++ b/Build/source/texk/xdvipdfmx/src/tt_cmap.c
@@ -43,7 +43,6 @@
#include "tt_aux.h"
#include "tt_gsub.h"
-#include "tt_post.h"
#include "unicode.h"
#include "agl.h"
@@ -848,7 +847,7 @@ handle_CIDFont (sfnt *sfont,
static USHORT
handle_subst_glyphs (CMap *cmap,
CMap *cmap_add, const char *used_glyphs,
- struct tt_post_table *post)
+ sfnt *sfont)
{
USHORT count;
USHORT i, gid;
@@ -868,33 +867,41 @@ handle_subst_glyphs (CMap *cmap,
if (!is_used_char2(used_glyphs, gid))
continue;
- if (!cmap_add && post) {
- /* JK: try to look up Unicode values from the glyph name...
- requires access to 'post' table */
+ 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
- long unicodes[MAX_UNICODES];
- int unicode_count = -1;
- int k;
- if (gid < post->numberOfGlyphs && post->glyphNamePtr[gid] != NULL) {
- unicode_count = agl_get_unicodes(post->glyphNamePtr[gid], unicodes, MAX_UNICODES);
- }
- if (unicode_count == -1)
- MESG("No Unicode mapping available: GID=%u, name=%s\n", gid,
- gid < post->numberOfGlyphs ? post->glyphNamePtr[gid] : "(none)");
- 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;
- 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);
+#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) {
+ WARN("No Unicode mapping available: GID=%u, name=%s", 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 {
+#else
+ WARN("No Unicode mapping available: GID=%u", gid);
+#endif
+ } else {
wbuf[0] = (gid >> 8) & 0xff;
wbuf[1] = gid & 0xff;
inbuf = wbuf;
@@ -934,7 +941,7 @@ static pdf_obj *
create_ToUnicode_cmap4 (struct cmap4 *map,
const char *cmap_name, CMap *cmap_add,
const char *used_glyphs,
- struct tt_post_table *post)
+ sfnt *sfont)
{
pdf_obj *stream = NULL;
CMap *cmap;
@@ -988,7 +995,7 @@ create_ToUnicode_cmap4 (struct cmap4 *map,
}
}
- count += handle_subst_glyphs(cmap, cmap_add, used_glyphs_copy, post);
+ count += handle_subst_glyphs(cmap, cmap_add, used_glyphs_copy, sfont);
if (count < 1)
stream = NULL;
@@ -1005,7 +1012,7 @@ static pdf_obj *
create_ToUnicode_cmap12 (struct cmap12 *map,
const char *cmap_name, CMap *cmap_add,
const char *used_glyphs,
- struct tt_post_table *post)
+ sfnt *sfont)
{
pdf_obj *stream = NULL;
CMap *cmap;
@@ -1043,7 +1050,7 @@ create_ToUnicode_cmap12 (struct cmap12 *map,
}
}
- count += handle_subst_glyphs(cmap, cmap_add, used_glyphs_copy, post);
+ count += handle_subst_glyphs(cmap, cmap_add, used_glyphs_copy, sfont);
if (count < 1)
stream = NULL;
@@ -1085,7 +1092,6 @@ otf_create_ToUnicode_stream (const char *font_name,
FILE *fp = NULL;
sfnt *sfont;
long offset = 0;
- struct tt_post_table *ttpost = NULL;
int i;
/* replace slash in map name with dash to make the output cmap name valid,
@@ -1157,8 +1163,6 @@ otf_create_ToUnicode_stream (const char *font_name,
cmap_add = CMap_cache_get(cmap_add_id);
}
- ttpost = tt_read_post_table(sfont);
-
CMap_set_silent(1); /* many warnings without this... */
for (i = 0; i < sizeof(cmap_plat_encs) / sizeof(cmap_plat_enc_rec); ++i) {
ttcmap = tt_cmap_read(sfont, cmap_plat_encs[i].platform, cmap_plat_encs[i].encoding);
@@ -1166,12 +1170,12 @@ otf_create_ToUnicode_stream (const char *font_name,
continue;
if (ttcmap->format == 4) {
cmap_obj = create_ToUnicode_cmap4(ttcmap->map,
- cmap_name, cmap_add, used_glyphs, ttpost);
+ cmap_name, cmap_add, used_glyphs, sfont);
break;
}
if (ttcmap->format == 12) {
cmap_obj = create_ToUnicode_cmap12(ttcmap->map,
- cmap_name, cmap_add, used_glyphs, ttpost);
+ cmap_name, cmap_add, used_glyphs, sfont);
break;
}
}
@@ -1180,9 +1184,6 @@ otf_create_ToUnicode_stream (const char *font_name,
tt_cmap_release(ttcmap);
CMap_set_silent(0);
- if (ttpost != NULL)
- tt_release_post_table(ttpost);
-
if (cmap_obj) {
res_id = pdf_defineresource("CMap", cmap_name,
cmap_obj, PDF_RES_FLUSH_IMMEDIATE);