Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fonts #545

Merged
merged 6 commits into from Nov 18, 2022
Merged

Fonts #545

merged 6 commits into from Nov 18, 2022

Conversation

DevCharly
Copy link
Collaborator

This PR packages some fonts into JARs (will be released to Maven Central later) and provides an easy way to use them with FlatLaf.

At the moment there are two fonts:

The Inter font was chosen because it is designed for computer screens and because JetBrains recently announced to use it for all its IntelliJ based IDEs as default font on all supported OSs. Maybe you want use it too in your application?

The JetBrains Mono font was chosen because I wanted to use it in FlatLaf Theme Editor.

This is the FlatLaf Demo using Inter font:

grafik

The fonts need to be installed before the can be used. E.g.

FlatInterFont.install();
FlatJetBrainsMonoFont.install();

To use them in your application as default font, use:

FlatLaf.setPreferredFontFamily( FlatInterFont.FAMILY );
FlatLaf.setPreferredLightFontFamily( FlatInterFont.FAMILY_LIGHT );
FlatLaf.setPreferredSemiboldFontFamily( FlatInterFont.FAMILY_SEMIBOLD );
FlatLaf.setPreferredMonospacedFontFamily( FlatJetBrainsMonoFont.FAMILY );

FlatLightLaf.setup();

//TODO create UI

You can of course also create fonts. E.g.:

// basic styles
new Font( FlatInterFont.FAMILY, Font.PLAIN, 12 );
new Font( FlatInterFont.FAMILY, Font.ITALIC, 12 );
new Font( FlatInterFont.FAMILY, Font.BOLD, 12 );
new Font( FlatInterFont.FAMILY, Font.BOLD | Font.ITALIC, 12 );

// light
new Font( FlatInterFont.FAMILY_LIGHT, Font.PLAIN, 12 );
new Font( FlatInterFont.FAMILY_LIGHT, Font.ITALIC, 12 );

// semibold
new Font( FlatInterFont.FAMILY_SEMIBOLD, Font.PLAIN, 12 );
new Font( FlatInterFont.FAMILY_SEMIBOLD, Font.ITALIC, 12 );

@rogerbj
Copy link

rogerbj commented Jul 7, 2022

Great news! Looking forward to this 👍

@DevCharly DevCharly merged commit 24bc7fb into main Nov 18, 2022
@DevCharly DevCharly deleted the fonts branch November 18, 2022 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants