Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get system default font

Tags:

java

fonts

Is there any way to get the system default font name in Java? The default font can differ from os. So it can create trouble if we use font Arial and the jar is running in Linux without having Arial font installed.

like image 433
Tapas Bose Avatar asked Aug 21 '11 18:08

Tapas Bose


People also ask

How do I find the default font on my computer?

Go to the Control Panel -> Appearance and Personalization -> Fonts. This Control Panel item can be opened by running the command: control fonts. Select Font settings in the left pane; In the next window click the Restore default font settings button.

What is the default Windows 10 system font?

Even though the default fonts provided by Microsoft—Segoe UI for Windows 10, and Segoe UI variable for Windows 11—looks pretty neat on the screen, you don't have to settle if you have grown bored with them; especially when you can easily alter them with the Windows Registry.

What is the Windows system font?

Segoe UI (pronounced "SEE-go") is the Windows system font.


2 Answers

Try this:

private final Font FONT = new JLabel().getFont();
like image 179
Salvation Avatar answered Sep 22 '22 18:09

Salvation


JavaFX makes this a lot easier:

import javafx.scene.text.Font;

then use:

Font defaultFont = Font.getDefault();

or

// Where 14 is the font size
Font defaultFont = new Font(14);
like image 28
Ky. Avatar answered Sep 22 '22 18:09

Ky.