Is it possible to center justifiy FSlateDrawElement::MakeText?

To draw centered text, you need to first calculate the size that the text will be when it is actually drawn. You can get find this information by getting the font measure service in slate via

const TSharedRef< FSlateFontMeasure > FontMeasureService = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();

and then calling the appropriate procedures on it. You can look in the source code for Slate’s editable text view ( SEditableText.cpp ) for an example of this. (Other widgets use it too, of course).

Hey Team,

Is it possible for me to center justify drawn text with FSlateDrawElement::MakeText OR to get the rendered text size to manually offset the text?

I am building a custom graph widget and am using FSlateDrawElement::MakeText to draw the graph’s axis and grid labels as seen below. The labels are generated on load depending on the data’s range and scale. This means I can’t manually set the graph grids and labels in the widget’s blueprint as the number of labels and grids and their positions change dynamically.


If MakeText is not the recommended technique for manually drawing text, how should I go about drawing my labels in my custom widget?


Awesome, the font measure service works perfectly. Thank you Cancel!