Is there a way to change the default font size in Swing GTK LaF?
GTK LaF apparently assumes 72dpi, so all fonts are only 3/4 of the size that should be when using a 96 dpi screen. See Fedora Error for more details . I would like to find a workaround while I wait for a fix.
I already tried resetting the font size using UIDefaults, as recommended here , but (as also noted there) GTK LaF seems to ignore this.
I could create a factory widget that would also set the desired font size to create all of my Swing widgets, but that would be massively invasive, so I would like to avoid this route if there is any other way.
Edit: The following does not work:
public class GTKLaF extends com.sun.java.swing.plaf.gtk.GTKLookAndFeel {
@Override
public UIDefaults getDefaults() {
final float scale = 3f;
final UIDefaults defaults = super.getDefaults();
final Map<Object,Object> changes = new HashMap<Object,Object>();
for (Map.Entry<Object,Object> e : defaults.entrySet()) {
final Object key = e.getKey();
final Object val = e.getValue();
if (val instanceof FontUIResource) {
final FontUIResource ores = (FontUIResource) val;
final FontUIResource nres =
new FontUIResource(ores.deriveFont(ores.getSize2D()*scale));
changes.put(key, nres);
System.out.println(key + " = " + nres);
}
else if (val instanceof Font) {
final Font ofont = (Font) val;
final Font nfont = ofont.deriveFont(ofont.getSize2D()*scale);
changes.put(key, nfont);
System.out.println(key + " = " + nfont);
}
}
defaults.putAll(changes);
return defaults;
}
}
You might think that this will print at least a dozen key-value pairs, but it only prints one: TitledBorder.font. Apparently, other font properties are not provided by GTLLookAndFeel, but from somewhere else!
source
share