apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.64k stars 846 forks source link

Wrong font used for file chooser #5265

Open rkeen-siemens opened 1 year ago

rkeen-siemens commented 1 year ago

Apache NetBeans version

Apache NetBeans 16

What happened

The new feature to allow customizing FlatLaf is nice, but when changing the font and changing the font size the new font is not used for file chooser file list and details views.

How to reproduce

  1. Choose Tools > Options > Appearance > FlatLaf
  2. In the Advanced section, click the Edit custom properties button
  3. Close the options dialog and add a line to FlatLaf.properties (which should now be open in the editor) to change the default font (e.g. defaultFont = "Nanum Brush Script")
  4. Save the file and close NetBeans
  5. Launch NetBeans again with a custom font size (e.g. ./bin/netbeans --fontsize 24). You'll see the UI has changed to use the new font as expected
  6. Choose File > Open File...

The file chooser dialog that appears uses the selected font for most of the UI, but the file list and detail views use the standard sans serif font rather than the new font.

WrongFont

If you launch NetBeans without overriding the font size, the file chooser uses the correct font.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 10 Pro, CentOS 7.6 with Gnome 3

JDK

Java 17.0.4.1

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

I suspect this is due to the logic in AllLFCustoms.initCustomFontSize where it resizes the existing font for "FileChooser.listFont" (and others). The problem is that at this point there is no value set for some of the settings including "FileChooser.listFont", "OptionPane.messageFont", and "windowTitleFont" and they are then assigned the default Dialog font.

Some possible solutions:

  1. If the setting doesn't yet exist, don't set it since "FileChooser.listFont" falls back to "List.font", "OptionPane.messageFont" falls back to "Label.font". "windowTitleFont" may need separate handling since it seems to fallback to a hard coded value where used, so perhaps it should fallback to another existing UIManager value instead?
  2. Set the default values from FlatLaf settings, either "defaultFont" or "monospaced.font" and only fallback to the hard coded values if those don't exist

Are you willing to submit a pull request?

Yes

Code of Conduct

Yes

neilcsmith-net commented 1 year ago

More a workaround, but have you tried setting the font size in the FlatLaf defaultFont property too?

rkeen-siemens commented 1 year ago

Yes, setting the font size in the defaultFont property doesn't make a difference. The font is still set to dialog.

neilcsmith-net commented 1 year ago

@rkeen-siemens did you remove the --fontsize argument in the process? Setting the defaultFont to eg. 20 FONT_NAME works for me. At least in the file chooser.

rkeen-siemens commented 1 year ago

did you remove the --fontsize argument in the process?

Good point. Removing the --fontsize argument does work around the issue.