How to center Text perfectly inside overlay + size-box


I have a simple Setup, a size-box (80x80 so that it matches the grid), an overlay inside, and a one lettered Text inside of that.

I set the text to center vertically and horizontally, padding is symetrically defined, justification is center. As you can see in the image, the green Text box is centered perpectly. But the single letter in side is not. Its off to the left and top. Its the same for different fonts.

Is there any way to fix that?

Hi @Catrexis

The cause is usually the font glyph metrics (ascender, descender, internal padding/bearing, etc) for characters being used in slate/umg.
It’s possible that alignment and justification are set to center but the bounding box of a single character may still have extra space on the top and bottom to accomodate taller ascenders or descenders on other characters (like “g” or “y”), pushing the character to the bottom of the bounding box

I think there are a couple potential things we can do to get it to center properly

Check Font Internal Padding/Clipping
In the Text Block details panel under Font see if changing the Transform Policy or checking the font baseline helps.
Some custom TTF/OTF fonts have baseline offsets which cause the glyphs to be rendered higher/lower than expected

Wrap in a Scale Box or Size Box
Sometimes forcing the Text Block to be contained within a Scale Box set to Scale to Fit (or center alignment on the Scale Box itself) forces the bounds to adhere strictly to the visual geometry of the graphic rather than the line metrics of the font itself

Manual Padding/Shift Offset

If you’re using a single specific glyph/icon like character and need to offset by exact pixels, perhaps adjusting the Padding (or Render Transform → Translation) on the Text Block directly would be a cleaner fix for that particular font

Could you what font family you’re using or if it also occurs with default unreal engine fonts?
This might help identify if it’s a particular glyph issue or slate hierarchy one.

Hope this helps! Let me know