mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 15:27:16 -06:00
Theme Editor:
- use JetBrains Mono font for editor area - added Inter font to allow using it in preview (Java 11+)
This commit is contained in:
@@ -22,6 +22,8 @@ plugins {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation( project( ":flatlaf-core" ) )
|
implementation( project( ":flatlaf-core" ) )
|
||||||
implementation( project( ":flatlaf-extras" ) )
|
implementation( project( ":flatlaf-extras" ) )
|
||||||
|
implementation( project( ":flatlaf-fonts-inter" ) )
|
||||||
|
implementation( project( ":flatlaf-fonts-jetbrains-mono" ) )
|
||||||
|
|
||||||
implementation( "com.miglayout:miglayout-swing:5.3" )
|
implementation( "com.miglayout:miglayout-swing:5.3" )
|
||||||
implementation( "com.fifesoft:rsyntaxtextarea:3.1.4" )
|
implementation( "com.fifesoft:rsyntaxtextarea:3.1.4" )
|
||||||
@@ -32,6 +34,8 @@ tasks {
|
|||||||
jar {
|
jar {
|
||||||
dependsOn( ":flatlaf-core:jar" )
|
dependsOn( ":flatlaf-core:jar" )
|
||||||
dependsOn( ":flatlaf-extras:jar" )
|
dependsOn( ":flatlaf-extras:jar" )
|
||||||
|
dependsOn( ":flatlaf-fonts-inter:jar" )
|
||||||
|
dependsOn( ":flatlaf-fonts-jetbrains-mono:jar" )
|
||||||
|
|
||||||
manifest {
|
manifest {
|
||||||
attributes( "Main-Class" to "com.formdev.flatlaf.themeeditor.FlatLafThemeEditor" )
|
attributes( "Main-Class" to "com.formdev.flatlaf.themeeditor.FlatLafThemeEditor" )
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.text.StyleContext;
|
||||||
import org.fife.ui.autocomplete.AutoCompletion;
|
import org.fife.ui.autocomplete.AutoCompletion;
|
||||||
import org.fife.ui.autocomplete.CompletionProvider;
|
import org.fife.ui.autocomplete.CompletionProvider;
|
||||||
import org.fife.ui.rsyntaxtextarea.AbstractTokenMakerFactory;
|
import org.fife.ui.rsyntaxtextarea.AbstractTokenMakerFactory;
|
||||||
@@ -48,6 +49,7 @@ import org.fife.ui.rtextarea.Gutter;
|
|||||||
import org.fife.ui.rtextarea.RTextArea;
|
import org.fife.ui.rtextarea.RTextArea;
|
||||||
import org.fife.ui.rtextarea.RTextScrollPane;
|
import org.fife.ui.rtextarea.RTextScrollPane;
|
||||||
import org.fife.ui.rtextarea.SearchContext;
|
import org.fife.ui.rtextarea.SearchContext;
|
||||||
|
import com.formdev.flatlaf.fonts.jetbrains_mono.FlatJetBrainsMonoFont;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,8 +130,7 @@ class FlatThemeEditorPane
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateTheme() {
|
void updateTheme() {
|
||||||
Font defaultFont = RTextArea.getDefaultFont();
|
Font font = createEditorFont( 0 );
|
||||||
Font font = defaultFont.deriveFont( (float) UIManager.getFont( "defaultFont" ).getSize() );
|
|
||||||
|
|
||||||
textArea.setFont( font );
|
textArea.setFont( font );
|
||||||
textArea.setBackground( UIManager.getColor( "FlatThemeEditorPane.background" ) );
|
textArea.setBackground( UIManager.getColor( "FlatThemeEditorPane.background" ) );
|
||||||
@@ -161,14 +162,28 @@ class FlatThemeEditorPane
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateFontSize( int sizeIncr ) {
|
void updateFontSize( int sizeIncr ) {
|
||||||
Font defaultFont = RTextArea.getDefaultFont();
|
Font font = createEditorFont( sizeIncr );
|
||||||
Font font = defaultFont.deriveFont( (float) UIManager.getFont( "defaultFont" ).getSize() + sizeIncr );
|
|
||||||
|
|
||||||
textArea.setFont( font );
|
textArea.setFont( font );
|
||||||
textArea.setSyntaxScheme( new FlatSyntaxScheme( font ) );
|
textArea.setSyntaxScheme( new FlatSyntaxScheme( font ) );
|
||||||
scrollPane.getGutter().setLineNumberFont( font );
|
scrollPane.getGutter().setLineNumberFont( font );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Font createEditorFont( int sizeIncr ) {
|
||||||
|
int size = UIManager.getFont( "defaultFont" ).getSize() + sizeIncr;
|
||||||
|
StyleContext sc = StyleContext.getDefaultStyleContext();
|
||||||
|
Font font = sc.getFont( FlatJetBrainsMonoFont.FAMILY, Font.PLAIN, size );
|
||||||
|
if( isFallbackFont( font ) ) {
|
||||||
|
Font defaultFont = RTextArea.getDefaultFont();
|
||||||
|
font = defaultFont.deriveFont( (float) size );
|
||||||
|
}
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isFallbackFont( Font font ) {
|
||||||
|
return Font.DIALOG.equalsIgnoreCase( font.getFamily() );
|
||||||
|
}
|
||||||
|
|
||||||
void selected() {
|
void selected() {
|
||||||
if( findReplaceVisible )
|
if( findReplaceVisible )
|
||||||
showFindReplaceBar( false );
|
showFindReplaceBar( false );
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ import com.formdev.flatlaf.extras.FlatSVGIcon;
|
|||||||
import com.formdev.flatlaf.extras.FlatSVGUtils;
|
import com.formdev.flatlaf.extras.FlatSVGUtils;
|
||||||
import com.formdev.flatlaf.extras.FlatUIDefaultsInspector;
|
import com.formdev.flatlaf.extras.FlatUIDefaultsInspector;
|
||||||
import com.formdev.flatlaf.extras.components.*;
|
import com.formdev.flatlaf.extras.components.*;
|
||||||
|
import com.formdev.flatlaf.fonts.inter.FlatInterFont;
|
||||||
|
import com.formdev.flatlaf.fonts.jetbrains_mono.FlatJetBrainsMonoFont;
|
||||||
import com.formdev.flatlaf.icons.FlatClearIcon;
|
import com.formdev.flatlaf.icons.FlatClearIcon;
|
||||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
import com.formdev.flatlaf.util.StringUtils;
|
import com.formdev.flatlaf.util.StringUtils;
|
||||||
@@ -105,6 +107,10 @@ class FlatThemeFileEditor
|
|||||||
System.setProperty( "user.language", "en" );
|
System.setProperty( "user.language", "en" );
|
||||||
|
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
|
if( SystemInfo.isJava_11_orLater )
|
||||||
|
FlatInterFont.install();
|
||||||
|
FlatJetBrainsMonoFont.install();
|
||||||
|
|
||||||
FlatLaf.registerCustomDefaultsSource( "com.formdev.flatlaf.themeeditor" );
|
FlatLaf.registerCustomDefaultsSource( "com.formdev.flatlaf.themeeditor" );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user