FontMetrics
Andrea Liana
andrea.liana at ingliana.com
Thu Oct 4 12:41:34 UTC 2018
Hello,
Its my first time I contribute to a mailing list, maybe not in proper
way, but lets talk about Font Metrics.
I've been tinkering fro Java 8 with JavaFX and still I am.
I am working on framework in order to replace my old AWT/Swing based one
in production.
About FontMetrics, it was one of the first problem I encountered when I
built from scratch a new table component. Sorry for JavaFX, but the
default one is quite hard to manage. To solve that, after digging all
around, the easiest way to manage was to create an instance of
javafx.scene.text.Text in the skin class and use it when calculating
layout and text position.
The code looks like:
private final Texttext =new Text(); ....
text.setText(column._title); text.setFont(HeaderFont); final Bounds
bounds = text.getLayoutBounds(); ... // Use bounds for text measurement...
Maybe its not the best or elegant way, but for the moment it works. In
my opinion font measurements should be baked into the Font class
directly instead of adding more classes.
Andrea Liana
More information about the openjfx-discuss
mailing list