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

Fonts management improvements #331

Open
1 of 3 tasks
mgarin opened this issue Aug 26, 2015 · 5 comments
Open
1 of 3 tasks

Fonts management improvements #331

mgarin opened this issue Aug 26, 2015 · 5 comments

Comments

@mgarin
Copy link
Owner

mgarin commented Aug 26, 2015

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:

  • Add better system language/locale -aware default fonts

  • Add some kind of FontsManager to handle fonts conveniently

  • Allow changing fonts in runtime for different parts of application

@mgarin mgarin self-assigned this Aug 26, 2015
@mgarin mgarin added this to the v1.30 milestone Aug 26, 2015
@iamchathu
Copy link
Contributor

+1

Better to reduce static imports since it will be a nightmare to use them in Netbeans IDE

@mgarin mgarin added the major label Nov 10, 2016
@mgarin
Copy link
Owner Author

mgarin commented Nov 10, 2016

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>

@mgarin
Copy link
Owner Author

mgarin commented Jun 15, 2017

Some parts of this enhancemet might be implemented a part of #460

@mgarin
Copy link
Owner Author

mgarin commented Jul 3, 2017

@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.

@mgarin
Copy link
Owner Author

mgarin commented Jul 6, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants