diff options
author | kitfox | 2012-07-11 07:17:46 +0200 |
---|---|---|
committer | kitfox | 2012-07-11 07:17:46 +0200 |
commit | b4e88ac42c444e4ed98b3f6d69187f78eed397b5 (patch) | |
tree | d7d42d9c4165ff9a7eb46cbbc8e412845aa6fbff /src | |
parent | Can now safely update trees that contain embedded images. (diff) | |
download | svg-salamander-core-b4e88ac42c444e4ed98b3f6d69187f78eed397b5.tar.gz svg-salamander-core-b4e88ac42c444e4ed98b3f6d69187f78eed397b5.tar.xz svg-salamander-core-b4e88ac42c444e4ed98b3f6d69187f78eed397b5.zip |
Adding support for 'letter-spacing' attr in Tspan element.
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@117 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/kitfox/svg/Tspan.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/com/kitfox/svg/Tspan.java b/src/main/java/com/kitfox/svg/Tspan.java index bffa6b8..ceaa394 100644 --- a/src/main/java/com/kitfox/svg/Tspan.java +++ b/src/main/java/com/kitfox/svg/Tspan.java @@ -159,12 +159,19 @@ public class Tspan extends ShapeElement { {
fontSize = sty.getFloatValueWithUnits();
}
+
+ float letterSpacing = 0;
+ if (getStyle(sty.setName("letter-spacing")))
+ {
+ letterSpacing = sty.getFloatValueWithUnits();
+ }
+
//Get font
Font font = diagram.getUniverse().getFont(fontFamily);
if (font == null)
{
- addShapeSysFont(addShape, font, fontFamily, fontSize);
+ addShapeSysFont(addShape, font, fontFamily, fontSize, letterSpacing);
return;
}
@@ -206,13 +213,14 @@ public class Tspan extends ShapeElement { cursorY += dy[posPtr++];
}
- cursorX += fontScale * glyph.getHorizAdvX();
+ cursorX += fontScale * glyph.getHorizAdvX() + letterSpacing;
}
strokeWidthScalar = 1f;
}
- private void addShapeSysFont(GeneralPath addShape, Font font, String fontFamily, float fontSize)
+ private void addShapeSysFont(GeneralPath addShape, Font font,
+ String fontFamily, float fontSize, float letterSpacing)
{
java.awt.Font sysFont = new java.awt.Font(fontFamily, java.awt.Font.PLAIN, (int)fontSize);
@@ -225,7 +233,7 @@ public class Tspan extends ShapeElement { for (int i = 0; i < text.length(); i++)
{
xform.setToIdentity();
- xform.setToTranslation(cursorX, cursorY);
+ xform.setToTranslation(cursorX + i * letterSpacing, cursorY);
if (rotate != null) xform.rotate(rotate[Math.min(i, rotate.length - 1)]);
String unicode = text.substring(i, i + 1);
|