copy all font attributes in FlatUIUtils.nonUIResource() and when scaling fonts (issue #75)

This commit is contained in:
Karl Tauber
2020-03-12 11:22:43 +01:00
parent de718f847c
commit eb30f9d5bf
2 changed files with 3 additions and 3 deletions

View File

@@ -121,7 +121,7 @@ public class FlatUIUtils
} }
public static Font nonUIResource( Font font ) { public static Font nonUIResource( Font font ) {
return (font instanceof UIResource) ? new Font( font.getName(), font.getStyle(), font.getSize() ) : font; return (font instanceof UIResource) ? font.deriveFont( font.getStyle() ) : font;
} }
public static int minimumWidth( JComponent c, int minimumWidth ) { public static int minimumWidth( JComponent c, int minimumWidth ) {

View File

@@ -197,7 +197,7 @@ public class UIScale
return font; return font;
int newFontSize = Math.round( (font.getSize() / fontScaleFactor) * scaleFactor ); int newFontSize = Math.round( (font.getSize() / fontScaleFactor) * scaleFactor );
return new FontUIResource( font.getFamily(), font.getStyle(), newFontSize ); return new FontUIResource( font.deriveFont( (float) newFontSize ) );
} }
/** /**
@@ -205,7 +205,7 @@ public class UIScale
*/ */
public static FontUIResource scaleFont( FontUIResource font, float scaleFactor ) { public static FontUIResource scaleFont( FontUIResource font, float scaleFactor ) {
int newFontSize = Math.round( font.getSize() * scaleFactor ); int newFontSize = Math.round( font.getSize() * scaleFactor );
return new FontUIResource( font.getFamily(), font.getStyle(), newFontSize ); return new FontUIResource( font.deriveFont( (float) newFontSize ) );
} }
/** /**