Skip to content

Commit

Permalink
Add handling for TextAttribute.TRACKING and update to release 5.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jfree committed Nov 7, 2021
1 parent 843236f commit 15ff235
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
9 changes: 5 additions & 4 deletions README.md
@@ -1,7 +1,7 @@
JFreeSVG
========

Version 5.0.1, by David Gilbert, 4 August 2021.
Version 5.0.2, by David Gilbert, 7 November 2021.

(C)opyright 2013-2021, by David Gilbert. All rights reserved.

Expand Down Expand Up @@ -31,7 +31,7 @@ JFreeSVG is published to the Central Repository. You can include it in your pro
<dependency>
<groupId>org.jfree</groupId>
<artifactId>org.jfree.svg</artifactId>
<version>5.0.1</version>
<version>5.0.2</version>
</dependency>

JFreeSVG is a modular library with the module name `org.jfree.svg`.
Expand All @@ -41,7 +41,7 @@ To use JFreeSVG with Java 8, you can use the following (note the different artif
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreesvg</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</dependency>

Build
Expand Down Expand Up @@ -75,7 +75,8 @@ JFreeSVG is free software under the terms of the GNU General Public License vers
Change History
--------------

Version 5.0.2 (not yet released)
Version 5.0.2 (7 November 2021)
- add support for `TextAttribute.TRACKING`;
- clarified Javadocs for `SVGHints.KEY_BEGIN_GROUP`.

Version 5.0.1 (4 August 2021)
Expand Down
2 changes: 1 addition & 1 deletion jfreesvg.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -5,7 +5,7 @@

<groupId>org.jfree</groupId>
<artifactId>org.jfree.svg</artifactId>
<version>5.0.2-SNAPSHOT</version>
<version>5.0.2</version>
<packaging>jar</packaging>

<name>JFreeSVG</name>
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/jfree/svg/SVGGraphics2D.java
Expand Up @@ -52,6 +52,7 @@
import java.awt.Stroke;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import java.awt.geom.Arc2D;
Expand Down Expand Up @@ -1550,6 +1551,14 @@ private String getSVGFontStyle() {
if (this.font.isItalic()) {
b.append(" font-style: italic;");
}
Object tracking = this.font.getAttributes().get(TextAttribute.TRACKING);
if (tracking instanceof Number) {
double spacing = ((Number) tracking).doubleValue() * this.font.getSize();
if (Math.abs(spacing) > 0.000001) { // not zero
b.append(" letter-spacing: ").append(geomDP(spacing)).append(';');
}
}

return b.toString();
}

Expand Down

0 comments on commit 15ff235

Please sign in to comment.