"Get Text Size" available without Draw HUD event?

There’s useful function Get Text Size, it allows you to determine real screen size of Text.

The problem is that function works only if you place it after Receive Draw HUD event in HUD because it uses UCanvas methods.

Now, I’m UE4 C++ noob, so I’d like to humbly ask if there’s any way to write another version of this function as part of standalone plug-in? This way I’d be able to determine size of any text I want, in any widget blueprint.
Now I’d have to send every string to HUD, apply Get Text Size on it and send the result back to the original script. It’s hacky, ugly way and it doesn’t work well :wink:

If you’re using a runtime cached font (you are if you’re using UMG) then you could do the measure using the Slate font measurer instead.

TSharedRef<FSlateFontMeasure> FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
FontMeasure->Measure(YourText, YourFont);

Or you could just use UCanvas::CanvasStringSize which will work for both offline and runtime cached fonts.

You’d need to make a UFUNCTION to expose whatever C++ you need to BPs.

Works like a charm!
Thank you :slight_smile: