--- poppler-31jul09-subst/utils/pdftops.cc- 2009-07-31 04:11:56.000000000 +0100 +++ poppler-31jul09-subst/utils/pdftops.cc 2009-07-31 04:21:31.000000000 +0100 @@ -46,6 +46,10 @@ #include "PSOutputDev.h" #include "Error.h" +#ifndef SUBST_FONTS +#define SUBST_FONTS 0 /* set default: 1 to substitute missing fonts, 0 to pass missing fonts */ +#endif + static GBool setPSPaperSize(char *size, int &psPaperWidth, int &psPaperHeight) { if (!strcmp(size, "match")) { psPaperWidth = psPaperHeight = -1; @@ -86,6 +90,11 @@ static GBool noEmbedTTFonts = gFalse; static GBool noEmbedCIDPSFonts = gFalse; static GBool noEmbedCIDTTFonts = gFalse; +#if SUBST_FONTS +static GBool noSubstFonts = gFalse; +#else +static GBool substFonts = gFalse; +#endif static GBool preload = gFalse; static char paperSize[15] = ""; static int paperWidth = -1; @@ -136,6 +145,13 @@ "don't embed CID PostScript fonts"}, {"-noembcidtt", argFlag, &noEmbedCIDTTFonts, 0, "don't embed CID TrueType fonts"}, +#if SUBST_FONTS + {"-nosubst", argFlag, &noSubstFonts,0, + "don't substitute missing fonts"}, +#else + {"-subst", argFlag, &substFonts, 0, + "substitute missing fonts"}, +#endif {"-preload", argFlag, &preload, 0, "preload images and forms"}, {"-paper", argString, paperSize, sizeof(paperSize), @@ -269,6 +285,15 @@ if (noEmbedCIDTTFonts) { globalParams->setPSEmbedCIDTrueType(!noEmbedCIDTTFonts); } +#if SUBST_FONTS + if (noSubstFonts) { + globalParams->setPSSubstFonts(!noSubstFonts); + } +#else + if (!substFonts) { + globalParams->setPSSubstFonts(substFonts); + } +#endif if (preload) { globalParams->setPSPreload(preload); } --- poppler-31jul09-subst/poppler/GlobalParams.h- 2009-07-31 04:11:56.000000000 +0100 +++ poppler-31jul09-subst/poppler/GlobalParams.h 2009-07-31 04:21:31.000000000 +0100 @@ -193,6 +193,7 @@ GBool getPSEmbedTrueType(); GBool getPSEmbedCIDPostScript(); GBool getPSEmbedCIDTrueType(); + GBool getPSSubstFonts(); GBool getPSPreload(); GBool getPSOPI(); GBool getPSASCIIHex(); @@ -238,6 +239,7 @@ void setPSEmbedTrueType(GBool embed); void setPSEmbedCIDPostScript(GBool embed); void setPSEmbedCIDTrueType(GBool embed); + void setPSSubstFonts(GBool substFonts); void setPSPreload(GBool preload); void setPSOPI(GBool opi); void setPSASCIIHex(GBool hex); @@ -317,6 +319,7 @@ GBool psEmbedTrueType; // embed TrueType fonts? GBool psEmbedCIDPostScript; // embed CID PostScript fonts? GBool psEmbedCIDTrueType; // embed CID TrueType fonts? + GBool psSubstFonts; // substitute missing fonts? GBool psPreload; // preload PostScript images and forms into // memory GBool psOPI; // generate PostScript OPI comments? --- poppler-31jul09-subst/poppler/GlobalParams.cc- 2009-07-31 04:11:56.000000000 +0100 +++ poppler-31jul09-subst/poppler/GlobalParams.cc 2009-07-31 04:21:31.000000000 +0100 @@ -602,6 +602,7 @@ psEmbedTrueType = gTrue; psEmbedCIDPostScript = gTrue; psEmbedCIDTrueType = gTrue; + psSubstFonts = gTrue; psPreload = gFalse; psOPI = gFalse; psASCIIHex = gFalse; @@ -1280,6 +1281,15 @@ return e; } +GBool GlobalParams::getPSSubstFonts() { + GBool e; + + lockGlobalParams; + e = psSubstFonts; + unlockGlobalParams; + return e; +} + GBool GlobalParams::getPSPreload() { GBool preload; @@ -1649,6 +1659,12 @@ unlockGlobalParams; } +void GlobalParams::setPSSubstFonts(GBool substFonts) { + lockGlobalParams; + psSubstFonts = substFonts; + unlockGlobalParams; +} + void GlobalParams::setPSPreload(GBool preload) { lockGlobalParams; psPreload = preload; --- poppler-31jul09-subst/poppler/PSOutputDev.h- 2009-07-31 04:11:56.000000000 +0100 +++ poppler-31jul09-subst/poppler/PSOutputDev.h 2009-07-31 04:21:31.000000000 +0100 @@ -358,6 +358,7 @@ // (only psModePSOrigPageSizes output mode) int imgLLX, imgLLY, // imageable area, in pts imgURX, imgURY; + GBool substFonts; // substitute missing fonts GBool preload; // load all images into memory, and // predefine forms --- poppler-31jul09-subst/poppler/PSOutputDev.cc- 2009-07-31 04:11:56.000000000 +0100 +++ poppler-31jul09-subst/poppler/PSOutputDev.cc 2009-07-31 04:21:31.000000000 +0100 @@ -1751,34 +1751,39 @@ } } if (!psName) { - if (font->isFixedWidth()) { - i = 8; - } else if (font->isSerif()) { - i = 4; - } else { - i = 0; - } - if (font->isBold()) { - i += 2; - } - if (font->isItalic()) { - i += 1; - } - psName = new GooString(psSubstFonts[i].psName); - for (code = 0; code < 256; ++code) { - if ((charName = ((Gfx8BitFont *)font)->getCharName(code)) && - charName[0] == 'm' && charName[1] == '\0') { - break; + if (substFonts) { + if (font->isFixedWidth()) { + i = 8; + } else if (font->isSerif()) { + i = 4; + } else { + i = 0; + } + if (font->isBold()) { + i += 2; + } + if (font->isItalic()) { + i += 1; + } + psName = new GooString(psSubstFonts[i].psName); + for (code = 0; code < 256; ++code) { + if ((charName = ((Gfx8BitFont *)font)->getCharName(code)) && + charName[0] == 'm' && charName[1] == '\0') { + break; + } + } + if (code < 256) { + w1 = ((Gfx8BitFont *)font)->getWidth(code); + } else { + w1 = 0; + } + w2 = psSubstFonts[i].mWidth; + xs = w1 / w2; + if (xs < 0.1) { + xs = 1; } - } - if (code < 256) { - w1 = ((Gfx8BitFont *)font)->getWidth(code); } else { - w1 = 0; - } - w2 = psSubstFonts[i].mWidth; - xs = w1 / w2; - if (xs < 0.1) { + psName = new GooString(name); xs = 1; } if (font->getType() == fontType3) {