1

I want to use the font Arial Unicode MS in my JavaFX project which works fine. But i want e.g. the headlines to be bold. But I don't get the bold font working. What's the probleme here?

I tried it with css and within the code directly

.bold-font {
    -fx-font-family: Arial Unicode MS;
    -fx-font-weight: bold;
}

and

label.setFont( Font.font("Arial Unicode MS", FontWeight.BOLD,24));

Nothing worked and when i check the font after setting with "getFont()" it is still regular.

Tobi F
  • 15
  • 4
  • Does the font family support bold? – Slaw Jun 24 '19 at 18:49
  • Yes there is a bold version of Arial Unicode MS in Java Swing. Only in JavaFx it does not work. The Syntax should be right, because when using default Arial it works. – Tobi F Jun 25 '19 at 05:43
  • On my computer (Windows 10) JavaFX (12.0.1) doesn't have _Arial Unicode MS_. You can check what's available via [`Font.getFamilies()`](https://openjfx.io/javadoc/12/javafx.graphics/javafx/scene/text/Font.html#getFamilies())/[`Font.getFontNames()`](https://openjfx.io/javadoc/12/javafx.graphics/javafx/scene/text/Font.html#getFontNames()). – Slaw Jun 25 '19 at 05:51
  • Not? I have Windows 10 and using Java 8. I can use the Arial Unicode, but using your command Font.getFontNames() shows me that there is only the normal Arial Unicode MS available. Thank you for your help! – Tobi F Jun 25 '19 at 07:50
  • Note you can add fonts using one of the `Font#loadFont[s]` methods. I believe JavaFX 8+ also [supports @font-face](https://openjfx.io/javadoc/12/javafx.graphics/javafx/scene/doc-files/cssref.html#introatrules) in CSS. – Slaw Jun 25 '19 at 07:53
  • I'm not sure but it seems that Arial Unicode MS Bold is not free to use, i think you have to pay for the font files. But I'm not sure about that, – Tobi F Jun 25 '19 at 08:17

1 Answers1

0

i checked few possibilities with Arial Unicode MS and look enter image description here

check this

incLab.setStyle("-fx-font-weight: bold; -fx-font-family: Arial Unicode MS; -fx-font-size: 24");
Paweł
  • 205
  • 2
  • 11
  • Have you tried this? If `label.setFont( Font.font("Arial Unicode MS", FontWeight.BOLD,24))` isn't working I wouldn't expect this to either. – Slaw Jun 25 '19 at 19:53
  • i checked my code before post here and it's working, i can check set exactly what you want and i'll let you know – Paweł Jun 25 '19 at 20:36
  • The problem for the OP seems to be they don't have the bold version of the font available. Me? I don't even have _Arial Unicode MS_ available, let alone the bold version. – Slaw Jun 25 '19 at 20:50
  • @Paweł check the font of your Label after setting to bold with **incLab.getFont()** for me it is still regular – Tobi F Jun 26 '19 at 06:27
  • I tried to set the Style directly in the code like @Paweł did. It seems to be working, the font appears bold but when tracing out the font of the label it still says it's regular. Setting it in css does not bring the same effect. I think this is a bug. – Tobi F Jun 26 '19 at 07:47