mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
Mac: use Aqua as base LaF; initialize font to San Francisco
This commit is contained in:
@@ -91,8 +91,18 @@ public abstract class FlatLaf
|
||||
* E.g. on Mac from system dependent LaF, otherwise from Metal LaF.
|
||||
*/
|
||||
private BasicLookAndFeel getBase() {
|
||||
if( base == null )
|
||||
base = new MetalLookAndFeel();
|
||||
if( base == null ) {
|
||||
if( SystemInfo.IS_MAC ) {
|
||||
// use Mac Aqua LaF as base
|
||||
try {
|
||||
base = (BasicLookAndFeel) Class.forName( "com.apple.laf.AquaLookAndFeel" ).newInstance();
|
||||
} catch( Exception ex ) {
|
||||
ex.printStackTrace();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
} else
|
||||
base = new MetalLookAndFeel();
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
@@ -126,11 +136,23 @@ public abstract class FlatLaf
|
||||
private void initFonts( UIDefaults defaults ) {
|
||||
FontUIResource uiFont = null;
|
||||
|
||||
//TODO
|
||||
if( SystemInfo.IS_WINDOWS ) {
|
||||
Font winFont = (Font) Toolkit.getDefaultToolkit().getDesktopProperty( "win.messagebox.font" );
|
||||
if( winFont != null )
|
||||
uiFont = new FontUIResource( winFont );
|
||||
|
||||
} else if( SystemInfo.IS_MAC ) {
|
||||
Font font = defaults.getFont( "Label.font" );
|
||||
|
||||
if( SystemInfo.IS_MAC_OS_10_11_EL_CAPITAN_OR_LATER ) {
|
||||
// use San Francisco Text font
|
||||
font = new FontUIResource( ".SF NS Text", font.getStyle(), font.getSize() );
|
||||
}
|
||||
|
||||
uiFont = (font instanceof FontUIResource) ? (FontUIResource) font : new FontUIResource( font );
|
||||
|
||||
} else if( SystemInfo.IS_LINUX ) {
|
||||
System.err.println( "WARNING: FlatLaf is not yet tested on Linux!" );
|
||||
}
|
||||
|
||||
if( uiFont == null )
|
||||
|
||||
@@ -26,24 +26,36 @@ import java.util.StringTokenizer;
|
||||
*/
|
||||
public class SystemInfo
|
||||
{
|
||||
// platforms
|
||||
public static final boolean IS_WINDOWS;
|
||||
public static final boolean IS_MAC;
|
||||
public static final boolean IS_LINUX;
|
||||
|
||||
// OS versions
|
||||
public static final boolean IS_MAC_OS_10_11_EL_CAPITAN_OR_LATER;
|
||||
|
||||
// Java versions
|
||||
public static final boolean IS_JAVA_9_OR_LATER;
|
||||
|
||||
// Java VMs
|
||||
public static final boolean IS_JETBRAINS_JVM;
|
||||
|
||||
static {
|
||||
// platforms
|
||||
String osName = System.getProperty( "os.name" ).toLowerCase( Locale.ENGLISH );
|
||||
|
||||
IS_WINDOWS = osName.startsWith( "windows" );
|
||||
IS_MAC = osName.startsWith( "mac" );
|
||||
IS_LINUX = osName.startsWith( "linux" );
|
||||
|
||||
// OS versions
|
||||
int osVersion = scanVersion( System.getProperty( "os.version" ) );
|
||||
IS_MAC_OS_10_11_EL_CAPITAN_OR_LATER = (IS_MAC && osVersion >= toVersion( 10, 11, 0, 0 ));
|
||||
|
||||
// Java versions
|
||||
int javaVersion = scanVersion( System.getProperty( "java.version" ) );
|
||||
IS_JAVA_9_OR_LATER = (javaVersion >= toVersion( 9, 0, 0, 0 ));
|
||||
|
||||
// Java VMs
|
||||
IS_JETBRAINS_JVM = System.getProperty( "java.vm.vendor", "Unknown" )
|
||||
.toLowerCase( Locale.ENGLISH ).contains( "jetbrains" );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user