Skip to content

Commit

Permalink
load the default font directly
Browse files Browse the repository at this point in the history
  • Loading branch information
xzel23 committed Jan 2, 2025
1 parent 7b00e71 commit 5a06773
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions utility-fx/src/main/java/com/dua3/utility/fx/FxFontUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.dua3.utility.text.FontDef;
import com.dua3.utility.text.FontUtil;
import javafx.geometry.Bounds;
import javafx.scene.control.Label;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
Expand Down Expand Up @@ -50,9 +49,11 @@ public class FxFontUtil implements FontUtil<Font> {
private static final float DEFAULT_SIZE;

static {
Font labelFont = new Label().getFont();
DEFAULT_FAMILY = Platform.isMacOS() ? "Verdana" : labelFont.getFamily();
DEFAULT_SIZE = (float) labelFont.getSize();
Font font = Font.getDefault();
// on macOS use Verdana instead of the default font because the default font
// does not support styling (bold, italics) in JavaFX..
DEFAULT_FAMILY = Platform.isMacOS() ? "Verdana" : font.getFamily();
DEFAULT_SIZE = (float) font.getSize();
}

private static class SingletonHolder {
Expand Down

0 comments on commit 5a06773

Please sign in to comment.