poppler/GlobalParams.cc | 54 ------------------------------------------------------ poppler/GlobalParams.h | 14 +++----------- poppler/OutputDev.cc | 24 ++++++++++++++++++++++++ poppler/OutputDev.h | 34 ++++++++++++++++++++++------------ poppler/PSOutputDev.cc | 8 ++++---- poppler/SplashOutputDev.cc | 18 +++++++++--------- poppler/SplashOutputDev.h | 4 ++-- utils/pdftoppm.cc | 22 ++++++++++++---------- utils/pdftops.cc | 26 +++++++++++++++++++++++++- 9 files changed, 101 insertions(+), 103 deletions(-) diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc index 3d88646..daa4a6c 100644 --- a/poppler/GlobalParams.cc +++ b/poppler/GlobalParams.cc @@ -620,9 +620,6 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir) textPageBreaks = gTrue; textKeepTinyChars = gFalse; enableFreeType = gTrue; - antialias = gTrue; - vectorAntialias = gTrue; - antialiasPrinting = gFalse; strokeAdjust = gTrue; screenType = screenUnset; screenSize = -1; @@ -1701,33 +1698,6 @@ GBool GlobalParams::getEnableFreeType() { return f; } -GBool GlobalParams::getAntialias() { - GBool f; - - lockGlobalParams; - f = antialias; - unlockGlobalParams; - return f; -} - -GBool GlobalParams::getVectorAntialias() { - GBool f; - - lockGlobalParams; - f = vectorAntialias; - unlockGlobalParams; - return f; -} - -GBool GlobalParams::getAntialiasPrinting() { - GBool f; - - lockGlobalParams; - f = antialiasPrinting; - unlockGlobalParams; - return f; -} - GBool GlobalParams::getStrokeAdjust() { GBool f; @@ -2098,30 +2068,6 @@ GBool GlobalParams::setDisableFreeTypeHinting(char *s) { return ok; } -GBool GlobalParams::setAntialias(char *s) { - GBool ok; - - lockGlobalParams; - ok = parseYesNo2(s, &antialias); - unlockGlobalParams; - return ok; -} - -GBool GlobalParams::setVectorAntialias(char *s) { - GBool ok; - - lockGlobalParams; - ok = parseYesNo2(s, &vectorAntialias); - unlockGlobalParams; - return ok; -} - -void GlobalParams::setAntialiasPrinting(GBool anti) { - lockGlobalParams; - antialiasPrinting = anti; - unlockGlobalParams; -} - void GlobalParams::setStrokeAdjust(GBool adjust) { lockGlobalParams; diff --git a/poppler/GlobalParams.h b/poppler/GlobalParams.h index c33a802..af655a7 100644 --- a/poppler/GlobalParams.h +++ b/poppler/GlobalParams.h @@ -20,7 +20,7 @@ // Copyright (C) 2007 Krzysztof Kowalczyk // Copyright (C) 2009 Jonathan Kew // Copyright (C) 2009 Petr Gajdos -// Copyright (C) 2009, 2011, 2012 William Bader +// Copyright (C) 2009, 2011, 2012, 2014 William Bader // Copyright (C) 2010 Hib Eris // Copyright (C) 2011 Pino Toscano // Copyright (C) 2012 Adrian Johnson @@ -183,9 +183,6 @@ public: GBool getTextPageBreaks(); GBool getTextKeepTinyChars(); GBool getEnableFreeType(); - GBool getAntialias(); - GBool getVectorAntialias(); - GBool getAntialiasPrinting(); GBool getStrokeAdjust(); ScreenType getScreenType(); int getScreenSize(); @@ -238,9 +235,6 @@ public: void setTextKeepTinyChars(GBool keep); GBool setEnableFreeType(char *s); GBool setDisableFreeTypeHinting(char *s); - GBool setAntialias(char *s); - GBool setVectorAntialias(char *s); - void setAntialiasPrinting(GBool print); void setStrokeAdjust(GBool strokeAdjust); void setScreenType(ScreenType st); void setScreenSize(int size); @@ -256,6 +250,8 @@ public: void setProfileCommands(GBool profileCommandsA); void setErrQuiet(GBool errQuietA); + static GBool parseYesNo2(const char *token, GBool *flag); + //----- security handlers void addSecurityHandler(XpdfSecurityHandler *handler); @@ -264,7 +260,6 @@ public: private: void parseNameToUnicode(GooString *name); - GBool parseYesNo2(const char *token, GBool *flag); UnicodeMap *getUnicodeMap2(GooString *encodingName); void scanEncodingDirs(); @@ -342,9 +337,6 @@ private: GBool textKeepTinyChars; // keep all characters in text output GBool enableFreeType; // FreeType enable flag GBool disableFreeTypeHinting; // FreeType disable hinting flag - GBool antialias; // anti-aliasing enable flag - GBool vectorAntialias; // vector anti-aliasing enable flag - GBool antialiasPrinting; // allow anti-aliasing when printing GBool strokeAdjust; // stroke adjustment enable flag ScreenType screenType; // halftone screen type int screenSize; // screen matrix size diff --git a/poppler/OutputDev.cc b/poppler/OutputDev.cc index ee3cf5a..dff5137 100644 --- a/poppler/OutputDev.cc +++ b/poppler/OutputDev.cc @@ -36,12 +36,26 @@ #include "Stream.h" #include "GfxState.h" #include "OutputDev.h" +#include "GlobalParams.h" #include "goo/GooHash.h" //------------------------------------------------------------------------ // OutputDev //------------------------------------------------------------------------ +OutputDev::OutputDev() +#ifdef USE_CMS + : iccColorSpaceCache(5) +#endif +{ + profileHash = NULL; + + allowAntialias = gTrue; + antialias = gTrue; + vectorAntialias = gTrue; + antialiasPrinting = gFalse; +} + void OutputDev::setDefaultCTM(double *ctm) { int i; double det; @@ -199,3 +213,13 @@ PopplerCache *OutputDev::getIccColorSpaceCache() return &iccColorSpaceCache; } #endif + +GBool OutputDev::setAntialiasStr(const char *s) { + GBool ok = GlobalParams::parseYesNo2(s, &antialias); + return ok; +} + +GBool OutputDev::setVectorAntialiasStr(const char *s) { + GBool ok = GlobalParams::parseYesNo2(s, &vectorAntialias); + return ok; +} diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h index e8a7a47..79fe907 100644 --- a/poppler/OutputDev.h +++ b/poppler/OutputDev.h @@ -22,7 +22,7 @@ // Copyright (C) 2009, 2012, 2013 Albert Astals Cid // Copyright (C) 2010 Christian Feuersänger // Copyright (C) 2012 Fabio D'Urso -// Copyright (C) 2012 William Bader +// Copyright (C) 2012, 2014 William Bader // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -73,13 +73,7 @@ class OutputDev { public: // Constructor. - OutputDev() -#ifdef USE_CMS - : iccColorSpaceCache(5) -#endif - { - profileHash = NULL; - } + OutputDev(); // Destructor. virtual ~OutputDev() {} @@ -327,15 +321,31 @@ public: //----- links virtual void processLink(AnnotLink * /*link*/) {} -#if 1 //~tmp: turn off anti-aliasing temporarily - virtual GBool getVectorAntialias() { return gFalse; } - virtual void setVectorAntialias(GBool /*vaa*/) {} -#endif + //----- Anti-aliasing + GBool getAllowAntialias() { return allowAntialias; } + GBool getAntialias() { return antialias; } + virtual GBool getVectorAntialias() { return vectorAntialias; } + GBool getAntialiasPrinting() { return antialiasPrinting; } + + GBool setAntialiasStr(const char *s); + GBool setVectorAntialiasStr(const char *s); + + void setAllowAntialias(GBool anti) { allowAntialias = anti; } + void setAntialias(GBool anti) { antialias = anti; } + virtual void setVectorAntialias(GBool anti) { vectorAntialias = anti; } + void setAntialiasPrinting(GBool anti) { antialiasPrinting = anti; } #ifdef USE_CMS PopplerCache *getIccColorSpaceCache(); #endif +protected: + + GBool allowAntialias; // this device allows antialiasing; set false to disable all antialiasing + GBool antialias; // font antialiasing enable flag + GBool vectorAntialias; // vector antialiasing enable flag + GBool antialiasPrinting; // allow antialiasing when printing + private: double defCTM[6]; // default coordinate transform matrix diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 149bb62..427f0f9 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -23,7 +23,7 @@ // Copyright (C) 2009-2013 Thomas Freitag // Copyright (C) 2009 Till Kamppeter // Copyright (C) 2009 Carlos Garcia Campos -// Copyright (C) 2009, 2011, 2012 William Bader +// Copyright (C) 2009, 2011, 2012, 2014 William Bader // Copyright (C) 2009 Kovid Goyal // Copyright (C) 2009-2011, 2013, 2014 Adrian Johnson // Copyright (C) 2012, 2014 Fabio D'Urso @@ -3195,7 +3195,7 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, paperColor[0] = 0xff; splashOut = new SplashOutputDev(splashModeMono8, 1, gFalse, paperColor, gFalse, - globalParams->getAntialiasPrinting()); + getAntialiasPrinting()); #if SPLASH_CMYK } else if (level == psLevel1Sep || level == psLevel2Sep || level == psLevel3Sep || globalParams->getOverprintPreview()) { @@ -3203,14 +3203,14 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, paperColor[0] = paperColor[1] = paperColor[2] = paperColor[3] = 0; splashOut = new SplashOutputDev(splashModeCMYK8, 1, gFalse, paperColor, gFalse, - globalParams->getAntialiasPrinting()); + getAntialiasPrinting()); #endif } else { numComps = 3; paperColor[0] = paperColor[1] = paperColor[2] = 0xff; splashOut = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor, gFalse, - globalParams->getAntialiasPrinting()); + getAntialiasPrinting()); } splashOut->startDoc(doc); diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index 1faa6f7..c4cec4a 100644 --- a/poppler/SplashOutputDev.cc +++ b/poppler/SplashOutputDev.cc @@ -22,7 +22,7 @@ // Copyright (C) 2009 Petr Gajdos // Copyright (C) 2009-2014 Thomas Freitag // Copyright (C) 2009 Carlos Garcia Campos -// Copyright (C) 2009 William Bader +// Copyright (C) 2009, 2014 William Bader // Copyright (C) 2010 Patrick Spendrin // Copyright (C) 2010 Brian Cameron // Copyright (C) 2010 PaweÅ‚ Wiejacha @@ -1256,10 +1256,9 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA, bitmapRowPad = bitmapRowPadA; bitmapTopDown = bitmapTopDownA; bitmapUpsideDown = gFalse; - allowAntialias = allowAntialiasA; - vectorAntialias = allowAntialias && - globalParams->getVectorAntialias() && - colorMode != splashModeMono1; + splash = NULL; + setAllowAntialias(allowAntialiasA); + resetVectorAntialias(); overprintPreview = overprintPreviewA; enableFreeTypeHinting = gFalse; enableSlightHinting = gFalse; @@ -1380,8 +1379,8 @@ void SplashOutputDev::startDoc(PDFDoc *docA) { enableFreeTypeHinting, enableSlightHinting, #endif - allowAntialias && - globalParams->getAntialias() && + getAllowAntialias() && + getAntialias() && colorMode != splashModeMono1); for (i = 0; i < nT3Fonts; ++i) { delete t3FontCache[i]; @@ -1429,6 +1428,7 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { colorMode != splashModeMono1, bitmapTopDown); } } + resetVectorAntialias(); splash = new Splash(bitmap, vectorAntialias, &screenParams); splash->setThinLineMode(thinLineMode); splash->setMinLineWidth(globalParams->getMinLineWidth()); @@ -4144,12 +4144,12 @@ void SplashOutputDev::clearModRegion() { #if 1 //~tmp: turn off anti-aliasing temporarily GBool SplashOutputDev::getVectorAntialias() { - return splash->getVectorAntialias(); + return splash? splash->getVectorAntialias(): gFalse; } void SplashOutputDev::setVectorAntialias(GBool vaa) { vectorAntialias = vaa; - splash->setVectorAntialias(vaa); + if (splash) splash->setVectorAntialias(vaa); } #endif diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h index efbb865..e7b827d 100644 --- a/poppler/SplashOutputDev.h +++ b/poppler/SplashOutputDev.h @@ -390,14 +390,14 @@ private: static GBool tilingBitmapSrc(void *data, SplashColorPtr line, Guchar *alphaLine); + void resetVectorAntialias() { vectorAntialias = getAllowAntialias() && vectorAntialias && colorMode != splashModeMono1; } + GBool keepAlphaChannel; // don't fill with paper color, keep alpha channel SplashColorMode colorMode; int bitmapRowPad; GBool bitmapTopDown; GBool bitmapUpsideDown; - GBool allowAntialias; - GBool vectorAntialias; GBool overprintPreview; GBool enableFreeTypeHinting; GBool enableSlightHinting; diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc index 962860b..6459389 100644 --- a/utils/pdftoppm.cc +++ b/utils/pdftoppm.cc @@ -363,16 +363,6 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Bad '-freetype' value on command line\n"); } } - if (antialiasStr[0]) { - if (!globalParams->setAntialias(antialiasStr)) { - fprintf(stderr, "Bad '-aa' value on command line\n"); - } - } - if (vectorAntialiasStr[0]) { - if (!globalParams->setVectorAntialias(vectorAntialiasStr)) { - fprintf(stderr, "Bad '-aaVector' value on command line\n"); - } - } if (thinLineModeStr[0]) { if (strcmp(thinLineModeStr, "solid") == 0) { thinLineMode = splashThinLineSolid; @@ -465,6 +455,18 @@ int main(int argc, char *argv[]) { #endif splashModeRGB8, 4, gFalse, paperColor, gTrue, gTrue, thinLineMode); + + if (antialiasStr[0]) { + if (!splashOut->setAntialiasStr(antialiasStr)) { + fprintf(stderr, "Bad '-aa' value on command line\n"); + } + } + if (vectorAntialiasStr[0]) { + if (!splashOut->setVectorAntialiasStr(vectorAntialiasStr)) { + fprintf(stderr, "Bad '-aaVector' value on command line\n"); + } + } + splashOut->startDoc(doc); #endif // UTILS_USE_PTHREADS diff --git a/utils/pdftops.cc b/utils/pdftops.cc index babebed..b086abd 100644 --- a/utils/pdftops.cc +++ b/utils/pdftops.cc @@ -19,7 +19,7 @@ // Copyright (C) 2007-2008, 2010 Albert Astals Cid // Copyright (C) 2009 Till Kamppeter // Copyright (C) 2009 Sanjoy Mahajan -// Copyright (C) 2009, 2011, 2012 William Bader +// Copyright (C) 2009, 2011, 2012, 2014 William Bader // Copyright (C) 2010 Hib Eris // Copyright (C) 2012 Thomas Freitag // Copyright (C) 2013 Suzuki Toshiya @@ -95,6 +95,8 @@ static GBool noEmbedTTFonts = gFalse; static GBool noEmbedCIDPSFonts = gFalse; static GBool noEmbedCIDTTFonts = gFalse; static GBool fontPassthrough = gFalse; +static char antialiasStr[16] = ""; +static char vectorAntialiasStr[16] = ""; static GBool preload = gFalse; static char paperSize[15] = ""; static int paperWidth = -1; @@ -154,6 +156,10 @@ static const ArgDesc argDesc[] = { "don't embed CID TrueType fonts"}, {"-passfonts", argFlag, &fontPassthrough,0, "don't substitute missing fonts"}, + {"-aa", argString, antialiasStr, sizeof(antialiasStr), + "enable font anti-aliasing: yes, no"}, + {"-aaVector", argString, vectorAntialiasStr, sizeof(vectorAntialiasStr), + "enable vector anti-aliasing: yes, no"}, {"-preload", argFlag, &preload, 0, "preload images and forms"}, {"-paper", argString, paperSize, sizeof(paperSize), @@ -407,6 +413,24 @@ int main(int argc, char *argv[]) { paperHeight, noCrop, duplex); + + if (antialiasStr[0]) { + if (!psOut->setAntialiasStr(antialiasStr)) { + fprintf(stderr, "Bad '-aa' value on command line\n"); + } + if (psOut->getAntialias()) { + psOut->setAntialiasPrinting(gTrue); + } + } + if (vectorAntialiasStr[0]) { + if (!psOut->setVectorAntialiasStr(vectorAntialiasStr)) { + fprintf(stderr, "Bad '-aaVector' value on command line\n"); + } + if (psOut->getVectorAntialias()) { + psOut->setAntialiasPrinting(gTrue); + } + } + if (psOut->isOk()) { doc->displayPages(psOut, firstPage, lastPage, 72, 72, 0, noCrop, !noCrop, gTrue);