summaryrefslogtreecommitdiff
path: root/fofi
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2011-09-02 18:01:35 +0200
committerCarlos Garcia Campos <carlosgc@gnome.org>2011-09-02 18:01:35 +0200
commit9531a52b227a994ab8e0d66aeaff2b21358ca73e (patch)
tree72b9cab4230eff6c10fdaad2bfe16873835c26ea /fofi
parent830d2b40770333489a08f23a3b16a372770a8d19 (diff)
xpdf303: New signature of methods convertToCIDType0() and convertToType0()
Diffstat (limited to 'fofi')
-rw-r--r--fofi/FoFiTrueType.cc8
-rw-r--r--fofi/FoFiTrueType.h4
-rw-r--r--fofi/FoFiType1C.cc84
-rw-r--r--fofi/FoFiType1C.h19
4 files changed, 81 insertions, 34 deletions
diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc
index 1a171cbc..431910da 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 76be4241..c2d7bd42 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 97943de0..76931d7e 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 7c8d30a2..a1dd3ee8 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: