Slate: Styles and fonts

Hey everyone.

I’m having a weird problem with Slate and styles.

I have my Slate UI up and running and I’ve set up styles that the UI loads and adopts. Everything works perfectly, except for one single thing: fonts!

When editing the Style in the editor, I’ve set the option of being able to change the font style of a widget.
When I step through the code in the debugger I can see that it has the correct info in the style, but Slate can’t seem to find the font I requested in the style settings.

I’ve tried with the font name alone (excelate.ttf), with a relative path from Content (UI/Fonts/excelate.ttf) and neither works.

I’ve tried to hardcode the font with a full path in the code, and it loads perfectly - but I’d really like to be able to give the designers ability to edit the font style from the editor through Styles.

Is there something I’m missing? An ini-file setting that sets up the root directory for Slate to look for assets in, or something like that?

Where does Slate look for fonts by default? I’ve tried copying the font file to Engine/Content/Slate/Fonts and still no go there either.

Hope one of you guys can help!

Thanks in advance!

If by “in the editor” you mean via a Slate Widget Style asset, then unfortunately fonts cannot currently be set that way as we don’t yet have a font asset that will work with Slate.

Fonts must currently be set in the style set for your game via C++. Both ShooterGame and StrategyGame have an example of doing this.

I realise this is an inconvenience, and it is something we are working to address for a future release.

Hi Jamie,

thanks for your response!

I do, indeed, mean the Slate Widget Style asset. I’m sorry to hear that assigning fonts to a style won’t currently work, it’s kind of a big thing to let the designers choose their appearance instead of having to hardcode font selections into the Style, but be that as it may.

So as I understand it, the Slate styles only work with assets that have been imported into the editor, and can’t work with “raw” assets straight from an external file?

Thanks!

Hi again, Jamie.

Thanks for the detailed response, that’s very helpful to know :slight_smile:

It makes sense to advise against using the raw files for packaging purposes, I can certainly see where it could cause issues when an asset isn’t “registered” for packaging.

Here’s hoping for a prompt solution to the problem :slight_smile:

“So as I understand it, the Slate styles only work with assets that have been imported into the editor, and can’t work with “raw” assets straight from an external file?”

That’s not strictly true for games (and is not true at all for the editor, which loads all its content from disk since it doesn’t get packaged like a game does), but if you do load things from disk there are considerations that must be taken into account to ensure your content is packaged correctly, so we strongly advise people not to do that where there are alternatives (such as using a Slate Brush asset and a texture asset, rather than loading a texture from disk).

There isn’t an alternative for fonts, so loading from disk is currently the way it has to be. You’ll need to ensure that any fonts you add are somewhere inside the /Content/Slate directory for your game (you may need to make this) otherwise they won’t get packaged correctly.