'JavaFX - slider ticks displaying strange characters instead of numbers

I have these sliders here:

Sliders

And as you can see, they have the weirdest characters. How do I fix this/make them regular numbers? I've tried everything from setting the style of the scene to:

scene.getRoot().setStyle("-fx-font-family: 'serif'");

and also setting each slider, the panes, the HBox etc to the above, like so:

slider.setStyle("-fx-font-family: 'serif'");
slider.styleProperty().set("-fx-font-family: 'serif'");
slider.styleProperty().setValue("-fx-font-family: 'serif'");
sliderPane.setStyle("-fx-font-family: 'serif'");
hBox.setStyle("-fx-font-family: 'serif'");
this.setStyle("-fx-font-family: 'serif'");

I did this because something similar occurred with the slider labels as well, and setting the scene style to the serif font fixed it. But this time, nothing worked for the slider tick labels. Any idea what might be causing this?



Solution 1:[1]

I believe this is a duplicate of https://stackoverflow.com/a/39200640/3196753, filed upstream here: https://bugs.openjdk.java.net/browse/JDK-8242617. But since this issue is so hard to find online, I've decided to link the above two issues rather than marking it as a duplicate, since the original question was never marked as answered.

I've filed a bug report with Gluon in 2020 about this problem (it's still open) but it's a private bug system, so I'm copying and pasting it here in hopes it will show up more in search results.

When printing a JavaFX WebView, certain fonts corrupt if they also exist locally on the system.

Steps:

  1. Create a JavaFX WebView which calls PrinterJob.printPage(Node)
  2. Create an HTML+CSS sample that loads a web font
  3. Install the OpenType web font locally
  4. Observe texts corruption (e.g "Hello world" prints as "?? ???B ???Í ")

Workaround:

  1. Remove the offending OpenType font from the computer

Furthermore, I'm quoting an answer from the duplicate stackoverflow question:

The problem you encountered has nothing to do with encoding. The JavaFx WebView has some problems with loading local fonts. If you load a website which wants to load a local font installed on your computer you will see this cryptic letters. If you remove the font you will see the text as usual.

So your problem isn't the encoding of the website, it's the font spotify want's to load and you are having local on your pc.

You will have to find a way to stop the WebView from loading local fonts. Maybe by injecting some code.

If you have a support subscription with an OpenJDK or OpenJFX vendor, I would encourage opening up a bug report on this. Meanwhile, the workaround of removing the OpenType font was a viable workaround for the user I was working with.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1