diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2014-07-27 23:04:49 +0000 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2014-07-27 23:04:49 +0000 |
commit | 5795568a60dba76e57cdb78fda5aab4e6e135991 (patch) | |
tree | 0a2586ae809d714303ed3a6b76b623765af408bd /Build/source/texk/dvipdfm-x/pdfdev.c | |
parent | 378fc061ff4879abb4983d8e48f593f1b4b779d9 (diff) |
Fix CID-keyed fonts glyph lookup
Keep cff_charsets parsed from CID font around if exists. Use the
cff_charsets to do GID -> CID lookup.
git-svn-id: svn://tug.org/texlive/trunk@34743 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdfm-x/pdfdev.c')
-rw-r--r-- | Build/source/texk/dvipdfm-x/pdfdev.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Build/source/texk/dvipdfm-x/pdfdev.c b/Build/source/texk/dvipdfm-x/pdfdev.c index 7d27b913fe9..6fa42237542 100644 --- a/Build/source/texk/dvipdfm-x/pdfdev.c +++ b/Build/source/texk/dvipdfm-x/pdfdev.c @@ -52,6 +52,8 @@ #include "pdfdev.h" +#include "cff.h" + static int verbose = 0; void @@ -493,6 +495,8 @@ struct dev_font { int ucs_plane; int is_unicode; + + cff_charsets *cff_charsets; }; static struct dev_font *dev_fonts = NULL; @@ -954,8 +958,26 @@ handle_multibyte_string (struct dev_font *font, p = *str_ptr; length = *str_len; + if (ctype == -1 && font->cff_charsets) { /* freetype glyph indexes */ + /* Convert freetype glyph indexes to CID. */ + const unsigned char *inbuf = p; + unsigned char *outbuf = sbuf0; + for (i = 0; i < length; i += 2) { + unsigned int gid; + gid = *inbuf++ << 8; + gid += *inbuf++; + + gid = cff_charsets_lookup_cid(font->cff_charsets, gid); + + *outbuf++ = gid >> 8; + *outbuf++ = gid & 0xff; + } + + p = sbuf0; + length = outbuf - sbuf0; + } /* _FIXME_ */ - if (font->is_unicode) { /* UCS-4 */ + else if (font->is_unicode) { /* UCS-4 */ if (ctype == 1) { if (length * 4 >= FORMAT_BUF_SIZE) { WARN("Too long string..."); @@ -1291,8 +1313,11 @@ pdf_close_device (void) RELEASE(dev_fonts[i].tex_name); if (dev_fonts[i].resource) pdf_release_obj(dev_fonts[i].resource); + if (dev_fonts[i].cff_charsets) + cff_release_charsets(dev_fonts[i].cff_charsets); dev_fonts[i].tex_name = NULL; dev_fonts[i].resource = NULL; + dev_fonts[i].cff_charsets = NULL; } RELEASE(dev_fonts); } @@ -1474,6 +1499,8 @@ pdf_dev_locate_font (const char *font_name, spt_t ptsize) if (font->font_id < 0) return -1; + font->cff_charsets = mrec->opt.cff_charsets; + /* We found device font here. */ if (i < num_dev_fonts) { font->real_font_index = i; |