Font metrics in JavaFX Canvas
David Gilbert
dave at jfree.org
Thu Nov 30 07:26:31 UTC 2017
Hello,
I have an open source project FXGraphics2D [1] that provides a Graphics2D API for the JavaFX canvas. It is open source and used to provide JavaFX support for JFreeChart [2] and Orson Charts [3]. It can also be used more generally for any code that targets the Java2D API.
One limitation that I’ve encountered is that there is no API to get font metrics for fonts rendered on the JavaFX canvas, so it is difficult to implement the method Graphics2D.getFontMetrics(Font f) accurately. As a result, text alignment is difficult, for example see the tick labels on the vertical axis in this chart:
http://www.jfree.org/jfreechart/fxgraphics2d-font-issue.png
There is a feature request in the bug tracker, open for some time, that targets this particular feature. I’d like to highlight it for (hopefully) some attention in a future JDK release:
https://bugs.openjdk.java.net/browse/JDK-8090775 <https://bugs.openjdk.java.net/browse/JDK-8090775>
Best regards,
David Gilbert
[1] https://github.com/jfree/fxgraphics2d <https://github.com/jfree/fxgraphics2d>
[2] https://github.com/jfree/jfreechart-fx <https://github.com/jfree/jfreechart-fx>
[3] https://github.com/jfree/orson-charts-fx <https://github.com/jfree/orson-charts-fx>
More information about the openjfx-dev
mailing list