How to set / change the font of a UTextEditableBlock with a Font asset from c++. Currently using the UEditableTextBlock::WidgetStyle.TextStyle.SetFont() but that only seems to accept font files to be loaded from disk. Its working if I give it an existing ttf file in ‘InFontName’. I already have font assets added to the editor but not able to find the way to set them.
Found The solution by loading the Composit font asset as a UObject then use the object in the SetFont (*Replace [/Script/Engine.Font’/Engine/EngineFonts/Roboto] with the reference of the target asset):
UObject* FontObj = LoadObject<UObject>(this, TEXT("/Script/Engine.Font'/Engine/EngineFonts/Roboto'"), NULL, LOAD_None, NULL);
if (FontObj) {
EditableTextBlockPtr->WidgetStyle.TextStyle.SetFont(FontObj, 24);
}
else{
// Handle Error
}