Commit 670ea176 authored by Adrian Johnson's avatar Adrian Johnson

pdffonts: list the encoding of each font

Bug 46888
parent 3ab6b5eb
......@@ -76,6 +76,8 @@ public:
// Return collection name (<registry>-<ordering>).
GooString *getCollection() { return collection; }
GooString *getCMapName() { return cMapName; }
// Return true if this CMap matches the specified <collectionA>, and
// <cMapNameA>.
GBool match(GooString *collectionA, GooString *cMapNameA);
......
......@@ -200,6 +200,7 @@ FontInfo::FontInfo(GfxFont *font, PDFDoc *doc) {
if (substituteNameAux.getLength() > 0)
substituteName = substituteNameAux.copy();
}
encoding = font->getEncodingName()->copy();
// look for a ToUnicode map
hasToUnicode = gFalse;
......@@ -225,6 +226,7 @@ FontInfo::FontInfo(GfxFont *font, PDFDoc *doc) {
FontInfo::FontInfo(FontInfo& f) {
name = f.name ? f.name->copy() : NULL;
file = f.file ? f.file->copy() : NULL;
encoding = f.encoding ? f.encoding->copy() : NULL;
type = f.type;
emb = f.emb;
subset = f.subset;
......@@ -236,6 +238,7 @@ FontInfo::FontInfo(FontInfo& f) {
FontInfo::~FontInfo() {
delete name;
delete file;
delete encoding;
if (substituteName)
delete substituteName;
}
......@@ -58,6 +58,7 @@ public:
GooString *getName() { return name; };
GooString *getSubstituteName() { return substituteName; };
GooString *getFile() { return file; };
GooString *getEncoding() { return encoding; };
Type getType() { return type; };
GBool getEmbedded() { return emb; };
GBool getSubset() { return subset; };
......@@ -69,6 +70,7 @@ private:
GooString *name;
GooString *substituteName;
GooString *file;
GooString *encoding;
Type type;
GBool emb;
GBool subset;
......
......@@ -240,6 +240,7 @@ GfxFont::GfxFont(const char *tagA, Ref idA, GooString *nameA,
stretch = StretchNotDefined;
weight = WeightNotDefined;
refCnt = 1;
encodingName = new GooString("");
hasToUnicode = gFalse;
}
......@@ -252,6 +253,9 @@ GfxFont::~GfxFont() {
if (embFontName) {
delete embFontName;
}
if (encodingName) {
delete encodingName;
}
}
void GfxFont::incRefCnt() {
......@@ -1136,6 +1140,22 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
}
}
if (baseEncFromFontFile) {
encodingName->Set("Builtin");
} else if (baseEnc == winAnsiEncoding) {
encodingName->Set("WinAnsi");
} else if (baseEnc == macRomanEncoding) {
encodingName->Set("MacRoman");
} else if (baseEnc == macExpertEncoding) {
encodingName->Set("MacExpert");
} else if (baseEnc == symbolEncoding) {
encodingName->Set("Symbol");
} else if (baseEnc == zapfDingbatsEncoding) {
encodingName->Set("ZapfDingbats");
} else {
encodingName->Set("Standard");
}
// copy the base encoding
for (i = 0; i < 256; ++i) {
enc[i] = (char *)baseEnc[i];
......@@ -1161,6 +1181,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
if (obj1.isDict()) {
obj1.dictLookup("Differences", &obj2);
if (obj2.isArray()) {
encodingName->Set("Custom");
hasEncoding = gTrue;
code = 0;
for (i = 0; i < obj2.arrayGetLength(); ++i) {
......@@ -1847,6 +1868,11 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA,
goto err2;
}
obj1.free();
if (cMap->getCMapName()) {
encodingName->Set(cMap->getCMapName()->getCString());
} else {
encodingName->Set("Custom");
}
// CIDToGIDMap (for embedded TrueType fonts)
if (type == fontCIDType2 || type == fontCIDType2OT) {
......
......@@ -260,6 +260,9 @@ public:
// Does this font have a toUnicode map?
GBool hasToUnicodeCMap() { return hasToUnicode; }
// Return the name of the encoding
GooString *getEncodingName() { return encodingName; }
protected:
virtual ~GfxFont();
......@@ -288,6 +291,7 @@ protected:
int refCnt;
GBool ok;
GBool hasToUnicode;
GooString *encodingName;
};
//------------------------------------------------------------------------
......
......@@ -21,6 +21,9 @@ a subset prefix)
.B type
the font type -- see below for details
.TP
.B encoding
the font encoding
.TP
.B emb
"yes" if the font is embedded in the PDF file
.TP
......
......@@ -182,14 +182,15 @@ int main(int argc, char *argv[]) {
}
} else {
// print the font info
printf("name type emb sub uni object ID\n");
printf("------------------------------------ ----------------- --- --- --- ---------\n");
printf("name type encoding emb sub uni object ID\n");
printf("------------------------------------ ----------------- ---------------- --- --- --- ---------\n");
if (fonts) {
for (int i = 0; i < fonts->getLength(); ++i) {
FontInfo *font = (FontInfo *)fonts->get(i);
printf("%-36s %-17s %-3s %-3s %-3s",
printf("%-36s %-17s %-16s %-3s %-3s %-3s",
font->getName() ? font->getName()->getCString() : "[none]",
fontTypeNames[font->getType()],
font->getEncoding()->getCString(),
font->getEmbedded() ? "yes" : "no",
font->getSubset() ? "yes" : "no",
font->getToUnicode() ? "yes" : "no");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment