themesstarling-frameworkbitmap-fontsfeathers-ui

How to override default Feathers theme font


I wanted to override the MinimalDesktopTheme default font (to be able to use UTF-8 characters) and I've extended the theme class like this:

public class DesktopTheme extends MinimalDesktopTheme
{
    public function DesktopTheme()
    {
        super();
    }

    override protected function initializeFonts():void
    {
        super.initializeFonts();
        trace(TextField.getBitmapFont(FontProxy.ACTION_JACKSON_NAME));
        this.primaryTextFormat = new BitmapFontTextFormat(
            FontProxy.ACTION_JACKSON_NAME,
            30,
            BaseMinimalDesktopTheme.PRIMARY_TEXT_COLOR
        );
    }
}

The trace shows me that the font was successfully registered: [object BitmapFont]. I register it in a different place before this code is being executed.

The problem is that an exception is being thrown from the feathers.core::FeathersControl/setSizeInternal at line 1871 with the following message [Fault] exception, information=ArgumentError: A component's height cannot be NaN. The height parameter was not a number for some reason.

I was also playing around with font sizes while generating bitmap fonts and I've noticed that with some values of the bitmap font size this exception does not occur.

What am I doing wrong? How do I correctly override the default theme font?


Solution

  • It turned out that my approach was correct and the issue was caused by the fact that I generated bitmap font in plain text format instead of XML.