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

Font issues #309

Closed
guekho64 opened this issue Apr 18, 2021 · 8 comments
Closed

Font issues #309

guekho64 opened this issue Apr 18, 2021 · 8 comments
Milestone

Comments

@guekho64
Copy link

guekho64 commented Apr 18, 2021

It seems FlatLaf has some issues trying to detect which are my current font settings, as demonstrated by this simple example:

This is how it looks

nope

This is how it should look

ok

Here's the code of this example (I had to modify FlatLaf src to access LinuxFontPolicy#getGnomeFont)

public class Main {
	public static void main (final String[] argv) {
		FlatIntelliJLaf.install();
		Font info = LinuxFontPolicy.getGnomeFont();
		String text = "This is what FlatLaf thinks it's my system wide font:\n\n";
		JOptionPane.showOptionDialog(
				null,
				text + info.toString(),
				"Correct Font Example",
				0,
				JOptionPane.INFORMATION_MESSAGE,
				null,
				new Object[] {"A button, of course"}, 0
				);
	}
}

System Info

FlatLaf Versions Tested

FlatLaf (master)
FlatLaf (1.1.2)

Desktop Environment

MATE 1.24.0

java -version

openjdk version "14.0.2" 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 14.0.2+12-Ubuntu-120.04, mixed mode, sharing)

lsb_release -a

Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal

uname -a

Linux PC 5.8.0-50-lowlatency 56~20.04.1-Ubuntu SMP PREEMPT Tue Apr 13 01:48:06 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

@guekho64 guekho64 mentioned this issue Apr 18, 2021
@DevCharly
Copy link
Collaborator

I wonder what font is used in other Lafs.

Could you replace:

FlatIntelliJLaf.install();
Font info = LinuxFontPolicy.getGnomeFont();

with

UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
Font info = UIManager.getFont( "Label.font" );

and

UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
Font info = UIManager.getFont( "Label.font" );

and post the two screenshots? Thanks.

@kingthorin

This comment has been minimized.

@DevCharly

This comment has been minimized.

@guekho64
Copy link
Author

guekho64 commented Apr 20, 2021

Here you go:


SystemLAF = javax.swing.plaf.metal.MetalLookAndFeel
javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=bold,size=12]

CrossplatformLAF = javax.swing.plaf.metal.MetalLookAndFeel
javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=bold,size=12]


And yeah, I was expecting that, since Metal doesn't follow my settings either....

@DevCharly
Copy link
Collaborator

Many thanks.

Yes, was expecting that for Metal too, but I actually thought that GTK is used as System Laf on Linux.

Could you please also try:

UIManager.setLookAndFeel( new GTKLookAndFeel() );

I also wonder whether the text in the JButton is totally out of vertical center for Metal and GTK Lafs as in your first screenshot

@guekho64
Copy link
Author

Here's how JOptionPane looks in GTK laf:

image

Surprisingly enough, it doesn't acquire correct fonts either.

Here you can compare how it should look (MATE's oficial file browser: Caja 1.24)

image

Honestly, I'm not sure where could be the fault:

  • Is java incorrectly parsing the output of defaultToolkit().getDesktopProperty()?
  • MATE Desktop Environment is doing something wrong when reporting its default font to Java?
  • Are some fonts simply misconfigured (Another case would be Nimbus Sans Bold, which reports itself as Nimbus Sans-Bold)?
    • Not to mention SF Compact Rounded Semibold was designed by ®Apple
  • Font name conventions aren't strict enough, to allow for a trustworthy font metadata parsing?
    • For instance, doing new Font("SF Compact Rounded Semibold") actually works.
    • Doing new Font("SF Compact Rounded Semi-bold") fails.
    • My PR Fix #309 #310 does not follow any conventions at all, and only relies in U+0020 (" ") as the only word delimiter available, and considers last token from defaultToolkit().getDesktopProperty() as fontsize; aside from that, it doesn't make any more assumptions, and tries real hard to guess which font it's currently in use, but of course, it's not infallible. As a fallback, it'll default to generate a Dialog font, which it's universally available to Java, being a Logic family font.

@guekho64
Copy link
Author

Are there any news on this, or #310, by any chance?

@DevCharly
Copy link
Collaborator

Had some issues with PR #310...

There is a fix in commit 9edaf58
Please give it a try...

@DevCharly DevCharly added this to the 1.2 milestone May 4, 2021
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 a pull request may close this issue.

3 participants