Summary: | freetype patch for xpdf | ||
---|---|---|---|
Product: | [Unmaintained] kpdf | Reporter: | LuRan <hephooey_dev> |
Component: | general | Assignee: | Albert Astals Cid <aacid> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: |
gentoo's patch
before the patch after the patch |
Description
LuRan
2005-03-01 15:21:27 UTC
Created attachment 9903 [details]
gentoo's patch
gentoo's patch for xpdf
Hi, without a testcase that demonstrates this patch is necessary in kpdf we are not going to use it. Also someone explaining where the bug is rather than giving just a patch would be useful Sorry, my fault. I'll upload two snapshot of a pdf file viewed in kpdf before and after the patch. I can upload the pdf if you want, but it's 4.4 Mb big. About the bug I don't know much, I only heard that it has something to do with the unicode map of truetype fonts, and the patch is originally from the author of xpdf and will be included in the next release of xpdf. Created attachment 9914 [details]
before the patch
Created attachment 9915 [details]
after the patch
You don't have to know Chinese to see the difference;) The first two charactor
is the same since the font is embeded in the file. other is different because
it use external font configed in xpdfrc. Latin charactor do not have this kind
of problem, you can see it from the snapshot.
You can find some more information in bugs.gentoo.org, bug #42161 CVS commit by aacid: * Use fontconfig for searching CID Fonts too if no font is found the xpdf way * Don't parse "MS-Micho" to fontname "MS" and style "Mincho" * Apply patch given at 100551 that fixes crash on 101032 when the font was found, thanks LuRan for providing the patch * Stephan can you try it does not crashes there and then send a screenshot to the SuSe reported to see if what we display is the correct thing * Will backport when i'm sure the introduced patch does not causes any side effect BUGS: 101032, 100551 M +4 -0 CharCodeToUnicode.h 1.2 M +3 -0 GlobalParams.cc 1.9 M +45 -6 SplashOutputDev.cc 1.2 --- kdegraphics/kpdf/xpdf/xpdf/CharCodeToUnicode.h #1.1:1.2 @@ -68,4 +68,8 @@ public: int mapToUnicode(CharCode c, Unicode *u, int size); + // Return the mapping's length, i.e., one more than the max char + // code supported by the mapping. + CharCode getLength() { return mapLen; } + private: --- kdegraphics/kpdf/xpdf/xpdf/GlobalParams.cc #1.8:1.9 @@ -1047,4 +1047,6 @@ FILE *GlobalParams::findToUnicodeFile(GS void parseStyle(QString& name, int& weight, int& slant) { + if (name.find("MS-") == 0) name = "MS " + name.remove(0,3); + if (!name.contains('-') && !name.contains(',')) return; QString type = name.section(QRegExp("[-,]"),-1); @@ -1107,4 +1109,5 @@ DisplayFontParam *GlobalParams::getDispl } unlockGlobalParams; + if (!dfp) dfp = getDisplayFont(fontName); return dfp; } --- kdegraphics/kpdf/xpdf/xpdf/SplashOutputDev.cc #1.1:1.2 @@ -498,8 +498,10 @@ void SplashOutputDev::updateFont(GfxStat Gushort *codeToGID; DisplayFontParam *dfp; + CharCodeToUnicode *ctu; double m11, m12, m21, m22, w1, w2; SplashCoord mat[4]; const char *name; - int c, substIdx, n, code; + Unicode uBuf[8]; + int c, substIdx, n, code, cmap; needFontUpdate = gFalse; @@ -545,5 +547,4 @@ void SplashOutputDev::updateFont(GfxStat // look for a display font mapping or a substitute font - dfp = NULL; if (gfxFont->isCIDFont()) { if (((GfxCIDFont *)gfxFont)->getCollection()) { @@ -651,8 +652,46 @@ void SplashOutputDev::updateFont(GfxStat break; case fontCIDType2: + codeToGID = NULL; + n = 0; + if (dfp) { + // create a CID-to-GID mapping, via Unicode + if ((ctu = ((GfxCIDFont *)gfxFont)->getToUnicode())) { + if ((ff = FoFiTrueType::load(fileName->getCString()))) { + // look for a Unicode cmap + for (cmap = 0; cmap < ff->getNumCmaps(); ++cmap) { + if ((ff->getCmapPlatform(cmap) == 3 && + ff->getCmapEncoding(cmap) == 1) || + ff->getCmapPlatform(cmap) == 0) { + break; + } + } + if (cmap < ff->getNumCmaps()) { + // map CID -> Unicode -> GID + n = ctu->getLength(); + codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort)); + for (code = 0; code < n; ++code) { + if (ctu->mapToUnicode(code, uBuf, 8) > 0) { + codeToGID[code] = ff->mapCodeToGID(cmap, uBuf[0]); + } else { + codeToGID[code] = 0; + } + } + } + delete ff; + } + ctu->decRefCnt(); + } else { + error(-1, "Couldn't find a mapping to Unicode for font '%s'", + gfxFont->getName() ? gfxFont->getName()->getCString() + : "(unnamed)"); + } + } else { + if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort)); memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), n * sizeof(Gushort)); + } + } if (!(fontFile = fontEngine->loadTrueTypeFont( id, |