X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fxpdf%2FFTFont.cc;h=ab101acdec795a2f3f4f48ef15e2c5c6306cb188;hb=8032fd96d450ac015c0153f1fa57e974d67b4993;hp=0524c7edc135c4d057bc3e0e9e846572420334cf;hpb=2a393c134fe3fe8eb85bf818cb7ad6ae4396322a;p=evince.git diff --git a/pdf/xpdf/FTFont.cc b/pdf/xpdf/FTFont.cc index 0524c7ed..ab101acd 100644 --- a/pdf/xpdf/FTFont.cc +++ b/pdf/xpdf/FTFont.cc @@ -6,14 +6,14 @@ // //======================================================================== -#ifdef __GNUC__ -#pragma implementation -#endif - #include #if FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H) +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + #include #include #include "gmem.h" @@ -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); + } } //------------------------------------------------------------------------ @@ -261,15 +276,11 @@ FTFont::FTFont(FTFontFile *fontFileA, double *m) { yMax = (int)(1.2 * size); } // this should be (max - min + 1), but we add some padding to - // deal with rounding errors + // deal with rounding errors, bogus bboxes, etc. glyphW = xMax - xMin + 3; + glyphW += glyphW >> 1; glyphH = yMax - yMin + 3; - // another kludge: some CJK TT fonts have bogus bboxes, so add more - // padding - if (face->num_glyphs > 1000) { - glyphW += glyphW >> 1; - glyphH += glyphH >> 1; - } + glyphH += glyphH >> 1; if (engine->aa) { glyphSize = glyphW * glyphH; } else { @@ -444,9 +455,9 @@ Guchar *FTFont::getGlyphPixmap(CharCode c, Unicode u, int *x, int *y, int *w, int *h) { FT_GlyphSlot slot; FT_UInt idx; - int gSize; + int rowSize; int i, j, k; - Guchar *ret; + Guchar *ret, *p, *q; // check the cache i = (c & (cacheSets - 1)) * cacheAssoc; @@ -516,12 +527,16 @@ Guchar *FTFont::getGlyphPixmap(CharCode c, Unicode u, cacheTags[i+j].w = *w; cacheTags[i+j].h = *h; if (fontFile->engine->aa) { - gSize = *w * *h; + rowSize = *w; } else { - gSize = ((*w + 7) >> 3) * *h; + rowSize = (*w + 7) >> 3; } ret = cache + (i+j) * glyphSize; - memcpy(ret, slot->bitmap.buffer, gSize); + for (k = 0, p = ret, q = slot->bitmap.buffer; + k < slot->bitmap.rows; + ++k, p += rowSize, q += slot->bitmap.pitch) { + memcpy(p, q, rowSize); + } } else { ++cacheTags[i+j].mru; } @@ -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; }