diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2014-07-25 13:56:32 +0000 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2014-07-25 13:56:32 +0000 |
commit | 31053cc388d6f0b348b297a3a0b950e8d707916a (patch) | |
tree | ae93721619df1a0a9c1b422e7d702d46c5aa7f1d | |
parent | c953c51fc011990ac2c82ef8b88f7acf33781d2d (diff) |
Revert "Support CID-keyed OpenType fonts in xdvipdfmx (from Jiang Jiang)"
This reverts commit bf7b0213f14c179b2df004cf6ee134a4b8ae4f99.
git-svn-id: svn://tug.org/texlive/trunk@34717 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/dvipdfm-x/ChangeLog | 5 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/cff.c | 6 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/pdfdev.c | 33 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/pdffont.c | 28 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/pdffont.h | 2 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/tt_cmap.c | 24 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/type0.c | 98 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/type0.h | 1 |
8 files changed, 38 insertions, 159 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index b4fec2eb3e1..cca422e00d7 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,8 +1,3 @@ -2014-07-23 Jiang Jiang <gzjjgod@gmail.com> - - * cff.c, pdfdev.c, pdffont.c, pdffont.h, tt_cmap.c, type0.c, type0.h: - Support CID-keyed OpenType fonts. - 2014-07-22 Khaled Hosny <khaledhosny@eglug.org> * src/dvi.c, src/dvicodes.h: Support DVI-IVD inspired text reflection diff --git a/Build/source/texk/dvipdfm-x/cff.c b/Build/source/texk/dvipdfm-x/cff.c index 40ff4648ce7..7a54e3fecfd 100644 --- a/Build/source/texk/dvipdfm-x/cff.c +++ b/Build/source/texk/dvipdfm-x/cff.c @@ -326,13 +326,9 @@ cff_get_index_header (cff_font *cff) ERROR("invalid offsize data"); idx->offset = NEW(count+1, l_offset); - for (i=0;i<count;i++) { + for (i=0;i<count+1;i++) { (idx->offset)[i] = get_offset(cff->SFONT_OR_STREAM, idx->offsize); } - if (count == 0xFFFF) - cff_seek(cff, cff_tell(cff) + idx->offsize); - else - (idx->offset)[i] = get_offset(cff->SFONT_OR_STREAM, idx->offsize); if (idx->offset[0] != 1) ERROR("cff_get_index(): invalid index data"); diff --git a/Build/source/texk/dvipdfm-x/pdfdev.c b/Build/source/texk/dvipdfm-x/pdfdev.c index 593a9890cf5..54f1a9aa457 100644 --- a/Build/source/texk/dvipdfm-x/pdfdev.c +++ b/Build/source/texk/dvipdfm-x/pdfdev.c @@ -52,10 +52,6 @@ #include "pdfdev.h" -#ifdef XETEX -#include FT_CID_H -#endif - static int verbose = 0; void @@ -461,7 +457,6 @@ struct dev_font { int enc_id; #ifdef XETEX unsigned short *ft_to_gid; - FT_Bool is_cid_keyed; #endif /* if >= 0, index of a dev_font that really has the resource and used_chars */ @@ -469,7 +464,6 @@ struct dev_font { pdf_obj *resource; char *used_chars; - char *used_glyphs; /* Font format: * simple, composite or bitmap. @@ -881,10 +875,6 @@ dev_set_font (int font_id) if (!real_font->resource) { real_font->resource = pdf_get_font_reference(real_font->font_id); real_font->used_chars = pdf_get_font_usedchars(real_font->font_id); -#ifdef XETEX - if (real_font->is_cid_keyed) - real_font->used_glyphs = pdf_get_font_usedglyphs(real_font->font_id); -#endif } if (!real_font->used_on_this_page) { @@ -969,22 +959,15 @@ handle_multibyte_string (struct dev_font *font, #ifdef XETEX if (ctype == -1) { /* freetype glyph indexes */ - if (font->ft_to_gid || font->is_cid_keyed) { + if (font->ft_to_gid) { /* convert freetype glyph indexes to physical GID */ const unsigned char *inbuf = p; unsigned char *outbuf = sbuf0; - FT_Face face = pdf_font_get_ft_face(pdf_get_font(font->font_id)); for (i = 0; i < length; i += 2) { unsigned int gid; gid = *inbuf++ << 8; gid += *inbuf++; - if (font->is_cid_keyed) { - FT_UInt cid = 0; - FT_Get_CID_From_Glyph_Index(face, gid, &cid); - gid = cid; - } else { - gid = font->ft_to_gid[gid]; - } + gid = font->ft_to_gid[gid]; *outbuf++ = gid >> 8; *outbuf++ = gid & 0xff; } @@ -1173,11 +1156,6 @@ pdf_dev_set_string (spt_t xpos, spt_t ypos, length = instr_len; if (font->format == PDF_FONTTYPE_COMPOSITE) { - if (real_font->used_glyphs != NULL) { - for (i = 0; i < length; i += 2) - add_to_used_chars2(real_font->used_glyphs, - (unsigned short) (str_ptr[i] << 8)|str_ptr[i+1]); - } if (handle_multibyte_string(font, &str_ptr, &length, ctype) < 0) { ERROR("Error in converting input string..."); return; @@ -1553,17 +1531,10 @@ pdf_dev_locate_font (const char *font_name, spt_t ptsize) font->enc_id = pdf_get_font_encoding(font->font_id); #ifdef XETEX font->ft_to_gid = pdf_get_font_ft_to_gid(font->font_id); - - font->is_cid_keyed = 0; - { - FT_Face face = pdf_font_get_ft_face(pdf_get_font(font->font_id)); - FT_Get_CID_Is_Internally_CID_Keyed(face, &font->is_cid_keyed); - } #endif font->resource = NULL; /* Don't ref obj until font is actually used. */ font->used_chars = NULL; - font->used_glyphs = NULL; font->extend = 1.0; font->slant = 0.0; diff --git a/Build/source/texk/dvipdfm-x/pdffont.c b/Build/source/texk/dvipdfm-x/pdffont.c index 2bea295e7d8..570e0663301 100644 --- a/Build/source/texk/dvipdfm-x/pdffont.c +++ b/Build/source/texk/dvipdfm-x/pdffont.c @@ -343,24 +343,6 @@ pdf_get_font_usedchars (int font_id) } } -char * -pdf_get_font_usedglyphs (int font_id) -{ - pdf_font *font; - - CHECK_ID(font_id); - - font = GET_FONT(font_id); - if (font->subtype == PDF_FONT_FONTTYPE_TYPE0) { - Type0Font *t0font; - - t0font = Type0Font_cache_get(font->font_id); - return Type0Font_get_usedglyphs(t0font); - } - - return NULL; -} - int pdf_get_font_wmode (int font_id) { @@ -379,16 +361,6 @@ pdf_get_font_wmode (int font_id) } } -pdf_font * -pdf_get_font (int font_id) -{ - pdf_font *font; - - CHECK_ID(font_id); - - return GET_FONT(font_id); -} - int pdf_get_font_subtype (int font_id) { diff --git a/Build/source/texk/dvipdfm-x/pdffont.h b/Build/source/texk/dvipdfm-x/pdffont.h index d2afc7a7a3f..6d3ea72b56f 100644 --- a/Build/source/texk/dvipdfm-x/pdffont.h +++ b/Build/source/texk/dvipdfm-x/pdffont.h @@ -60,11 +60,9 @@ extern void pdf_close_fonts (void); extern int pdf_font_findresource (const char *font_name, double font_scale, fontmap_rec *mrec); -extern pdf_font* pdf_get_font (int font_id); extern int pdf_get_font_subtype (int font_id); extern pdf_obj *pdf_get_font_reference (int font_id); extern char *pdf_get_font_usedchars (int font_id); -extern char *pdf_get_font_usedglyphs (int font_id); #if 0 extern char *pdf_get_font_fontname (int font_id); /* without unique tag */ diff --git a/Build/source/texk/dvipdfm-x/tt_cmap.c b/Build/source/texk/dvipdfm-x/tt_cmap.c index a2e8e21f679..aa49979be6c 100644 --- a/Build/source/texk/dvipdfm-x/tt_cmap.c +++ b/Build/source/texk/dvipdfm-x/tt_cmap.c @@ -55,10 +55,6 @@ #include "tt_cmap.h" -#ifdef XETEX -#include FT_CID_H -#endif - #define VERBOSE_LEVEL_MIN 0 static int verbose = 0; void @@ -951,16 +947,6 @@ handle_subst_glyphs (CMap *cmap, return count; } -unsigned int -gid_to_cid(sfnt *sfont, USHORT gid) -{ - unsigned int cid = 0; -#ifdef XETEX - FT_Get_CID_From_Glyph_Index(sfont->ft_face, gid, &cid); -#endif - return cid ? cid : gid; -} - static pdf_obj * create_ToUnicode_cmap4 (struct cmap4 *map, const char *cmap_name, CMap *cmap_add, @@ -999,11 +985,10 @@ create_ToUnicode_cmap4 (struct cmap4 *map, map->idDelta[i]) & 0xffff; } if (is_used_char2(used_glyphs_copy, gid)) { - unsigned int cid = gid_to_cid(sfont, gid); count++; - wbuf[0] = (cid >> 8) & 0xff; - wbuf[1] = (cid & 0xff); + wbuf[0] = (gid >> 8) & 0xff; + wbuf[1] = (gid & 0xff); wbuf[2] = (ch >> 8) & 0xff; wbuf[3] = ch & 0xff; @@ -1072,10 +1057,9 @@ create_ToUnicode_cmap12 (struct cmap12 *map, d = ch - map->groups[i].startCharCode; gid = (USHORT) ((map->groups[i].startGlyphID + d) & 0xffff); if (is_used_char2(used_glyphs_copy, gid)) { - unsigned int cid = gid_to_cid(sfont, gid); count++; - wbuf[0] = (cid >> 8) & 0xff; - wbuf[1] = (cid & 0xff); + wbuf[0] = (gid >> 8) & 0xff; + wbuf[1] = (gid & 0xff); len = UC_sput_UTF16BE((long)ch, &p, wbuf+WBUF_SIZE); CMap_add_bfchar(cmap, wbuf, 2, wbuf+2, len); diff --git a/Build/source/texk/dvipdfm-x/type0.c b/Build/source/texk/dvipdfm-x/type0.c index b74b3f27e02..3238b0949d7 100644 --- a/Build/source/texk/dvipdfm-x/type0.c +++ b/Build/source/texk/dvipdfm-x/type0.c @@ -45,9 +45,6 @@ #include "type0.h" -#ifdef XETEX -#include FT_CID_H -#endif #define TYPE0FONT_DEBUG_STR "Type0" #define TYPE0FONT_DEBUG 3 @@ -88,7 +85,6 @@ struct Type0Font { char *fontname; /* BaseFont */ char *encoding; /* "Identity-H" or "Identity-V" (not ID) */ char *used_chars; /* Used chars (CIDs) */ - char *used_glyphs; /* Used glyphs (GIDs) */ /* * Type0 only @@ -116,7 +112,6 @@ Type0Font_init_font_struct (Type0Font *font) font->descriptor = NULL; font->encoding = NULL; font->used_chars = NULL; - font->used_glyphs = NULL; font->descendant = NULL; font->wmode = -1; font->flags = FLAG_NONE; @@ -144,7 +139,6 @@ Type0Font_clean (Type0Font *font) font->indirect = NULL; font->descriptor = NULL; font->used_chars = NULL; - font->used_glyphs = NULL; font->encoding = NULL; font->fontname = NULL; } @@ -153,47 +147,13 @@ Type0Font_clean (Type0Font *font) /* PLEASE FIX THIS */ #include "tt_cmap.h" -pdf_obj *Type0Font_create_ToUnicode_stream(Type0Font *font) { - CIDFont *cidfont = font->descendant; - char *used = Type0Font_get_usedglyphs(font); - if (!used) - used = Type0Font_get_usedchars(font); - return otf_create_ToUnicode_stream(CIDFont_get_ident(cidfont), - CIDFont_get_opt_index(cidfont), -#ifdef XETEX - CIDFont_get_ft_face(cidfont), -#endif - used); -} - -/* Try to load ToUnicode CMap from file system first, if not found fallback to - * font CMap reverse lookup. */ -pdf_obj *Type0Font_try_load_ToUnicode_stream(Type0Font *font, char *cmap_base) { - char *cmap_name = NEW(strlen(cmap_base) + strlen("-UTF-16"), char); - pdf_obj *tounicode; - - sprintf(cmap_name, "%s-UTF16", cmap_base); - tounicode = pdf_read_ToUnicode_file(cmap_name); - if (!tounicode) { - sprintf(cmap_name, "%s-UCS2", cmap_base); - tounicode = pdf_read_ToUnicode_file(cmap_name); - } - - RELEASE(cmap_name); - - if (!tounicode) - tounicode = Type0Font_create_ToUnicode_stream(font); - - return tounicode; -} - static void add_ToUnicode (Type0Font *font) { pdf_obj *tounicode; CIDFont *cidfont; CIDSysInfo *csi; - char *fontname; + char *cmap_name, *fontname; /* * ToUnicode CMap: @@ -237,24 +197,45 @@ add_ToUnicode (Type0Font *font) switch (CIDFont_get_subtype(cidfont)) { case CIDFONT_TYPE2: /* PLEASE FIX THIS */ - tounicode = Type0Font_create_ToUnicode_stream(font); + tounicode = otf_create_ToUnicode_stream(CIDFont_get_ident(cidfont), + CIDFont_get_opt_index(cidfont), +#ifdef XETEX + CIDFont_get_ft_face(cidfont), +#endif + Type0Font_get_usedchars(font)); break; default: if (CIDFont_get_flag(cidfont, CIDFONT_FLAG_TYPE1C)) { /* FIXME */ - tounicode = Type0Font_create_ToUnicode_stream(font); + tounicode = otf_create_ToUnicode_stream(CIDFont_get_ident(cidfont), + CIDFont_get_opt_index(cidfont), +#ifdef XETEX + CIDFont_get_ft_face(cidfont), +#endif + Type0Font_get_usedchars(font)); } else if (CIDFont_get_flag(cidfont, CIDFONT_FLAG_TYPE1)) { /* FIXME */ /* Font loader will create ToUnicode and set. */ return; } else { - tounicode = Type0Font_try_load_ToUnicode_stream(font, fontname); + cmap_name = NEW(strlen(fontname) + 7, char); + sprintf(cmap_name, "%s-UTF16", fontname); + tounicode = pdf_read_ToUnicode_file(cmap_name); + if (!tounicode) { + sprintf(cmap_name, "%s-UCS2", fontname); + tounicode = pdf_read_ToUnicode_file(cmap_name); + } + RELEASE(cmap_name); } break; } } else { - char *cmap_base = NEW(strlen(csi->registry) + strlen(csi->ordering) + 2, char); - sprintf(cmap_base, "%s-%s", csi->registry, csi->ordering); - tounicode = Type0Font_try_load_ToUnicode_stream(font, cmap_base); - RELEASE(cmap_base); + cmap_name = NEW(strlen(csi->registry)+strlen(csi->ordering)+8, char); + sprintf(cmap_name, "%s-%s-UTF16", csi->registry, csi->ordering); + tounicode = pdf_read_ToUnicode_file(cmap_name); + if (!tounicode) { + sprintf(cmap_name, "%s-%s-UCS2", csi->registry, csi->ordering); + tounicode = pdf_read_ToUnicode_file(cmap_name); + } + RELEASE(cmap_name); } if (tounicode) { @@ -329,14 +310,6 @@ Type0Font_get_usedchars (Type0Font *font) return font->used_chars; } -char * -Type0Font_get_usedglyphs (Type0Font *font) -{ - ASSERT(font); - - return font->used_glyphs; -} - pdf_obj * Type0Font_get_resource (Type0Font *font) { @@ -522,7 +495,6 @@ Type0Font_cache_find (const char *map_name, int cmap_id, fontmap_opt *fmap_opt) */ font->used_chars = NULL; - font->used_glyphs = NULL; font->flags = FLAG_NONE; switch (CIDFont_get_subtype(cidfont)) { @@ -534,19 +506,11 @@ Type0Font_cache_find (const char *map_name, int cmap_id, fontmap_opt *fmap_opt) /* * Need used_chars to write W, W2. */ - if ((parent_id = CIDFont_get_parent_id(cidfont, wmode ? 0 : 1)) < 0) { -#ifdef XETEX - FT_Face face = CIDFont_get_ft_face(cidfont); - FT_Bool is_cid_keyed = 0; - FT_Get_CID_Is_Internally_CID_Keyed(face, &is_cid_keyed); - if (is_cid_keyed) - font->used_glyphs = new_used_chars2(); -#endif + if ((parent_id = CIDFont_get_parent_id(cidfont, wmode ? 0 : 1)) < 0) font->used_chars = new_used_chars2(); - } else { + else { /* Don't allocate new one. */ font->used_chars = Type0Font_get_usedchars(Type0Font_cache_get(parent_id)); - font->used_glyphs = Type0Font_get_usedglyphs(Type0Font_cache_get(parent_id)); font->flags |= FLAG_USED_CHARS_SHARED; } break; diff --git a/Build/source/texk/dvipdfm-x/type0.h b/Build/source/texk/dvipdfm-x/type0.h index 7e140bc8719..6b8fa1d1c39 100644 --- a/Build/source/texk/dvipdfm-x/type0.h +++ b/Build/source/texk/dvipdfm-x/type0.h @@ -35,7 +35,6 @@ extern int Type0Font_get_wmode (Type0Font *font); extern char *Type0Font_get_encoding (Type0Font *font); #endif extern char *Type0Font_get_usedchars (Type0Font *font); -extern char *Type0Font_get_usedglyphs (Type0Font *font); extern pdf_obj *Type0Font_get_resource (Type0Font *font); |