Browse Source

Fixed regression introduced with rev 1095887:

Painting state was not properly handled when painting text runs which could lead to missing color setters and therefore wrong font colors.
Removed save/restoreGraphicsState from PDFTextUtil as that doesn't update the painting state. Instead the code is now using equivalent methods from PDFGraphics2D.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1135540 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_1rc1old
Jeremias Maerki 13 years ago
parent
commit
860ebd1410

+ 1
- 16
src/java/org/apache/fop/pdf/PDFTextUtil.java View File

private void writeChar(char ch, StringBuffer sb) { private void writeChar(char ch, StringBuffer sb) {
if (!useMultiByte) { if (!useMultiByte) {
if (ch < 32 || ch > 127) { if (ch < 32 || ch > 127) {
sb.append("\\").append(Integer.toOctalString((int)ch));
sb.append("\\").append(Integer.toOctalString(ch));
} else { } else {
switch (ch) { switch (ch) {
case '(': case '(':
this.textRenderingMode = TR_FILL; this.textRenderingMode = TR_FILL;
} }


/**
* Creates a "q" command, pushing a copy of the entire graphics state onto the stack.
*/
public void saveGraphicsState() {
write("q\n");
}

/**
* Creates a "Q" command, restoring the entire graphics state to its former value by popping
* it from the stack.
*/
public void restoreGraphicsState() {
write("Q\n");
}

/** /**
* Creates a "cm" command. * Creates a "cm" command.
* @param at the transformation matrix * @param at the transformation matrix

+ 16
- 12
src/java/org/apache/fop/svg/PDFGraphics2D.java View File

&& !trans.isIdentity(); && !trans.isIdentity();


if (newClip || newTransform) { if (newClip || newTransform) {
currentStream.write("q\n");
paintingState.save();
saveGraphicsState();
if (newTransform) { if (newTransform) {
concatMatrix(tranvals); concatMatrix(tranvals);
} }
applyUnknownPaint(paint, ss); applyUnknownPaint(paint, ss);


if (newClip || newTransform) { if (newClip || newTransform) {
currentStream.write("Q\n");
paintingState.restore();
restoreGraphicsState();
} }
return; return;
} }
processPathIterator(iter); processPathIterator(iter);
doDrawing(false, true, false); doDrawing(false, true, false);
if (newClip || newTransform) { if (newClip || newTransform) {
currentStream.write("Q\n");
paintingState.restore();
restoreGraphicsState();
} }
} }


&& !trans.isIdentity(); && !trans.isIdentity();


if (newClip || newTransform) { if (newClip || newTransform) {
currentStream.write("q\n");
paintingState.save();
saveGraphicsState();
if (newTransform) { if (newTransform) {
concatMatrix(tranvals); concatMatrix(tranvals);
} }
applyUnknownPaint(paint, s); applyUnknownPaint(paint, s);


if (newClip || newTransform) { if (newClip || newTransform) {
currentStream.write("Q\n");
paintingState.restore();
restoreGraphicsState();
} }
return; return;
} }
iter.getWindingRule() == PathIterator.WIND_EVEN_ODD); iter.getWindingRule() == PathIterator.WIND_EVEN_ODD);
} }
if (newClip || newTransform) { if (newClip || newTransform) {
currentStream.write("Q\n");
paintingState.restore();
restoreGraphicsState();
} }
} }


void saveGraphicsState() {
currentStream.write("q\n");
paintingState.save();
}

void restoreGraphicsState() {
currentStream.write("Q\n");
paintingState.restore();
}

/** Checks whether the use of transparency is allowed. */ /** Checks whether the use of transparency is allowed. */
protected void checkTransparencyAllowed() { protected void checkTransparencyAllowed() {
pdfDoc.getProfile().verifyTransparencyAllowed("Java2D graphics"); pdfDoc.getProfile().verifyTransparencyAllowed("Java2D graphics");

+ 6
- 2
src/java/org/apache/fop/svg/PDFTextPainter.java View File

} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
protected boolean isSupported(Graphics2D g2d) { protected boolean isSupported(Graphics2D g2d) {
return g2d instanceof PDFGraphics2D; return g2d instanceof PDFGraphics2D;
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
protected void paintTextRun(TextRun textRun, Graphics2D g2d) { protected void paintTextRun(TextRun textRun, Graphics2D g2d) {
AttributedCharacterIterator runaci = textRun.getACI(); AttributedCharacterIterator runaci = textRun.getACI();
runaci.first(); runaci.first();
runaci.first(); //Reset ACI runaci.first(); //Reset ACI


final PDFGraphics2D pdf = (PDFGraphics2D)g2d; final PDFGraphics2D pdf = (PDFGraphics2D)g2d;

PDFTextUtil textUtil = new PDFTextUtil(pdf.fontInfo) { PDFTextUtil textUtil = new PDFTextUtil(pdf.fontInfo) {
@Override
protected void write(String code) { protected void write(String code) {
pdf.currentStream.write(code); pdf.currentStream.write(code);
} }
return; return;
} }


textUtil.saveGraphicsState();
pdf.saveGraphicsState();
textUtil.concatMatrix(g2d.getTransform()); textUtil.concatMatrix(g2d.getTransform());
Shape imclip = g2d.getClip(); Shape imclip = g2d.getClip();
pdf.writeClip(imclip); pdf.writeClip(imclip);
} }
textUtil.writeTJ(); textUtil.writeTJ();
textUtil.endTextObject(); textUtil.endTextObject();
textUtil.restoreGraphicsState();
pdf.restoreGraphicsState();
if (DEBUG) { if (DEBUG) {
g2d.setStroke(new BasicStroke(0)); g2d.setStroke(new BasicStroke(0));
g2d.setColor(Color.LIGHT_GRAY); g2d.setColor(Color.LIGHT_GRAY);

Loading…
Cancel
Save