How to make text scale in only one axis?

Hey guys,

I’m working on a widget that I need to display a variety of names. The names have to be the same size in the Y, but need to be able to squash down in the X in order to account for longer names. How can I do this? Using a Scale box only allows me to scale both axis’s. There doesn’t appear to be a way to only scale in one axis.

The Scalebox works like that by default:

You get to choose how each slot behaves, too.


There doesn’t appear to be a way to only scale in one axis.

Wouldn’t this make the text stretched vertically and distorted? Are you sure this is what you need?

Yes. This is what they want, I’m afraid. It has to be stretched vertically and distorted, but it cannot change in the Y.

In the example you posted (and how scalebox seems to work), the text is scaling in both axis’s at the same time. Changing “stretch” just changes which axis it looks at to decide if it should scale.

Scale box was the first thing I tried.

It’s possible to achieve this using the transform settings in the text, but I can’t figure out how to tie that to a predefined size not to go over, and how to set what to scale it to if it does.

You may need to fiddle with the values to hit the sweetspot:

image

Massage it until it’s close enough :smiley: But it may be just a limitation of UMG at this point. This needs to be full dynamic, right?

Yeah, exactly. It needing to be dynamic is the problem. We can’t know how long the names are going to be, so people can input them in real time, so we need to figure out how much to scale each name if it’s over a certain size.

The best idea I have right now is to just check how many characters are in the name, and if it’s over a certain number, scale it a certain amount. It’s not perfect, as characters can be very different sizes (“l” vs “m”, for example), but on average it should be about right.

I am using the desired size of the text. It’s pretty much pixel perfect (not really), you just need the right value. If you’re doing it run-time, you can skip Force Layout Prepass.

Oh, that’s really cool. I’ll try that out, thanks!