static void CIDFont_dofont (CIDFont *font) { if (!font || !font->indirect) return; if (__verbose) MESG(":%s", font->ident); if (__verbose > 1) { if (font->fontname) MESG("[%s]", font->fontname); } switch (font->subtype) { case CIDFONT_TYPE0: if(__verbose) MESG("[CIDFontType0]"); if (CIDFont_get_flag(font, CIDFONT_FLAG_TYPE1)) CIDFont_type0_t1dofont(font); else if (CIDFont_get_flag(font, CIDFONT_FLAG_TYPE1C)) CIDFont_type0_t1cdofont(font); else CIDFont_type0_dofont(font); break; case CIDFONT_TYPE2: if(__verbose) MESG("[CIDFontType2]"); CIDFont_type2_dofont(font); break; default: ERROR("%s: Unknown CIDFontType %d.", CIDFONT_DEBUG_STR, font->subtype); break; } }
static void add_ToUnicode (Type0Font *font) { pdf_obj *tounicode; CIDFont *cidfont; CIDSysInfo *csi; char *fontname; /* * ToUnicode CMap: * * ToUnicode CMaps are usually not required for standard character * collections such as Adobe-Japan1. Identity-H is used for UCS * ordering CID-keyed fonts. External resource must be loaded for * others. */ cidfont = font->descendant; if (!cidfont) { ERROR("%s: No descendant CID-keyed font.", TYPE0FONT_DEBUG_STR); return; } if (CIDFont_is_ACCFont(cidfont)) { /* No need to embed ToUnicode */ return; } else if (CIDFont_is_UCSFont(cidfont)) { /* * Old version of dvipdfmx mistakenly used Adobe-Identity as Unicode. */ tounicode = pdf_read_ToUnicode_file("Adobe-Identity-UCS2"); if (!tounicode) { /* This should work */ tounicode = pdf_new_name("Identity-H"); } pdf_add_dict(font->fontdict, pdf_new_name("ToUnicode"), tounicode); return; } tounicode = NULL; csi = CIDFont_get_CIDSysInfo(cidfont); fontname = CIDFont_get_fontname(cidfont); if (CIDFont_get_embedding(cidfont)) { fontname += 7; /* FIXME */ } if (!strcmp(csi->registry, "Adobe") && !strcmp(csi->ordering, "Identity")) { switch (CIDFont_get_subtype(cidfont)) { case CIDFONT_TYPE2: /* PLEASE FIX THIS */ tounicode = Type0Font_create_ToUnicode_stream(font); break; default: if (CIDFont_get_flag(cidfont, CIDFONT_FLAG_TYPE1C)) { /* FIXME */ tounicode = Type0Font_create_ToUnicode_stream(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); } 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); } if (tounicode) { pdf_add_dict(font->fontdict, pdf_new_name("ToUnicode"), tounicode); } else { WARN("Failed to load ToUnicode CMap for font \"%s\"", fontname); } return; }