Commit aa0fd32a authored by Albert Astals Cid's avatar Albert Astals Cid

Consider render value when colorizing text

Fixes bug 2807
parent cf710b99
......@@ -606,15 +606,6 @@ void CairoOutputDev::updateFont(GfxState *state) {
cairo_set_font_matrix (cairo, &matrix);
}
void CairoOutputDev::updateRender(GfxState *state) {
int rm;
rm = state->getRender();
if (rm == 7 && haveCSPattern) {
haveCSPattern = gFalse;
restoreState(state);
}
}
void CairoOutputDev::doPath(cairo_t *cairo, GfxState *state, GfxPath *path) {
GfxSubpath *subpath;
int i, j;
......@@ -909,7 +900,7 @@ void CairoOutputDev::endString(GfxState *state)
return;
}
if (!(render & 1)) {
if (!(render & 1) && !haveCSPattern) {
LOG (printf ("fill string\n"));
cairo_set_source (cairo, fill_pattern);
cairo_show_glyphs (cairo, glyphs, glyphCount);
......@@ -930,7 +921,7 @@ void CairoOutputDev::endString(GfxState *state)
}
// clip
if (render & 4) {
if (haveCSPattern || (render & 4)) {
LOG (printf ("clip string\n"));
// append the glyph path to textClipPath.
......@@ -1014,17 +1005,14 @@ void CairoOutputDev::type3D1(GfxState *state, double wx, double wy,
}
void CairoOutputDev::beginTextObject(GfxState *state) {
if (state->getFillColorSpace()->getMode() == csPattern) {
if (!(state->getRender() & 4) && state->getFillColorSpace()->getMode() == csPattern) {
haveCSPattern = gTrue;
saveState(state);
savedRender = state->getRender();
state->setRender(7); // Set clip to text path
}
}
void CairoOutputDev::endTextObject(GfxState *state) {
if (haveCSPattern) {
state->setRender(savedRender);
haveCSPattern = gFalse;
if (state->getFillColorSpace()->getMode() != csPattern) {
if (textClipPath) {
......
......@@ -150,7 +150,6 @@ public:
//----- update text state
virtual void updateFont(GfxState *state);
virtual void updateRender(GfxState *state);
//----- path painting
virtual void stroke(GfxState *state);
......@@ -328,7 +327,6 @@ protected:
GBool haveCSPattern; // set if text has been drawn with a
// clipping render mode because of pattern colorspace
int savedRender; // use if pattern colorspace
};
//------------------------------------------------------------------------
......
......@@ -3342,7 +3342,7 @@ void Gfx::opBeginText(Object args[], int numArgs) {
out->updateTextMat(state);
out->updateTextPos(state);
fontChanged = gTrue;
if (out->supportTextCSPattern(state)) {
if (!(state->getRender() & 4) && out->supportTextCSPattern(state)) {
textHaveCSPattern = gTrue;
}
}
......@@ -3397,10 +3397,23 @@ void Gfx::opSetTextLeading(Object args[], int numArgs) {
}
void Gfx::opSetTextRender(Object args[], int numArgs) {
int rm = state->getRender();
state->setRender(args[0].getInt());
if (args[0].getInt() == 7) {
textHaveCSPattern = gFalse;
}
if ((args[0].getInt() & 4) && textHaveCSPattern && drawText) {
GBool needFill = out->deviceHasTextClip(state);
out->endTextObject(state);
if (needFill) {
doPatternFill(gTrue);
}
out->restoreState(state);
out->beginTextObject(state);
out->updateTextMat(state);
out->updateTextPos(state);
textHaveCSPattern = gFalse;
} else if ((rm & 4) && !(args[0].getInt() & 4) && out->supportTextCSPattern(state) && drawText) {
out->beginTextObject(state);
textHaveCSPattern = gTrue;
}
out->updateRender(state);
}
......
......@@ -20,7 +20,7 @@
// Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org>
// Copyright (C) 2008, 2009 Koji Otani <sho@bbr.jp>
// Copyright (C) 2008 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2009 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2009, 2010 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2009 William Bader <williambader@hotmail.com>
......@@ -125,7 +125,7 @@ static char *prolog[] = {
"~1sn",
"/pdfOpNames [",
" /pdfFill /pdfStroke /pdfLastFill /pdfLastStroke",
" /pdfTextMat /pdfFontSize /pdfCharSpacing /pdfTextRender",
" /pdfTextMat /pdfFontSize /pdfCharSpacing /pdfTextRender /pdfPatternCS",
" /pdfTextRise /pdfWordSpacing /pdfHorizScaling /pdfTextClipPath",
"] def",
"~123sn",
......@@ -157,6 +157,7 @@ static char *prolog[] = {
" /pdfFontSize 0 def",
" /pdfCharSpacing 0 def",
" /pdfTextRender 0 def",
" /pdfPatternCS false def",
" /pdfTextRise 0 def",
" /pdfWordSpacing 0 def",
" /pdfHorizScaling 1 def",
......@@ -398,6 +399,7 @@ static char *prolog[] = {
" pdfTextMat matrix concatmatrix dup 4 0 put dup 5 0 put",
" exch findfont exch makefont setfont } def",
"/Tr { /pdfTextRender exch def } def",
"/Tp { /pdfPatternCS exch def } def",
"/Ts { /pdfTextRise exch def } def",
"/Tw { /pdfWordSpacing exch def } def",
"/Tz { /pdfHorizScaling exch def } def",
......@@ -469,7 +471,7 @@ static char *prolog[] = {
"/Tj1 {",
" 0 pdfTextRise pdfTextMat dtransform rmoveto",
" currentpoint 8 2 roll",
" pdfTextRender 1 and 0 eq {",
" pdfTextRender 1 and 0 eq pdfPatternCS not and {",
" 6 copy awidthshow",
" } if",
" pdfTextRender 3 and dup 1 eq exch 2 eq or {",
......@@ -478,7 +480,7 @@ static char *prolog[] = {
" currentfont /FontType get 3 eq { fCol } { sCol } ifelse",
" false awcp currentpoint stroke moveto",
" } if",
" pdfTextRender 4 and 0 ne {",
" pdfTextRender 4 and 0 ne pdfPatternCS or {",
" 8 6 roll moveto",
" false awcp",
" /pdfTextClipPath [ pdfTextClipPath aload pop",
......@@ -3708,10 +3710,6 @@ void PSOutputDev::updateRender(GfxState *state) {
int rm;
rm = state->getRender();
if (rm == 7 && haveCSPattern) {
haveCSPattern = gFalse;
restoreState(state);
}
writePSFmt("{0:d} Tr\n", rm);
rm &= 3;
if (rm != 0 && rm != 3) {
......@@ -3807,7 +3805,8 @@ GBool PSOutputDev::tilingPatternFill(GfxState *state, Object *str,
if (paintType == 2) {
writePSFmt("{0:.4g} 0 {1:.4g} {2:.4g} {3:.4g} {4:.4g} setcachedevice\n",
xStep, bbox[0], bbox[1], bbox[2], bbox[3]);
} else {
} else
{
if (x1 - 1 <= x0) {
writePS("1 0 setcharwidth\n");
} else {
......@@ -4359,7 +4358,7 @@ void PSOutputDev::drawString(GfxState *state, GooString *s) {
}
delete s2;
if (state->getRender() & 4) {
if (state->getRender() & 4 || haveCSPattern) {
haveTextClip = gTrue;
}
}
......@@ -4368,9 +4367,7 @@ void PSOutputDev::beginTextObject(GfxState *state) {
if (state->getFillColorSpace()->getMode() == csPattern) {
saveState(state);
haveCSPattern = gTrue;
savedRender = state->getRender();
state->setRender(7);
writePSFmt("{0:d} Tr\n", 7);
writePS("true Tp\n");
}
}
......@@ -4379,7 +4376,6 @@ void PSOutputDev::endTextObject(GfxState *state) {
if (haveTextClip) {
writePS("Tclip*\n");
haveTextClip = gFalse;
state->setRender(savedRender);
if (state->getFillColorSpace()->getMode() != csPattern) {
double cxMin, cyMin, cxMax, cyMax;
state->getClipBBox(&cxMin, &cyMin, &cxMax, &cyMax);
......@@ -4390,8 +4386,6 @@ void PSOutputDev::endTextObject(GfxState *state) {
restoreState(state);
updateFillColor(state);
}
} else {
state->setRender(savedRender);
}
haveCSPattern = gFalse;
} else if (haveTextClip) {
......
......@@ -17,7 +17,7 @@
// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2006-2008 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Brad Hards <bradh@kde.org>
// Copyright (C) 2009 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2009, 2010 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2009 William Bader <williambader@hotmail.com>
......@@ -427,7 +427,6 @@ private:
// clipping render mode
GBool haveCSPattern; // set if text has been drawn with a
// clipping render mode because of pattern colorspace
int savedRender; // use if pattern colorspace
GBool inType3Char; // inside a Type 3 CharProc
GooString *t3String; // Type 3 content string
......
......@@ -1225,15 +1225,6 @@ void SplashOutputDev::updateFont(GfxState * /*state*/) {
needFontUpdate = gTrue;
}
void SplashOutputDev::updateRender(GfxState *state) {
int rm;
rm = state->getRender();
if (rm == 7 && haveCSPattern) {
haveCSPattern = gFalse;
restoreState(state);
}
}
void SplashOutputDev::doUpdateFont(GfxState *state) {
GfxFont *gfxFont;
GfxFontType fontType;
......@@ -1621,7 +1612,7 @@ void SplashOutputDev::drawChar(GfxState *state, double x, double y,
// fill
if (!(render & 1)) {
if (!state->getFillColorSpace()->isNonMarking()) {
if (!haveCSPattern && !state->getFillColorSpace()->isNonMarking()) {
splash->fillChar((SplashCoord)x, (SplashCoord)y, code, font);
}
}
......@@ -1638,7 +1629,7 @@ void SplashOutputDev::drawChar(GfxState *state, double x, double y,
}
// clip
if (render & 4) {
if (haveCSPattern || (render & 4)) {
if ((path = font->getGlyphPath(code))) {
path->offset((SplashCoord)x, (SplashCoord)y);
if (textClipPath) {
......@@ -1927,17 +1918,14 @@ void SplashOutputDev::drawType3Glyph(T3FontCache *t3Font,
}
void SplashOutputDev::beginTextObject(GfxState *state) {
if (state->getFillColorSpace()->getMode() == csPattern) {
if (!(state->getRender() & 4) && state->getFillColorSpace()->getMode() == csPattern) {
haveCSPattern = gTrue;
saveState(state);
savedRender = state->getRender();
state->setRender(7);
}
}
void SplashOutputDev::endTextObject(GfxState *state) {
if (haveCSPattern) {
state->setRender(savedRender);
haveCSPattern = gFalse;
if (state->getFillColorSpace()->getMode() != csPattern) {
if (textClipPath) {
......
......@@ -116,7 +116,6 @@ public:
//----- update text state
virtual void updateFont(GfxState *state);
virtual void updateRender(GfxState *state);
//----- path painting
virtual void stroke(GfxState *state);
......@@ -246,8 +245,7 @@ private:
Guchar *alphaLine);
GBool haveCSPattern; // set if text has been drawn with a
// clipping render mode because of pattern colorspace
int savedRender; // use if pattern colorspace
// clipping render mode because of pattern colorspace
GBool keepAlphaChannel; // don't fill with paper color, keep alpha channel
SplashColorMode colorMode;
......
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