From d997987aae2e0c7490ab54138c3b46bfd9d50539 Mon Sep 17 00:00:00 2001 From: kitfox Date: Sun, 10 Aug 2014 03:51:34 +0000 Subject: Fixing SVGSALAMANDER-40. Now trimming leading and trailing whitespace from text elements. Fixing SVGSALAMANDER-44. Raster will now check for changes in height when resizing PatternPaintContext. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@183 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- src/main/java/com/kitfox/svg/Text.java | 11 ++++++----- src/main/java/com/kitfox/svg/pattern/PatternPaintContext.java | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main/java/com/kitfox/svg/Text.java b/src/main/java/com/kitfox/svg/Text.java index 2ab9a0a..a83c389 100644 --- a/src/main/java/com/kitfox/svg/Text.java +++ b/src/main/java/com/kitfox/svg/Text.java @@ -351,14 +351,14 @@ public class Text extends ShapeElement case TXAN_MIDDLE: { AffineTransform at = new AffineTransform(); - at.translate(-textPath.getBounds2D().getWidth() / 2, 0); + at.translate(-textPath.getBounds().getWidth() / 2, 0); textPath.transform(at); break; } case TXAN_END: { AffineTransform at = new AffineTransform(); - at.translate(-textPath.getBounds2D().getWidth(), 0); + at.translate(-textPath.getBounds().getWidth(), 0); textPath.transform(at); break; } @@ -389,7 +389,8 @@ public class Text extends ShapeElement if (obj instanceof String) { - String text = (String) obj; + String text = (String)obj; + text = text.trim(); Shape textShape = font.createGlyphVector(frc, text).getOutline(cursorX, cursorY); textPath.append(textShape, false); @@ -429,14 +430,14 @@ public class Text extends ShapeElement case TXAN_MIDDLE: { AffineTransform at = new AffineTransform(); - at.translate(-textPath.getBounds2D().getWidth() / 2, 0); + at.translate(-textPath.getBounds().getWidth() / 2, 0); textPath.transform(at); break; } case TXAN_END: { AffineTransform at = new AffineTransform(); - at.translate(-textPath.getBounds2D().getWidth(), 0); + at.translate(-Math.ceil(textPath.getBounds().getWidth()), 0); textPath.transform(at); break; } diff --git a/src/main/java/com/kitfox/svg/pattern/PatternPaintContext.java b/src/main/java/com/kitfox/svg/pattern/PatternPaintContext.java index a0bdc92..49c8c2c 100644 --- a/src/main/java/com/kitfox/svg/pattern/PatternPaintContext.java +++ b/src/main/java/com/kitfox/svg/pattern/PatternPaintContext.java @@ -96,7 +96,7 @@ public class PatternPaintContext implements PaintContext public Raster getRaster(int x, int y, int w, int h) { //System.err.println("" + x + ", " + y + ", " + w + ", " + h); - if (buf == null || buf.getWidth() != w || buf.getHeight() != buf.getHeight()) + if (buf == null || buf.getWidth() != w || buf.getHeight() != h) { buf = new BufferedImage(w, h, source.getType()); } -- cgit v1.2.3-55-g7522