UFontFace* FontFace = NewObject(…);
FontFace->LoadingPolicy = EFontLoadingPolicy::Inline;
FontFace->FontFaceData = FFontFaceData::MakeFontFaceData(…);
UFont* Font = NewObject<UFont>(...);
Font->FontCacheType = EFontCacheType::Runtime;
FTypefaceEntry& TypefaceEntry = Font->CompositeFont.DefaultTypeface.Fonts[Font->CompositeFont.DefaultTypeface.Fonts.AddDefaulted()];
TypefaceEntry.Font = FFontData(FontFace);
Something like that. Note that at that point in time nothing is keeping your font from being GC’d, but if you use it with a UMG widget then the widget will keep it alive (there are also other ways to keep an object alive).
Also note that MakeFontFaceData
takes an r-value reference, so you’ll either need to MoveTemp
or CopyTemp
your data into it (depending on whether you still need your source array afterwards).
Will I need to strip any headers or anything out of the .ttf file as bytes?
No, it’s just raw TTF/OTF payload data. FreeType is what actually makes use of the data.