cpp/poppler-page-renderer.cpp | 4 ++-- poppler/GlobalParams.cc | 54 ------------------------------------------------------ poppler/GlobalParams.h | 14 +++----------- poppler/PSOutputDev.cc | 14 +++++++------- poppler/PSOutputDev.h | 3 +++ poppler/SplashOutputDev.cc | 17 +++++++---------- poppler/SplashOutputDev.h | 8 +++++--- qt4/src/poppler-page.cc | 4 ++-- qt5/src/poppler-page.cc | 4 ++-- utils/pdftohtml.cc | 6 ++---- utils/pdftoppm.cc | 46 ++++++++++++++++++++++++++++++++++------------ utils/pdftops.cc | 14 +++++++++++++- 12 files changed, 80 insertions(+), 108 deletions(-) diff --git a/cpp/poppler-page-renderer.cpp b/cpp/poppler-page-renderer.cpp index 1317192..7ac7ca9 100644 --- a/cpp/poppler-page-renderer.cpp +++ b/cpp/poppler-page-renderer.cpp @@ -171,8 +171,8 @@ image page_renderer::render_page(const page *p, bgColor[0] = d->paper_color & 0xff; bgColor[1] = (d->paper_color >> 8) & 0xff; bgColor[2] = (d->paper_color >> 16) & 0xff; - const GBool text_AA = d->hints & text_antialiasing ? gTrue : gFalse; - SplashOutputDev splashOutputDev(splashModeXBGR8, 4, gFalse, bgColor, gTrue, text_AA); + SplashOutputDev splashOutputDev(splashModeXBGR8, 4, gFalse, bgColor, gTrue); + splashOutputDev.setFontAntialias(d->hints & text_antialiasing ? gTrue : gFalse); splashOutputDev.setVectorAntialias(d->hints & antialiasing ? gTrue : gFalse); splashOutputDev.setFreeTypeHinting(d->hints & text_hinting ? gTrue : gFalse, gFalse); splashOutputDev.startDoc(pdfdoc); 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/PSOutputDev.cc b/poppler/PSOutputDev.cc index b95df31..d0e977b 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 @@ -1230,6 +1230,7 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, } // initialize + rasterAntialias = gFalse; displayText = gTrue; ok = gTrue; outputFunc = outputFuncA; @@ -3202,24 +3203,23 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, numComps = 1; paperColor[0] = 0xff; splashOut = new SplashOutputDev(splashModeMono8, 1, gFalse, - paperColor, gFalse, - globalParams->getAntialiasPrinting()); + paperColor, gFalse); #if SPLASH_CMYK } else if (level == psLevel1Sep || level == psLevel2Sep || level == psLevel3Sep || globalParams->getOverprintPreview()) { numComps = 4; paperColor[0] = paperColor[1] = paperColor[2] = paperColor[3] = 0; splashOut = new SplashOutputDev(splashModeCMYK8, 1, gFalse, - paperColor, gFalse, - globalParams->getAntialiasPrinting()); + paperColor, gFalse); #endif } else { numComps = 3; paperColor[0] = paperColor[1] = paperColor[2] = 0xff; splashOut = new SplashOutputDev(splashModeRGB8, 1, gFalse, - paperColor, gFalse, - globalParams->getAntialiasPrinting()); + paperColor, gFalse); } + splashOut->setFontAntialias(rasterAntialias); + splashOut->setVectorAntialias(rasterAntialias); splashOut->startDoc(doc); // break the page into stripes diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h index 262ce14..ce40bf8 100644 --- a/poppler/PSOutputDev.h +++ b/poppler/PSOutputDev.h @@ -308,6 +308,8 @@ public: { overlayCbk = cbk; overlayCbkData = data; } void setDisplayText(GBool display) { displayText = display; } + void setRasterAntialias(GBool a) { rasterAntialias = a; } + private: void init(PSOutputFunc outputFuncA, void *outputStreamA, @@ -488,6 +490,7 @@ private: GBool t3NeedsRestore; // set if a 'q' operator was issued GBool forceRasterize; // forces the page to be rasterized into a image before printing GBool displayText; // displayText + GBool rasterAntialias; // antialias on rasterize #if OPI_SUPPORT int opi13Nest; // nesting level of OPI 1.3 objects diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index bfb07eb..0509ad1 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 @@ -1252,17 +1252,14 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA, GBool reverseVideoA, SplashColorPtr paperColorA, GBool bitmapTopDownA, - GBool allowAntialiasA, - SplashThinLineMode thinLineMode, - GBool overprintPreviewA) { + SplashThinLineMode thinLineMode, + GBool overprintPreviewA) { colorMode = colorModeA; bitmapRowPad = bitmapRowPadA; bitmapTopDown = bitmapTopDownA; bitmapUpsideDown = gFalse; - allowAntialias = allowAntialiasA; - vectorAntialias = allowAntialias && - globalParams->getVectorAntialias() && - colorMode != splashModeMono1; + fontAntialias = gTrue; + vectorAntialias = gTrue; overprintPreview = overprintPreviewA; enableFreeTypeHinting = gFalse; enableSlightHinting = gFalse; @@ -1383,8 +1380,7 @@ void SplashOutputDev::startDoc(PDFDoc *docA) { enableFreeTypeHinting, enableSlightHinting, #endif - allowAntialias && - globalParams->getAntialias() && + getFontAntialias() && colorMode != splashModeMono1); for (i = 0; i < nT3Fonts; ++i) { delete t3FontCache[i]; @@ -4151,6 +4147,7 @@ GBool SplashOutputDev::getVectorAntialias() { } void SplashOutputDev::setVectorAntialias(GBool vaa) { + vaa = vaa && colorMode != splashModeMono1; vectorAntialias = vaa; splash->setVectorAntialias(vaa); } diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h index efbb865..c29d42f 100644 --- a/poppler/SplashOutputDev.h +++ b/poppler/SplashOutputDev.h @@ -170,9 +170,8 @@ public: SplashOutputDev(SplashColorMode colorModeA, int bitmapRowPadA, GBool reverseVideoA, SplashColorPtr paperColorA, GBool bitmapTopDownA = gTrue, - GBool allowAntialiasA = gTrue, SplashThinLineMode thinLineMode = splashThinLineDefault, - GBool overprintPreviewA = globalParams->getOverprintPreview()); + GBool overprintPreviewA = globalParams->getOverprintPreview()); // Destructor. virtual ~SplashOutputDev(); @@ -359,6 +358,9 @@ public: virtual void setVectorAntialias(GBool vaa); #endif + GBool getFontAntialias() { return fontAntialias; } + void setFontAntialias(GBool anti) { fontAntialias = anti; } + void setFreeTypeHinting(GBool enable, GBool enableSlightHinting); protected: @@ -396,7 +398,7 @@ private: int bitmapRowPad; GBool bitmapTopDown; GBool bitmapUpsideDown; - GBool allowAntialias; + GBool fontAntialias; GBool vectorAntialias; GBool overprintPreview; GBool enableFreeTypeHinting; diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc index fc928b9..ca76aa9 100644 --- a/qt4/src/poppler-page.cc +++ b/qt4/src/poppler-page.cc @@ -293,7 +293,6 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, bgColor[2] = m_page->parentDoc->paperColor.red(); } - GBool AA = m_page->parentDoc->m_hints & Document::TextAntialiasing ? gTrue : gFalse; SplashThinLineMode thinLineMode = splashThinLineDefault; if (m_page->parentDoc->m_hints & Document::ThinLineShape) thinLineMode = splashThinLineShape; if (m_page->parentDoc->m_hints & Document::ThinLineSolid) thinLineMode = splashThinLineSolid; @@ -304,8 +303,9 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, #else splashModeXBGR8, #endif - 4, gFalse, bgColor, gTrue, AA, thinLineMode, overprint); + 4, gFalse, bgColor, gTrue, thinLineMode, overprint); + splash_output->setFontAntialias(m_page->parentDoc->m_hints & Document::TextAntialiasing ? gTrue : gFalse); splash_output->setVectorAntialias(m_page->parentDoc->m_hints & Document::Antialiasing ? gTrue : gFalse); splash_output->setFreeTypeHinting(m_page->parentDoc->m_hints & Document::TextHinting ? gTrue : gFalse, m_page->parentDoc->m_hints & Document::TextSlightHinting ? gTrue : gFalse); diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index 6eea0d0..8b90acd 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -293,7 +293,6 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, bgColor[2] = m_page->parentDoc->paperColor.red(); } - GBool AA = m_page->parentDoc->m_hints & Document::TextAntialiasing ? gTrue : gFalse; SplashThinLineMode thinLineMode = splashThinLineDefault; if (m_page->parentDoc->m_hints & Document::ThinLineShape) thinLineMode = splashThinLineShape; if (m_page->parentDoc->m_hints & Document::ThinLineSolid) thinLineMode = splashThinLineSolid; @@ -304,8 +303,9 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, #else splashModeXBGR8, #endif - 4, gFalse, bgColor, gTrue, AA, thinLineMode, overprint); + 4, gFalse, bgColor, gTrue, thinLineMode, overprint); + splash_output->setFontAntialias(m_page->parentDoc->m_hints & Document::TextAntialiasing ? gTrue : gFalse); splash_output->setVectorAntialias(m_page->parentDoc->m_hints & Document::Antialiasing ? gTrue : gFalse); splash_output->setFreeTypeHinting(m_page->parentDoc->m_hints & Document::TextHinting ? gTrue : gFalse, m_page->parentDoc->m_hints & Document::TextSlightHinting ? gTrue : gFalse); diff --git a/utils/pdftohtml.cc b/utils/pdftohtml.cc index aabed0b..7ca69ba 100644 --- a/utils/pdftohtml.cc +++ b/utils/pdftohtml.cc @@ -155,10 +155,8 @@ class SplashOutputDevNoText : public SplashOutputDev { public: SplashOutputDevNoText(SplashColorMode colorModeA, int bitmapRowPadA, GBool reverseVideoA, SplashColorPtr paperColorA, - GBool bitmapTopDownA = gTrue, - GBool allowAntialiasA = gTrue) : SplashOutputDev(colorModeA, - bitmapRowPadA, reverseVideoA, paperColorA, bitmapTopDownA, - allowAntialiasA) { } + GBool bitmapTopDownA = gTrue) : SplashOutputDev(colorModeA, + bitmapRowPadA, reverseVideoA, paperColorA, bitmapTopDownA) { } virtual ~SplashOutputDevNoText() { } void drawChar(GfxState *state, double x, double y, diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc index 962860b..89ec9cc 100644 --- a/utils/pdftoppm.cc +++ b/utils/pdftoppm.cc @@ -268,6 +268,20 @@ static std::deque pageJobQueue; static pthread_mutex_t pageJobMutex = PTHREAD_MUTEX_INITIALIZER; static void processPageJobs() { + GBool fontAntialias = gTrue; + GBool vectorAntialias = gTrue; + + if (antialiasStr[0]) { + if (!GlobalParams::parseYesNo2(antialiasStr, &fontAntialias)) { + fprintf(stderr, "Bad '-aa' value on command line\n"); + } + } + if (vectorAntialiasStr[0]) { + if (!GlobalParams::parseYesNo2(vectorAntialiasStr, &vectorAntialias)) { + fprintf(stderr, "Bad '-aaVector' value on command line\n"); + } + } + while(true) { // pop the next job or exit if queue is empty pthread_mutex_lock(&pageJobMutex); @@ -288,7 +302,9 @@ static void processPageJobs() { #if SPLASH_CMYK (jpegcmyk || overprint) ? splashModeDeviceN8 : #endif - splashModeRGB8, 4, gFalse, *pageJob.paperColor, gTrue, gTrue, thinLineMode); + splashModeRGB8, 4, gFalse, *pageJob.paperColor, gTrue, thinLineMode); + splashOut->setFontAntialias(fontAntialias); + splashOut->setVectorAntialias(vectorAntialias); splashOut->startDoc(pageJob.doc); savePageSlice(pageJob.doc, splashOut, pageJob.pg, x, y, w, h, pageJob.pg_w, pageJob.pg_h, pageJob.ppmFile); @@ -328,6 +344,8 @@ int main(int argc, char *argv[]) { int exitCode; int pg, pg_num_len; double pg_w, pg_h, tmp; + GBool fontAntialias = gTrue; + GBool vectorAntialias = gTrue; exitCode = 99; @@ -363,16 +381,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; @@ -464,7 +472,21 @@ int main(int argc, char *argv[]) { (jpegcmyk || overprint) ? splashModeDeviceN8 : #endif splashModeRGB8, 4, - gFalse, paperColor, gTrue, gTrue, thinLineMode); + gFalse, paperColor, gTrue, thinLineMode); + + if (antialiasStr[0]) { + if (!GlobalParams::parseYesNo2(antialiasStr, &fontAntialias)) { + fprintf(stderr, "Bad '-aa' value on command line\n"); + } + } + if (vectorAntialiasStr[0]) { + if (!GlobalParams::parseYesNo2(vectorAntialiasStr, &vectorAntialias)) { + fprintf(stderr, "Bad '-aaVector' value on command line\n"); + } + } + + splashOut->setFontAntialias(fontAntialias); + splashOut->setVectorAntialias(vectorAntialias); splashOut->startDoc(doc); #endif // UTILS_USE_PTHREADS diff --git a/utils/pdftops.cc b/utils/pdftops.cc index fbc3d67..5adfe3b 100644 --- a/utils/pdftops.cc +++ b/utils/pdftops.cc @@ -19,7 +19,7 @@ // Copyright (C) 2007-2008, 2010, 2015 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,7 @@ static GBool noEmbedTTFonts = gFalse; static GBool noEmbedCIDPSFonts = gFalse; static GBool noEmbedCIDTTFonts = gFalse; static GBool fontPassthrough = gFalse; +static char rasterAntialiasStr[16] = ""; static GBool preload = gFalse; static char paperSize[15] = ""; static int paperWidth = -1; @@ -154,6 +155,8 @@ static const ArgDesc argDesc[] = { "don't embed CID TrueType fonts"}, {"-passfonts", argFlag, &fontPassthrough,0, "don't substitute missing fonts"}, + {"-aaRaster", argString, rasterAntialiasStr, sizeof(rasterAntialiasStr), + "enable anti-aliasing on rasterization: yes, no"}, {"-preload", argFlag, &preload, 0, "preload images and forms"}, {"-paper", argString, paperSize, sizeof(paperSize), @@ -206,6 +209,7 @@ int main(int argc, char *argv[]) { GBool ok; char *p; int exitCode; + GBool rasterAntialias = gFalse; std::vector pages; exitCode = 99; @@ -412,6 +416,14 @@ int main(int argc, char *argv[]) { paperHeight, noCrop, duplex); + + if (rasterAntialiasStr[0]) { + if (!GlobalParams::parseYesNo2(rasterAntialiasStr, &rasterAntialias)) { + fprintf(stderr, "Bad '-aaRaster' value on command line\n"); + } + } + + psOut->setRasterAntialias(rasterAntialias); if (psOut->isOk()) { for (int i = firstPage; i <= lastPage; ++i) { doc->displayPage(psOut, i, 72, 72,