MacOS Sierra uses the San Francisco system font, and occasionally this font is used in bold. In JavaFX, however, creating a bold label using the default system font does not work on mac, as the following simple test case shows. I am guessing this has something to do with how a font weight of "bold" translates to the actual font selected. I do think this is a serious bug from a user experience stand point, as JavaFX cannot visually mimic Apple's design guidelines without jumping through hoops.
public class BoldTest extends Application {
@Override
public void init() throws Exception {
}
@Override
public void start(Stage stage) throws Exception {
Label normal = new Label("Normal");
Label bold = new Label("Bold");
bold.setStyle("-fx-font-weight: bold;");
HBox box = new HBox();
box.getChildren().addAll(normal, bold);
Scene scene = new Scene(box);
stage.setScene(scene);
stage.setTitle("Bold test");
stage.setWidth(600);
stage.setHeight(600);
stage.show();
}
public static void main(String... arguments) {
launch(BoldTest.class, arguments);
}
}
public class BoldTest extends Application {
@Override
public void init() throws Exception {
}
@Override
public void start(Stage stage) throws Exception {
Label normal = new Label("Normal");
Label bold = new Label("Bold");
bold.setStyle("-fx-font-weight: bold;");
HBox box = new HBox();
box.getChildren().addAll(normal, bold);
Scene scene = new Scene(box);
stage.setScene(scene);
stage.setTitle("Bold test");
stage.setWidth(600);
stage.setHeight(600);
stage.show();
}
public static void main(String... arguments) {
launch(BoldTest.class, arguments);
}
}
- duplicates
-
JDK-8185569 System font on MAC won't bold or italic
- Closed
- relates to
-
JDK-8222624 Certain CSS attributes (bold, italic) ignored under OS-X
- Open