fofi/FoFiTrueType.cc | 8 ++-- fofi/FoFiTrueType.h | 4 +- fofi/FoFiType1C.cc | 84 +++++++++++++++++++++++++++++++++++-------------- fofi/FoFiType1C.h | 19 ++++++++--- poppler/PSOutputDev.cc | 13 +++++-- 5 files changed, 91 insertions(+), 37 deletions(-)
New commits: commit 9531a52b227a994ab8e0d66aeaff2b21358ca73e Author: Carlos Garcia Campos <[email protected]> Date: Fri Sep 2 18:01:35 2011 +0200 xpdf303: New signature of methods convertToCIDType0() and convertToType0() diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc index 1a171cb..431910d 100644 --- a/fofi/FoFiTrueType.cc +++ b/fofi/FoFiTrueType.cc @@ -702,7 +702,7 @@ void FoFiTrueType::convertToCIDType2(char *psName, 56); } -void FoFiTrueType::convertToCIDType0(char *psName, +void FoFiTrueType::convertToCIDType0(char *psName, int *cidMap, int nCIDs, FoFiOutputFunc outputFunc, void *outputStream) { char *start; @@ -715,7 +715,7 @@ void FoFiTrueType::convertToCIDType0(char *psName, if (!(ff = FoFiType1C::make(start, length))) { return; } - ff->convertToCIDType0(psName, outputFunc, outputStream); + ff->convertToCIDType0(psName, cidMap, nCIDs, outputFunc, outputStream); delete ff; } @@ -823,7 +823,7 @@ void FoFiTrueType::convertToType0(char *psName, int *cidMap, int nCIDs, (*outputFunc)(outputStream, "FontName currentdict end definefont pop\n", 40); } -void FoFiTrueType::convertToType0(char *psName, +void FoFiTrueType::convertToType0(char *psName, int *cidMap, int nCIDs, FoFiOutputFunc outputFunc, void *outputStream) { char *start; @@ -836,7 +836,7 @@ void FoFiTrueType::convertToType0(char *psName, if (!(ff = FoFiType1C::make(start, length))) { return; } - ff->convertToType0(psName, outputFunc, outputStream); + ff->convertToType0(psName, cidMap, nCIDs, outputFunc, outputStream); delete ff; } diff --git a/fofi/FoFiTrueType.h b/fofi/FoFiTrueType.h index 76be424..c2d7bd4 100644 --- a/fofi/FoFiTrueType.h +++ b/fofi/FoFiTrueType.h @@ -133,7 +133,7 @@ public: // Convert to a Type 0 CIDFont, suitable for embedding in a // PostScript file. <psName> will be used as the PostScript font // name. (Only useful for OpenType CFF fonts.) - void convertToCIDType0(char *psName, + void convertToCIDType0(char *psName, int *cidMap, int nCIDs, FoFiOutputFunc outputFunc, void *outputStream); // Convert to a Type 0 (but non-CID) composite font, suitable for @@ -148,7 +148,7 @@ public: // Convert to a Type 0 (but non-CID) composite font, suitable for // embedding in a PostScript file. <psName> will be used as the // PostScript font name. (Only useful for OpenType CFF fonts.) - void convertToType0(char *psName, + void convertToType0(char *psName, int *cidMap, int nCIDs, FoFiOutputFunc outputFunc, void *outputStream); // Write a clean TTF file, filling in missing tables and correcting diff --git a/fofi/FoFiType1C.cc b/fofi/FoFiType1C.cc index 97943de..76931d7 100644 --- a/fofi/FoFiType1C.cc +++ b/fofi/FoFiType1C.cc @@ -473,7 +473,7 @@ void FoFiType1C::convertToType1(char *psName, const char **newEncoding, GBool as (*outputFunc)(outputStream, "cleartomark\n", 12); } -void FoFiType1C::convertToCIDType0(char *psName, +void FoFiType1C::convertToCIDType0(char *psName, int *codeMap, int nCodes, FoFiOutputFunc outputFunc, void *outputStream) { int *cidMap; @@ -488,18 +488,36 @@ void FoFiType1C::convertToCIDType0(char *psName, int gid, offset, n, i, j, k; // compute the CID count and build the CID-to-GID mapping - nCIDs = 0; - for (i = 0; i < nGlyphs; ++i) { - if (charset[i] >= nCIDs) { - nCIDs = charset[i] + 1; + if (codeMap) { + nCIDs = nCodes; + cidMap = (int *)gmallocn(nCIDs, sizeof(int)); + for (i = 0; i < nCodes; ++i) { + if (codeMap[i] >= 0 && codeMap[i] < nGlyphs) { + cidMap[i] = codeMap[i]; + } else { + cidMap[i] = -1; + } + } + } else if (topDict.firstOp == 0x0c1e) { + nCIDs = 0; + for (i = 0; i < nGlyphs; ++i) { + if (charset[i] >= nCIDs) { + nCIDs = charset[i] + 1; + } + } + cidMap = (int *)gmallocn(nCIDs, sizeof(int)); + for (i = 0; i < nCIDs; ++i) { + cidMap[i] = -1; + } + for (i = 0; i < nGlyphs; ++i) { + cidMap[charset[i]] = i; + } + } else { + nCIDs = nGlyphs; + cidMap = (int *)gmallocn(nCIDs, sizeof(int)); + for (i = 0; i < nCIDs; ++i) { + cidMap[i] = i; } - } - cidMap = (int *)gmallocn(nCIDs, sizeof(int)); - for (i = 0; i < nCIDs; ++i) { - cidMap[i] = -1; - } - for (i = 0; i < nGlyphs; ++i) { - cidMap[charset[i]] = i; } // build the charstrings @@ -799,7 +817,7 @@ void FoFiType1C::convertToCIDType0(char *psName, gfree(cidMap); } -void FoFiType1C::convertToType0(char *psName, +void FoFiType1C::convertToType0(char *psName, int *codeMap, int nCodes, FoFiOutputFunc outputFunc, void *outputStream) { int *cidMap; @@ -812,18 +830,36 @@ void FoFiType1C::convertToType0(char *psName, int fd, i, j, k; // compute the CID count and build the CID-to-GID mapping - nCIDs = 0; - for (i = 0; i < nGlyphs; ++i) { - if (charset[i] >= nCIDs) { - nCIDs = charset[i] + 1; + if (codeMap) { + nCIDs = nCodes; + cidMap = (int *)gmallocn(nCIDs, sizeof(int)); + for (i = 0; i < nCodes; ++i) { + if (codeMap[i] >= 0 && codeMap[i] < nGlyphs) { + cidMap[i] = codeMap[i]; + } else { + cidMap[i] = -1; + } + } + } else if (topDict.firstOp == 0x0c1e) { + nCIDs = 0; + for (i = 0; i < nGlyphs; ++i) { + if (charset[i] >= nCIDs) { + nCIDs = charset[i] + 1; + } + } + cidMap = (int *)gmallocn(nCIDs, sizeof(int)); + for (i = 0; i < nCIDs; ++i) { + cidMap[i] = -1; + } + for (i = 0; i < nGlyphs; ++i) { + cidMap[charset[i]] = i; + } + } else { + nCIDs = nGlyphs; + cidMap = (int *)gmallocn(nCIDs, sizeof(int)); + for (i = 0; i < nCIDs; ++i) { + cidMap[i] = i; } - } - cidMap = (int *)gmallocn(nCIDs, sizeof(int)); - for (i = 0; i < nCIDs; ++i) { - cidMap[i] = -1; - } - for (i = 0; i < nGlyphs; ++i) { - cidMap[charset[i]] = i; } // write the descendant Type 1 fonts diff --git a/fofi/FoFiType1C.h b/fofi/FoFiType1C.h index 7c8d30a..a1dd3ee 100644 --- a/fofi/FoFiType1C.h +++ b/fofi/FoFiType1C.h @@ -179,14 +179,25 @@ public: // Convert to a Type 0 CIDFont, suitable for embedding in a // PostScript file. <psName> will be used as the PostScript font - // name. - void convertToCIDType0(char *psName, + // name. There are three cases for the CID-to-GID mapping: + // (1) if <codeMap> is non-NULL, then it is the CID-to-GID mapping + // (2) if <codeMap> is NULL and this is a CID CFF font, then the + // font's internal CID-to-GID mapping is used + // (3) is <codeMap> is NULL and this is an 8-bit CFF font, then + // the identity CID-to-GID mapping is used + void convertToCIDType0(char *psName, int *codeMap, int nCodes, FoFiOutputFunc outputFunc, void *outputStream); // Convert to a Type 0 (but non-CID) composite font, suitable for // embedding in a PostScript file. <psName> will be used as the - // PostScript font name. - void convertToType0(char *psName, + // PostScript font name. There are three cases for the CID-to-GID + // mapping: + // (1) if <codeMap> is non-NULL, then it is the CID-to-GID mapping + // (2) if <codeMap> is NULL and this is a CID CFF font, then the + // font's internal CID-to-GID mapping is used + // (3) is <codeMap> is NULL and this is an 8-bit CFF font, then + // the identity CID-to-GID mapping is used + void convertToType0(char *psName, int *codeMap, int nCodes, FoFiOutputFunc outputFunc, void *outputStream); private: diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 5c16d44..ae08570 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -2452,10 +2452,12 @@ void PSOutputDev::setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, if ((ffT1C = FoFiType1C::make(fontBuf, fontLen))) { if (globalParams->getPSLevel() >= psLevel3) { // Level 3: use a CID font - ffT1C->convertToCIDType0(psName->getCString(), outputFunc, outputStream); + ffT1C->convertToCIDType0(psName->getCString(), NULL, 0, + outputFunc, outputStream); } else { // otherwise: use a non-CID composite font - ffT1C->convertToType0(psName->getCString(), outputFunc, outputStream); + ffT1C->convertToType0(psName->getCString(), NULL, 0, + outputFunc, outputStream); } delete ffT1C; } @@ -2555,10 +2557,15 @@ void PSOutputDev::setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id, if (globalParams->getPSLevel() >= psLevel3) { // Level 3: use a CID font ffTT->convertToCIDType0(psName->getCString(), + ((GfxCIDFont *)font)->getCIDToGID(), + ((GfxCIDFont *)font)->getCIDToGIDLen(), outputFunc, outputStream); } else { // otherwise: use a non-CID composite font - ffTT->convertToType0(psName->getCString(), outputFunc, outputStream); + ffTT->convertToType0(psName->getCString(), + ((GfxCIDFont *)font)->getCIDToGID(), + ((GfxCIDFont *)font)->getCIDToGIDLen(), + outputFunc, outputStream); } } delete ffTT; _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
