Text Size in pixels showed on static text UMG widget (not HUD!).

I’m trying to get text size in specific font and font size draw onto “A simple static text widget” inside UMG which is not inside HUD, but used as actor component’s widget class.

So “Get text size” (HUD) - need hud, which I don’t have.
“Wrapped Text Size” and “Clipped Text Size” - need canvas, which I don’t have.
“Get Text Local Size”, “Get Text World Size” - need “text render component” which I don’t use.

Google unfortunatelly show very few answers (unreal text size) :frowning:

So how to check what is the size of the rendered wrapped text thru Text UMG component in specific font and font size ?
Maybe C++ solution?

I dont know how to measure text in UMG but from code you can get text size using font measure service, like this:

TSharedRef< FSlateFontMeasure > FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
		FSlateFontInfo Font = GET_YOUR_FONT_SOMEHOW;
		const FVector2D TextSize = FontMeasure->Measure(String_To_Measure, Font);

the only problem here will be how do you get the actual font so you can put in GET_YOUR_FONT_SOMEHOW place. The obvious solution would be to use STextBlock::GetFont method but for some reason its private…

1 Like

myTextBlock->Font (it’s public)