4

So i'm not clear on something. How does JavaFX handle variable fonts?

For example, I have this Roboto Variable Font. I have embedded it into my application via CSS. It seems however, to only use the Regular variant.

Specifying font weight (numerical values) does not change the rendered font. I want to be able to use thin (100) all to black (900) font weights.

I also tried using different fonts for different variations, but I couldn't declare any weight that was not bold. I did something like this:

@font-face { //Valid and reflects style
    font-family: "Roboto";
    src: url("res/Roboto-BoldItalic.otf") format("opentype");
    font-weight: bold;
    font-style: italic;
}
@font-face {
    font-family: "Roboto";
    src: url("res/Roboto-BlackItalic.otf") format("opentype");
    font-weight: extra_bold; //Invalid even when I use 900 (numerical value for extra bold)
    font-style: italic;
}

I'd like to use the variable font (because the size is smaller) but if I can get it to work with using multiple fonts, i'll take it at this time.

How should I go about it?

  • Also having this issue, we used separate variables in the end, see https://github.com/software-challenge/gui/pull/83/files – xeruf Jul 26 '22 at 06:07

0 Answers0