X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=pdf%2Fxpdf%2FFTFont.cc;h=ab101acdec795a2f3f4f48ef15e2c5c6306cb188;hb=8032fd96d450ac015c0153f1fa57e974d67b4993;hp=8de09e0e61046f3cbe482c375b6ce8b7c6047143;hpb=28c37dbcf87665a4ccec58bef9ef8ff0697022dd;p=evince.git diff --git a/pdf/xpdf/FTFont.cc b/pdf/xpdf/FTFont.cc index 8de09e0e..ab101acd 100644 --- a/pdf/xpdf/FTFont.cc +++ b/pdf/xpdf/FTFont.cc @@ -56,6 +56,9 @@ FTFontFile::FTFontFile(FTFontEngine *engineA, char *fontFileName, ok = gFalse; engine = engineA; codeMap = NULL; + cidToGID = NULL; + cidToGIDLen = 0; + if (FT_New_Face(engine->lib, fontFileName, 0, &face)) { return; } @@ -144,11 +147,15 @@ FTFontFile::FTFontFile(FTFontEngine *engineA, char *fontFileName, ok = gFalse; engine = engineA; codeMap = NULL; + cidToGID = NULL; + cidToGIDLen = 0; + if (FT_New_Face(engine->lib, fontFileName, 0, &face)) { return; } - cidToGID = cidToGIDA; cidToGIDLen = cidToGIDLenA; + cidToGID = (Gushort *)gmalloc(cidToGIDLen * sizeof(Gushort)); + memcpy(cidToGID, cidToGIDA, cidToGIDLen * sizeof(Gushort)); mode = ftFontModeCIDToGIDMap; ok = gTrue; } @@ -157,12 +164,17 @@ FTFontFile::FTFontFile(FTFontEngine *engineA, char *fontFileName) { ok = gFalse; engine = engineA; codeMap = NULL; + cidToGID = NULL; + cidToGIDLen = 0; + if (FT_New_Face(engine->lib, fontFileName, 0, &face)) { return; } - cidToGID = NULL; - cidToGIDLen = 0; - mode = ftFontModeCFFCharset; + if (!strcmp(face->driver->root.clazz->module_name, "t1cid")) { + mode = ftFontModeCID; + } else { + mode = ftFontModeCFFCharset; + } ok = gTrue; } @@ -173,6 +185,9 @@ FTFontFile::~FTFontFile() { if (codeMap) { gfree(codeMap); } + if (cidToGID) { + gfree(cidToGID); + } } //------------------------------------------------------------------------ @@ -664,20 +679,25 @@ FT_UInt FTFont::getGlyphIndex(CharCode c, Unicode u) { break; case ftFontModeCFFCharset: #if 1 //~ cff cid->gid map + { #if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 0 - CFF_Font *cff = (CFF_Font *)((TT_Face)fontFile->face)->extra.data; + CFF_Font *cff = (CFF_Font *)((TT_Face)fontFile->face)->extra.data; #else - CFF_Font cff = (CFF_Font)((TT_Face)fontFile->face)->extra.data; + CFF_Font cff = (CFF_Font)((TT_Face)fontFile->face)->extra.data; #endif - idx = 0; - for (j = 0; j < (int)cff->num_glyphs; ++j) { - if (cff->charset.sids[j] == c) { - idx = j; - break; + idx = 0; + for (j = 0; j < (int)cff->num_glyphs; ++j) { + if (cff->charset.sids[j] == c) { + idx = j; + break; + } } } #endif break; + case ftFontModeCID: + idx = c; + break; } return idx; }