diff options
author | Simon Steiner <ssteiner@apache.org> | 2020-05-27 11:48:14 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2020-05-27 11:48:14 +0000 |
commit | 0cd45a6cbb6e76f94d1e6fdcb287cdeaa8e68c99 (patch) | |
tree | b40996d91270b680c87b8520bfd44e1f15c40393 | |
parent | 40a5599aba8e061124b7177388be9ca10c4a8757 (diff) | |
download | xmlgraphics-fop-0cd45a6cbb6e76f94d1e6fdcb287cdeaa8e68c99.tar.gz xmlgraphics-fop-0cd45a6cbb6e76f94d1e6fdcb287cdeaa8e68c99.zip |
FOP-2941: SVG container with stroke=black has an unexpected border
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1878158 13f79535-47bb-0310-9956-ffa450edef68
4 files changed, 26 insertions, 6 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/PSTextPainter.java b/fop-core/src/main/java/org/apache/fop/render/ps/PSTextPainter.java index 57397efc6..8c643b7a5 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/PSTextPainter.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/PSTextPainter.java @@ -420,6 +420,9 @@ public class PSTextPainter extends NativeTextPainter { private void paintStrokedGlyphs(PSGraphics2D g2d, TextUtil textUtil, Paint strokePaint, Stroke stroke) throws IOException { + if (currentGlyphs.toString().trim().isEmpty()) { + return; + } applyColor(strokePaint); PSGraphics2D.applyStroke(stroke, gen); diff --git a/fop-core/src/test/java/org/apache/fop/svg/NativeTextPainterTest.java b/fop-core/src/test/java/org/apache/fop/svg/NativeTextPainterTest.java index 5344e6a54..aa3019c9c 100644 --- a/fop-core/src/test/java/org/apache/fop/svg/NativeTextPainterTest.java +++ b/fop-core/src/test/java/org/apache/fop/svg/NativeTextPainterTest.java @@ -40,13 +40,14 @@ import org.apache.fop.svg.font.FOPFontFamilyResolverImpl; abstract class NativeTextPainterTest { - protected final void runTest(String testcase, OperatorValidator validator) throws Exception { + protected final Graphics2D runTest(String testcase, OperatorValidator validator) throws Exception { FontInfo fontInfo = createFontInfo(); BridgeContext bridgeContext = createBridgeContext(fontInfo); GraphicsNode svg = loadSVG(bridgeContext, testcase); Graphics2D g2d = createGraphics2D(fontInfo, validator); svg.paint(g2d); validator.end(); + return g2d; } private FontInfo createFontInfo() { diff --git a/fop-core/src/test/java/org/apache/fop/svg/PSTextPainterTestCase.java b/fop-core/src/test/java/org/apache/fop/svg/PSTextPainterTestCase.java index 2b716e348..7a2eb7027 100644 --- a/fop-core/src/test/java/org/apache/fop/svg/PSTextPainterTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/svg/PSTextPainterTestCase.java @@ -20,12 +20,13 @@ package org.apache.fop.svg; import java.awt.Graphics2D; +import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.OutputStream; +import org.junit.Assert; import org.junit.Test; -import org.apache.commons.io.output.NullOutputStream; - import org.apache.batik.bridge.TextPainter; import org.apache.xmlgraphics.java2d.GraphicContext; @@ -40,13 +41,12 @@ public class PSTextPainterTestCase extends NativeTextPainterTest { private static class OperatorCheckingPSGraphics2D extends PSGraphics2D { OperatorCheckingPSGraphics2D(FontInfo fontInfo, final OperatorValidator validator) { - super(false, new PSGenerator(new NullOutputStream()) { - + super(false, new PSGenerator(new ByteArrayOutputStream()) { @Override public void writeln(String cmd) throws IOException { + super.writeln(cmd); validator.check(cmd); } - }); } } @@ -74,4 +74,11 @@ public class PSTextPainterTestCase extends NativeTextPainterTest { .addOperatorMatch("xshow", "(C)\n[0] xshow")); } + @Test + public void testWatermark() throws Exception { + PSGraphics2D g2d = (PSGraphics2D) runTest("watermark.svg", + new OperatorValidator().addOperatorMatch("GS", "GS")); + OutputStream os = g2d.getPSGenerator().getOutputStream(); + Assert.assertFalse(os.toString().contains("( ) false charpath")); + } } diff --git a/fop-core/src/test/resources/org/apache/fop/svg/watermark.svg b/fop-core/src/test/resources/org/apache/fop/svg/watermark.svg new file mode 100644 index 000000000..fc2c6d97e --- /dev/null +++ b/fop-core/src/test/resources/org/apache/fop/svg/watermark.svg @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- Generator: Adobe Illustrator 10.0, SVG Export Plug-In . SVG Version: 3.0.0 Build 43) --> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" width="1170" height="1100" viewBox="0 0 1200.607 1722.573" enable-background="new 0 0 900.407 1522.273" xml:space="preserve"> + <g id="Layer_1" stroke="#000000"> + <text transform="matrix(0.5826 -0.8128 0.8128 0.5826 81.2793 600.3428)"> + <tspan x="0" y="0" fill="#E6E6E6" stroke="none" font-family="'Arial'" font-size="200">Copy</tspan> + </text> + </g> +</svg> |