I’m doing a simple DrawText operation in my Custom GameViewportClient:
At Init() in my GameViewportClient I load my font successfully (checking GetName). BTW: The same crashes also happens with a copy of Engine Font ‘Roboto’.
TestFont = LoadObject<UFont>(nullptr, TEXT("Font'/Game/Henry/Fonts/My_Font.My_Font'"));
my drawtext call
Canvas->DrawText(TestFont, TestText, 0.0f, 0.0, 1.0f, 1.0f, FontRenderInfo);
BTW: using the GEngine quick version works fine:
Canvas->DrawText(GEngine->GetLargeFont(), TestText, 0.0f, 0.0f, 1.0f, 1.0f, FontRenderInfo);
Using font loaded with LoadObject consistently causes a crash ‘Pure virtual function being called’
...
UE4Editor-Core.dll!FOutputDevice::LogfImpl() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Misc\OutputDevice.cpp:61]
UE4Editor-Core.dll!PureCallHandler() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Windows\WindowsPlatformMisc.cpp:477]
VCRUNTIME140.dll!UnknownFunction []
UE4Editor-SlateCore.dll!FSlateFontInfo::FSlateFontInfo() [D:\Build\++UE4\Sync\Engine\Source\Runtime\SlateCore\Private\Fonts\SlateFontInfo.cpp:83]
UE4Editor-Engine.dll!UFont::GetCharSize() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\Font.cpp:202]
...
Checking Engine\Source\Runtime\SlateCore\Private\Fonts\SlateFontInfo.cpp:
82: const IFontProviderInterface* FontProvider = Cast<const IFontProviderInterface>(InFontObject);
83: if (!FontProvider || !FontProvider->GetCompositeFont())
FontProvider->GetCompositeFont() acutally is a pure virtual function, and this one seems to get called internally. From FontProviderInterface.h:
class IFontProviderInterface
{
GENERATED_IINTERFACE_BODY()
virtual const FCompositeFont* GetCompositeFont() const = 0;
};
It also seems to be influenced by the Font Cache Type: my font and roboto are Font Cache Type “Runtime”. Testing with a copy of engine font RobotoDistancefield, which is Cache type “Offline” behaves different, but also creates a crash in DrawStringInternal_OfflineCache()…
Anyone having an idea, what I could be doing wrong?
Thank you