Fonts management improvements
Right now WebLaF uses some hardcoded fonts from WebFonts class and the only way to change them is to provide custom fonts into WebLookAndFeel class static variables before L&F initialization.
Some planned improvements:
-
[x] Add better system language/locale -aware default fonts
-
[ ] Add some kind of
FontsManagerto handle fonts conveniently -
[ ] Allow changing fonts in runtime for different parts of application
+1
Better to reduce static imports since it will be a nightmare to use them in Netbeans IDE
An important thing to be done upon implementing new fonts manager is to remove all default ways of component font setup which are currently used within swing.
For example this is how tooltip font is set:
LookAndFeel.installColorsAndFont ( c, "ToolTip.background", "ToolTip.foreground", "ToolTip.font" );
Usually calls like this one can be found within installDefaults methods of component UI.
Starting with v1.3.0 all those calls should be removed and Font should be specified directly inside the style of specific component. Also each Font should be attached to specific text content within the component and not the whole component as some of them might have multiple separate text elements within, for example JMenuItem has its own text and accelerator text.
It should be possible to specify a fully new font or a reference to global fonts defined in the skin. I don't have specifics on how exactly that would look like in the style XML, but here are some possible options:
Global skin fonts:
<skin>
<!-- Global fonts -->
<fonts>
<Font id="control" name="Tahoma" size="12" />
<Font id="alert" name="Segoe UI" style="bold" size="13" />
...
</fonts>
...
</skin>
And fonts usage within specific style contents (taken from current menu item style):
<ButtonText constraints="text" fontId="control" color="black" />
<AcceleratorText constraints="accelerator" padding="2,4,2,4" color="90,90,90">
<Font name="Tahoma" style="italic" size="10" />
</AcceleratorText>
Some parts of this enhancemet might be implemented a part of #460
@vp131 mentioned issue on Gitter chat:
OS - Windows 10 Pro Code sample - There isn't any. Just put up a textfield, run it and it works fine. Run it with WebLookAndFeel.install() and it's not working. The fonts are the ones provided by Windows itself. Just install any other language pack. In my case it's Hindi.
I've pushed some related changes in 5bd2b12 commit.
Shortly - WebFonts have been replaced with NativeFonts class and now try to use native fonts whenever it is possible by default. If something goes wrong it uses fallback fonts that have been moved there from WebFonts (and are used as fallback fonts in various L&Fs as well).
To disable native fonts usage simply add this line of code:
NativeFonts.setUseNativeFonts ( false );
And WebLaF fonts will function the same way they did before this change.
Currently native fonts are only supported for Windows and Mac OS X operating systems (and the latter still needs some testing on different versions). Unfortunately there is no good solution available for other Unix systems yet.