Hi,
Okay, so I know that Slate fonts can’t be set from the editor, so I took a look at the ShooterGame sample.
Here is my take at fonts :
#define TTF_FONT( RelativePath, ... ) FSlateFontInfo( FPaths::GameContentDir() / "GUI" / RelativePath + TEXT(".ttf"), __VA_ARGS__ ) // Straight from SGame
SAssignNew(TitleText, STextBlock)
.Text(InArgs._Title)
.TextStyle(TStyle)
.Font(TTF_FONT("Font", 14))
And well, I am getting insulted at runtime :
LogSlate:Warning: GetFontFace failed
to load or process
‘…/…/…/…/Project/Content/GUI/Font.ttf’
I don’t know about the multiple …/, they seem wrong, but the font is really in D:/Project/Content/GUI/Font.ttf . Unreal is in D:/Unreal.
Is this a path error, or did I miss something about fonts ?
(When can we hope for a proper Font binding using the editor ?)
That looks correct to me, assuming:
D:\Unreal\Engine\Binaries\Win64\UE4Editor.exe
D:\Project\Content\GUI\Font.ttf
The relative path would be:
…/…/…/…/Project/Content/GUI/Font.ttf
How are you running the game? The path you’ve chosen (GUI) won’t get packaged, so if you’re running a cooked and packaged game, then the font might be missing (but I assume it would be using a different path then). Really fonts should go inside /Content/Slate since that directory is packaged correctly.
I’ve just noticed you’re putting that font straight into a widget? That TTF_FONT should be into the style set for your game.
The game is running from PIE. I moved everything from Content/GUI to Content/Slate so that fonts get packaged later.
Unfortunately nothing changes. Just to be sure, I really have to put the TTF file there, not a UFont asset ?
Oh my, sorry, I just found out the name of the font was wrong. Sorry about that, there was no issue at all… It works now.