[poppler] poppler/CairoOutputDev.cc poppler/GfxFont.cc poppler/GlobalParams.cc poppler/GlobalParams.h poppler/SplashOutputDev.cc poppler/TextOutputDev.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Thu Oct 19 15:57:23 UTC 2017
poppler/CairoOutputDev.cc | 2
poppler/GfxFont.cc | 94 ++++++++++-----------
poppler/GlobalParams.cc | 193 ---------------------------------------------
poppler/GlobalParams.h | 44 ----------
poppler/SplashOutputDev.cc | 66 ++++-----------
poppler/TextOutputDev.cc | 3
6 files changed, 68 insertions(+), 334 deletions(-)
New commits:
commit 5b8fe4ee986673f15fcf8f58409cc85e8bf7ca12
Author: Albert Astals Cid <aacid at kde.org>
Date: Thu Oct 19 17:49:06 2017 +0200
Remove various never called internal setters from GlobalParams.h
TextKeepTinyChars: false, simplify if in TextOutputDev
DisableFreeTypeHinting: didn't actually have a getter :D
StrokeAdjust: true, adjust the code in Cairo/SplashOutputDev to use gTrue
ScreenType: unset, simplify switch in SplashOutputDev
ScreenSize: -1, simplify code in SplashOutputDev
ScreenDotRadius: -1, simplify code in SplashOutputDev
ScreenGamma: 1.0, simplify code in SplashOutputDev
ScreenBlackThreshold: 0.0, simplify code in SplashOutputDev
ScreenWhiteThreshold: 1.0, simplify code in SplashOutputDev
MinLineWidth: 0.0, define it as static const in SplashOutputDev since was used in various places
MapNumericCharNames: true, remove GfxFont.cc if guard
MapUnknownCharNames: true, remove GfxFont.cc if guard
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 80f7a99e..fdff172e 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -169,7 +169,7 @@ CairoOutputDev::CairoOutputDev() {
// the SA parameter supposedly defaults to false, but Acrobat
// apparently hardwires it to true
- stroke_adjust = globalParams->getStrokeAdjust();
+ stroke_adjust = gTrue;
align_stroke_coords = gFalse;
adjusted_stroke_width = gFalse;
xref = NULL;
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 04431b3c..d06eadff 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -1311,12 +1311,10 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
continue;
}
- // if the 'mapUnknownCharNames' flag is set, do a simple pass-through
+ // do a simple pass-through
// mapping for unknown character names
- if (globalParams->getMapUnknownCharNames()) {
- uBuf[0] = code;
- ctu->setMapping((CharCode)code, uBuf, 1);
- }
+ uBuf[0] = code;
+ ctu->setMapping((CharCode)code, uBuf, 1);
}
}
}
@@ -1505,54 +1503,52 @@ static int parseCharName(char *charName, Unicode *uBuf, int uLen,
if (names && (uBuf[0] = globalParams->mapNameToUnicodeText(charName))) {
return 1;
}
- if (globalParams->getMapNumericCharNames()) {
- unsigned int n = strlen(charName);
- // 3.3. otherwise, if the component is of the form "uni" (U+0075 U+006E
- // U+0069) followed by a sequence of uppercase hexadecimal digits (0 .. 9,
- // A .. F, i.e. U+0030 .. U+0039, U+0041 .. U+0046), the length of that
- // sequence is a multiple of four, and each group of four digits represents
- // a number in the set {0x0000 .. 0xD7FF, 0xE000 .. 0xFFFF}, then interpret
- // each such number as a Unicode scalar value and map the component to the
- // string made of those scalar values. Note that the range and digit length
- // restrictions mean that the "uni" prefix can be used only with Unicode
- // values from the Basic Multilingual Plane (BMP).
- if (n >= 7 && (n % 4) == 3 && !strncmp(charName, "uni", 3)) {
- int i;
- unsigned int m;
- for (i = 0, m = 3; i < uLen && m < n; m += 4) {
- if (isxdigit(charName[m]) && isxdigit(charName[m + 1]) &&
- isxdigit(charName[m + 2]) && isxdigit(charName[m + 3])) {
- unsigned int u;
- sscanf(charName + m, "%4x", &u);
- if (u <= 0xD7FF || (0xE000 <= u && u <= 0xFFFF)) {
- uBuf[i++] = u;
- }
- }
- }
- return i;
- }
- // 3.4. otherwise, if the component is of the form "u" (U+0075) followed by
- // a sequence of four to six uppercase hexadecimal digits {0 .. 9, A .. F}
- // (U+0030 .. U+0039, U+0041 .. U+0046), and those digits represent a
- // number in {0x0000 .. 0xD7FF, 0xE000 .. 0x10FFFF}, then interpret this
- // number as a Unicode scalar value and map the component to the string
- // made of this scalar value.
- if (n >= 5 && n <= 7 && charName[0] == 'u' && isxdigit(charName[1]) &&
- isxdigit(charName[2]) && isxdigit(charName[3]) && isxdigit(charName[4])
- && (n <= 5 || isxdigit(charName[5]))
- && (n <= 6 || isxdigit(charName[6]))) {
- unsigned int u;
- sscanf(charName + 1, "%x", &u);
- if (u <= 0xD7FF || (0xE000 <= u && u <= 0x10FFFF)) {
- uBuf[0] = u;
- return 1;
+ unsigned int n = strlen(charName);
+ // 3.3. otherwise, if the component is of the form "uni" (U+0075 U+006E
+ // U+0069) followed by a sequence of uppercase hexadecimal digits (0 .. 9,
+ // A .. F, i.e. U+0030 .. U+0039, U+0041 .. U+0046), the length of that
+ // sequence is a multiple of four, and each group of four digits represents
+ // a number in the set {0x0000 .. 0xD7FF, 0xE000 .. 0xFFFF}, then interpret
+ // each such number as a Unicode scalar value and map the component to the
+ // string made of those scalar values. Note that the range and digit length
+ // restrictions mean that the "uni" prefix can be used only with Unicode
+ // values from the Basic Multilingual Plane (BMP).
+ if (n >= 7 && (n % 4) == 3 && !strncmp(charName, "uni", 3)) {
+ int i;
+ unsigned int m;
+ for (i = 0, m = 3; i < uLen && m < n; m += 4) {
+ if (isxdigit(charName[m]) && isxdigit(charName[m + 1]) &&
+ isxdigit(charName[m + 2]) && isxdigit(charName[m + 3])) {
+ unsigned int u;
+ sscanf(charName + m, "%4x", &u);
+ if (u <= 0xD7FF || (0xE000 <= u && u <= 0xFFFF)) {
+ uBuf[i++] = u;
+ }
}
}
- // Not in Adobe Glyph Mapping convention: look for names like xx
- // or Axx and parse for hex or decimal values.
- if (numeric && parseNumericName(charName, hex, uBuf))
+ return i;
+ }
+ // 3.4. otherwise, if the component is of the form "u" (U+0075) followed by
+ // a sequence of four to six uppercase hexadecimal digits {0 .. 9, A .. F}
+ // (U+0030 .. U+0039, U+0041 .. U+0046), and those digits represent a
+ // number in {0x0000 .. 0xD7FF, 0xE000 .. 0x10FFFF}, then interpret this
+ // number as a Unicode scalar value and map the component to the string
+ // made of this scalar value.
+ if (n >= 5 && n <= 7 && charName[0] == 'u' && isxdigit(charName[1]) &&
+ isxdigit(charName[2]) && isxdigit(charName[3]) && isxdigit(charName[4])
+ && (n <= 5 || isxdigit(charName[5]))
+ && (n <= 6 || isxdigit(charName[6]))) {
+ unsigned int u;
+ sscanf(charName + 1, "%x", &u);
+ if (u <= 0xD7FF || (0xE000 <= u && u <= 0x10FFFF)) {
+ uBuf[0] = u;
return 1;
+ }
}
+ // Not in Adobe Glyph Mapping convention: look for names like xx
+ // or Axx and parse for hex or decimal values.
+ if (numeric && parseNumericName(charName, hex, uBuf))
+ return 1;
// 3.5. otherwise, map the component to the empty string
return 0;
}
diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 93c42d2a..e3de7e3f 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -583,19 +583,8 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir)
textEOL = eolUnix;
#endif
textPageBreaks = gTrue;
- textKeepTinyChars = gFalse;
enableFreeType = gTrue;
- strokeAdjust = gTrue;
- screenType = screenUnset;
- screenSize = -1;
- screenDotRadius = -1;
- screenGamma = 1.0;
- screenBlackThreshold = 0.0;
- screenWhiteThreshold = 1.0;
- minLineWidth = 0.0;
overprintPreview = gFalse;
- mapNumericCharNames = gTrue;
- mapUnknownCharNames = gTrue;
printCommands = gFalse;
profileCommands = gFalse;
errQuiet = gFalse;
@@ -1429,15 +1418,6 @@ GBool GlobalParams::getTextPageBreaks() {
return pageBreaks;
}
-GBool GlobalParams::getTextKeepTinyChars() {
- GBool tiny;
-
- lockGlobalParams;
- tiny = textKeepTinyChars;
- unlockGlobalParams;
- return tiny;
-}
-
GBool GlobalParams::getEnableFreeType() {
GBool f;
@@ -1447,96 +1427,6 @@ GBool GlobalParams::getEnableFreeType() {
return f;
}
-GBool GlobalParams::getStrokeAdjust() {
- GBool f;
-
- lockGlobalParams;
- f = strokeAdjust;
- unlockGlobalParams;
- return f;
-}
-
-ScreenType GlobalParams::getScreenType() {
- ScreenType t;
-
- lockGlobalParams;
- t = screenType;
- unlockGlobalParams;
- return t;
-}
-
-int GlobalParams::getScreenSize() {
- int size;
-
- lockGlobalParams;
- size = screenSize;
- unlockGlobalParams;
- return size;
-}
-
-int GlobalParams::getScreenDotRadius() {
- int r;
-
- lockGlobalParams;
- r = screenDotRadius;
- unlockGlobalParams;
- return r;
-}
-
-double GlobalParams::getScreenGamma() {
- double gamma;
-
- lockGlobalParams;
- gamma = screenGamma;
- unlockGlobalParams;
- return gamma;
-}
-
-double GlobalParams::getScreenBlackThreshold() {
- double thresh;
-
- lockGlobalParams;
- thresh = screenBlackThreshold;
- unlockGlobalParams;
- return thresh;
-}
-
-double GlobalParams::getScreenWhiteThreshold() {
- double thresh;
-
- lockGlobalParams;
- thresh = screenWhiteThreshold;
- unlockGlobalParams;
- return thresh;
-}
-
-double GlobalParams::getMinLineWidth() {
- double minLineWidthA;
-
- lockGlobalParams;
- minLineWidthA = minLineWidth;
- unlockGlobalParams;
- return minLineWidthA;
-}
-
-GBool GlobalParams::getMapNumericCharNames() {
- GBool map;
-
- lockGlobalParams;
- map = mapNumericCharNames;
- unlockGlobalParams;
- return map;
-}
-
-GBool GlobalParams::getMapUnknownCharNames() {
- GBool map;
-
- lockGlobalParams;
- map = mapUnknownCharNames;
- unlockGlobalParams;
- return map;
-}
-
GBool GlobalParams::getPrintCommands() {
GBool p;
@@ -1712,12 +1602,6 @@ void GlobalParams::setTextPageBreaks(GBool pageBreaks) {
unlockGlobalParams;
}
-void GlobalParams::setTextKeepTinyChars(GBool keep) {
- lockGlobalParams;
- textKeepTinyChars = keep;
- unlockGlobalParams;
-}
-
GBool GlobalParams::setEnableFreeType(char *s) {
GBool ok;
@@ -1727,89 +1611,12 @@ GBool GlobalParams::setEnableFreeType(char *s) {
return ok;
}
-GBool GlobalParams::setDisableFreeTypeHinting(char *s) {
- GBool ok;
-
- lockGlobalParams;
- ok = parseYesNo2(s, &disableFreeTypeHinting);
- unlockGlobalParams;
- return ok;
-}
-
-void GlobalParams::setStrokeAdjust(GBool adjust)
-{
- lockGlobalParams;
- strokeAdjust = adjust;
- unlockGlobalParams;
-}
-
-void GlobalParams::setScreenType(ScreenType st)
-{
- lockGlobalParams;
- screenType = st;
- unlockGlobalParams;
-}
-
-void GlobalParams::setScreenSize(int size)
-{
- lockGlobalParams;
- screenSize = size;
- unlockGlobalParams;
-}
-
-void GlobalParams::setScreenDotRadius(int radius)
-{
- lockGlobalParams;
- screenDotRadius = radius;
- unlockGlobalParams;
-}
-
-void GlobalParams::setScreenGamma(double gamma)
-{
- lockGlobalParams;
- screenGamma = gamma;
- unlockGlobalParams;
-}
-
-void GlobalParams::setScreenBlackThreshold(double blackThreshold)
-{
- lockGlobalParams;
- screenBlackThreshold = blackThreshold;
- unlockGlobalParams;
-}
-
-void GlobalParams::setScreenWhiteThreshold(double whiteThreshold)
-{
- lockGlobalParams;
- screenWhiteThreshold = whiteThreshold;
- unlockGlobalParams;
-}
-
-void GlobalParams::setMinLineWidth(double minLineWidthA)
-{
- lockGlobalParams;
- minLineWidth = minLineWidthA;
- unlockGlobalParams;
-}
-
void GlobalParams::setOverprintPreview(GBool overprintPreviewA) {
lockGlobalParams;
overprintPreview = overprintPreviewA;
unlockGlobalParams;
}
-void GlobalParams::setMapNumericCharNames(GBool map) {
- lockGlobalParams;
- mapNumericCharNames = map;
- unlockGlobalParams;
-}
-
-void GlobalParams::setMapUnknownCharNames(GBool map) {
- lockGlobalParams;
- mapUnknownCharNames = map;
- unlockGlobalParams;
-}
-
void GlobalParams::setPrintCommands(GBool printCommandsA) {
lockGlobalParams;
printCommands = printCommandsA;
diff --git a/poppler/GlobalParams.h b/poppler/GlobalParams.h
index 16dc7a4a..31e8cbfa 100644
--- a/poppler/GlobalParams.h
+++ b/poppler/GlobalParams.h
@@ -100,15 +100,6 @@ enum EndOfLineKind {
//------------------------------------------------------------------------
-enum ScreenType {
- screenUnset,
- screenDispersed,
- screenClustered,
- screenStochasticClustered
-};
-
-//------------------------------------------------------------------------
-
class GlobalParams {
public:
@@ -147,19 +138,8 @@ public:
GooString *getTextEncodingName();
EndOfLineKind getTextEOL();
GBool getTextPageBreaks();
- GBool getTextKeepTinyChars();
GBool getEnableFreeType();
- GBool getStrokeAdjust();
- ScreenType getScreenType();
- int getScreenSize();
- int getScreenDotRadius();
- double getScreenGamma();
- double getScreenBlackThreshold();
- double getScreenWhiteThreshold();
- double getMinLineWidth();
GBool getOverprintPreview() { return overprintPreview; }
- GBool getMapNumericCharNames();
- GBool getMapUnknownCharNames();
GBool getPrintCommands();
GBool getProfileCommands();
GBool getErrQuiet();
@@ -184,20 +164,8 @@ public:
void setTextEncoding(char *encodingName);
GBool setTextEOL(char *s);
void setTextPageBreaks(GBool pageBreaks);
- void setTextKeepTinyChars(GBool keep);
GBool setEnableFreeType(char *s);
- GBool setDisableFreeTypeHinting(char *s);
- void setStrokeAdjust(GBool strokeAdjust);
- void setScreenType(ScreenType st);
- void setScreenSize(int size);
- void setScreenDotRadius(int radius);
- void setScreenGamma(double gamma);
- void setScreenBlackThreshold(double blackThreshold);
- void setScreenWhiteThreshold(double whiteThreshold);
- void setMinLineWidth(double minLineWidth);
void setOverprintPreview(GBool overprintPreviewA);
- void setMapNumericCharNames(GBool map);
- void setMapUnknownCharNames(GBool map);
void setPrintCommands(GBool printCommandsA);
void setProfileCommands(GBool profileCommandsA);
void setErrQuiet(GBool errQuietA);
@@ -258,20 +226,8 @@ private:
EndOfLineKind textEOL; // type of EOL marker to use for text
// output
GBool textPageBreaks; // insert end-of-page markers?
- GBool textKeepTinyChars; // keep all characters in text output
GBool enableFreeType; // FreeType enable flag
- GBool disableFreeTypeHinting; // FreeType disable hinting flag
- GBool strokeAdjust; // stroke adjustment enable flag
- ScreenType screenType; // halftone screen type
- int screenSize; // screen matrix size
- int screenDotRadius; // screen dot radius
- double screenGamma; // screen gamma correction
- double screenBlackThreshold; // screen black clamping threshold
- double screenWhiteThreshold; // screen white clamping threshold
- double minLineWidth; // minimum line width
GBool overprintPreview; // enable overprint preview
- GBool mapNumericCharNames; // map numeric char names (from font subsets)?
- GBool mapUnknownCharNames; // map unknown char names?
GBool printCommands; // print the drawing commands
GBool profileCommands; // profile the drawing commands
GBool errQuiet; // suppress error messages?
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index dc5b6871..ff4e9119 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -103,6 +103,8 @@ extern "C" int unlink(char *filename);
#endif
#endif
+static const double s_minLineWidth = 0.0;
+
static inline void convertGfxColor(SplashColorPtr dest,
SplashColorMode colorMode,
GfxColorSpace *colorSpace,
@@ -1407,7 +1409,7 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA,
bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode,
colorMode != splashModeMono1, bitmapTopDown);
splash = new Splash(bitmap, vectorAntialias, &screenParams);
- splash->setMinLineWidth(globalParams->getMinLineWidth());
+ splash->setMinLineWidth(s_minLineWidth);
splash->setThinLineMode(thinLineMode);
splash->clear(paperColor, 0);
@@ -1425,27 +1427,15 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA,
}
void SplashOutputDev::setupScreenParams(double hDPI, double vDPI) {
- screenParams.size = globalParams->getScreenSize();
- screenParams.dotRadius = globalParams->getScreenDotRadius();
- screenParams.gamma = (SplashCoord)globalParams->getScreenGamma();
- screenParams.blackThreshold =
- (SplashCoord)globalParams->getScreenBlackThreshold();
- screenParams.whiteThreshold =
- (SplashCoord)globalParams->getScreenWhiteThreshold();
- switch (globalParams->getScreenType()) {
- case screenDispersed:
- screenParams.type = splashScreenDispersed;
- if (screenParams.size < 0) {
- screenParams.size = 4;
- }
- break;
- case screenClustered:
- screenParams.type = splashScreenClustered;
- if (screenParams.size < 0) {
- screenParams.size = 10;
- }
- break;
- case screenStochasticClustered:
+ screenParams.size = -1;
+ screenParams.dotRadius = -1;
+ screenParams.gamma = (SplashCoord)1.0;
+ screenParams.blackThreshold = (SplashCoord)0.0;
+ screenParams.whiteThreshold = (SplashCoord)1.0;
+
+ // use clustered dithering for resolution >= 300 dpi
+ // (compare to 299.9 to avoid floating point issues)
+ if (hDPI > 299.9 && vDPI > 299.9) {
screenParams.type = splashScreenStochasticClustered;
if (screenParams.size < 0) {
screenParams.size = 64;
@@ -1453,24 +1443,10 @@ void SplashOutputDev::setupScreenParams(double hDPI, double vDPI) {
if (screenParams.dotRadius < 0) {
screenParams.dotRadius = 2;
}
- break;
- case screenUnset:
- default:
- // use clustered dithering for resolution >= 300 dpi
- // (compare to 299.9 to avoid floating point issues)
- if (hDPI > 299.9 && vDPI > 299.9) {
- screenParams.type = splashScreenStochasticClustered;
- if (screenParams.size < 0) {
- screenParams.size = 64;
- }
- if (screenParams.dotRadius < 0) {
- screenParams.dotRadius = 2;
- }
- } else {
- screenParams.type = splashScreenDispersed;
- if (screenParams.size < 0) {
- screenParams.size = 4;
- }
+ } else {
+ screenParams.type = splashScreenDispersed;
+ if (screenParams.size < 0) {
+ screenParams.size = 4;
}
}
}
@@ -1558,7 +1534,7 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) {
}
splash = new Splash(bitmap, vectorAntialias, &screenParams);
splash->setThinLineMode(thinLineMode);
- splash->setMinLineWidth(globalParams->getMinLineWidth());
+ splash->setMinLineWidth(s_minLineWidth);
if (state) {
ctm = state->getCTM();
mat[0] = (SplashCoord)ctm[0];
@@ -1600,7 +1576,7 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) {
splash->setFlatness(1);
// the SA parameter supposedly defaults to false, but Acrobat
// apparently hardwires it to true
- splash->setStrokeAdjust(globalParams->getStrokeAdjust());
+ splash->setStrokeAdjust(gTrue);
splash->clear(paperColor, 0);
}
@@ -2854,7 +2830,7 @@ void SplashOutputDev::type3D1(GfxState *state, double wx, double wy,
splash->clear(color);
color[0] = 0xff;
}
- splash->setMinLineWidth(globalParams->getMinLineWidth());
+ splash->setMinLineWidth(s_minLineWidth);
splash->setThinLineMode(splashThinLineDefault);
splash->setFillPattern(new SplashSolidColor(color));
splash->setStrokePattern(new SplashSolidColor(color));
@@ -4315,7 +4291,7 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,
#endif
}
splash->setThinLineMode(transpGroup->origSplash->getThinLineMode());
- splash->setMinLineWidth(globalParams->getMinLineWidth());
+ splash->setMinLineWidth(s_minLineWidth);
//~ Acrobat apparently copies at least the fill and stroke colors, and
//~ maybe other state(?) -- but not the clipping path (and not sure
//~ what else)
@@ -4731,7 +4707,7 @@ GBool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *ca
splash->clear(paperColor, 0);
}
splash->setThinLineMode(formerSplash->getThinLineMode());
- splash->setMinLineWidth(globalParams->getMinLineWidth());
+ splash->setMinLineWidth(s_minLineWidth);
box.x1 = bbox[0]; box.y1 = bbox[1];
box.x2 = bbox[2]; box.y2 = bbox[3];
diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index 14002407..6b642491 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -2599,8 +2599,7 @@ void TextPage::addChar(GfxState *state, double x, double y,
}
// check the tiny chars limit
- if (!globalParams->getTextKeepTinyChars() &&
- fabs(w1) < 3 && fabs(h1) < 3) {
+ if (fabs(w1) < 3 && fabs(h1) < 3) {
if (++nTinyChars > 50000) {
charPos += nBytes;
return;
More information about the poppler
mailing list