With ue4 release 4.6 there came in composite fonts. Within the game content there can be created font objects containing multiple fonts. I only have found a description how to use font picker in a blueprint.
But how to use composite fonts in C++ to draw text on the HUD canvas?
E.g. I have created a composite font containing 4 fonts:
Now using the font to draw a text on the screen.
void AmyHUD::DrawHUD()
{
// Font'/Game/Fonts/CompositeVerdana.CompositeVerdana'
UObject* obj_ptr = StaticLoadObject( UFont::StaticClass(), NULL,
TEXT( "/Game/Fonts/CompositeVerdana" ) );
UFont* font_ptr = Cast<UFont>( obj_ptr );
this->DrawText( TEXT( "CompositeVerdana" ), FColor::White, 100.0f, 100.0f, font_ptr, 1 );
}
The text “CompositeVerdana” appears on the screen with the first font, named “Normal”. I assume that the first font will be used by default.
But how to address the the other fonts, named “Italic”, “Bold”, and “BoldItalic”, and how to make use of them?
Is it intented to use composite font with C++, does it has any advantages for C++, or is it just for blueprint comfort, and better don’t make use of composite fonts in C++.?