From 15ff235985fdd318c7d4e552822c6e91a5410af0 Mon Sep 17 00:00:00 2001 From: David Gilbert Date: Sun, 7 Nov 2021 09:32:36 +0100 Subject: [PATCH] Add handling for TextAttribute.TRACKING and update to release 5.0.2 --- README.md | 9 +++++---- jfreesvg.svg | 2 +- pom.xml | 2 +- src/main/java/org/jfree/svg/SVGGraphics2D.java | 9 +++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c8e9ca3..39838ce 100644 --- a/README.md +++ b/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. @@ -31,7 +31,7 @@ JFreeSVG is published to the Central Repository. You can include it in your pro org.jfree org.jfree.svg - 5.0.1 + 5.0.2 JFreeSVG is a modular library with the module name `org.jfree.svg`. @@ -41,7 +41,7 @@ To use JFreeSVG with Java 8, you can use the following (note the different artif org.jfree jfreesvg - 3.4.1 + 3.4.2 Build @@ -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) diff --git a/jfreesvg.svg b/jfreesvg.svg index aca864d..7274b7d 100644 --- a/jfreesvg.svg +++ b/jfreesvg.svg @@ -1,2 +1,2 @@ -Graphics2D Testertarget -> JFree/SVGGraphics2Dtimestamp -> 2021-08-04T21:08:57.034145os.name -> Mac OS Xos.version -> 10.16os.arch -> x86_64java.runtime.version -> 15.0.1+8java.vm.name -> OpenJDK 64-Bit Server VMjava.vendor.version -> Zulu15.28+13-CASelected NZ Exports Sept 2020Source: https://statisticsnz.shinyapps.io/trade_dashboard/BeveragesUSADairyTravelMeatServicesOther GoodsUnited KingdomWoodChinaAustraliaFruit & NutsGoods-3-2-10123X-1.0-0.50.00.51.0Y-3-2-10123Z-1.001.00SurfaceRendererDemo1y = cos(x) * sin(z)Serif Font 14ptSans Serif Font 14ptMonospaced Font 14ptJava2D!Murphy ÉOKTab 2Tab 145 +Graphics2D Testertarget -> JFree/SVGGraphics2Dtimestamp -> 2021-11-07T09:26:41.669878os.name -> Mac OS Xos.version -> 11.5os.arch -> x86_64java.runtime.version -> 16.0.2+7java.vm.name -> OpenJDK 64-Bit Server VMjava.vendor.version -> Zulu16.32+15-CASelected NZ Exports Sept 2020Source: https://statisticsnz.shinyapps.io/trade_dashboard/BeveragesUSADairyTravelMeatServicesOther GoodsUnited KingdomWoodChinaAustraliaFruit & NutsGoods-3-2-10123X-1.0-0.50.00.51.0Y-3-2-10123Z-1.001.00SurfaceRendererDemo1y = cos(x) * sin(z)Serif Font 14ptSans Serif Font 14ptMonospaced Font 14ptJava2D!Murphy ÉTracking: TRACKING_LOOSETracking: NoneTracking: TRACKING_TIGHTOKTab 2Tab 145 diff --git a/pom.xml b/pom.xml index e7c9512..5f78d4a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.jfree org.jfree.svg - 5.0.2-SNAPSHOT + 5.0.2 jar JFreeSVG diff --git a/src/main/java/org/jfree/svg/SVGGraphics2D.java b/src/main/java/org/jfree/svg/SVGGraphics2D.java index ffdcf3f..d996c8a 100644 --- a/src/main/java/org/jfree/svg/SVGGraphics2D.java +++ b/src/main/java/org/jfree/svg/SVGGraphics2D.java @@ -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; @@ -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(); }