Cannot request weight or font style with getFont

Suppose I have a label in my application that uses some font (javafx.text.Font). My application does not know this font (not constants), but can get the Font object from the label.

Now I want to create a new font based on the current font of this shortcut. So I would write something like this:

Font font = label.getFont();
Font modifiedFont = deriveFont(font, FontWeight.BOLD);

Problem: I can only get the name / font family and size. But I can’t ask for weight or style. In addition, there is no method deriveFont(), for example, with AWT fonts.

So how should I create a derived font in JavaFX? Or is it simply impossible (at the moment)?

+4
source share

All Articles