Making text size consistent

Currently when I use textscaled on my textlabels, their text sizes are different because of the length of the string. However, how would I make something like textscaled where it scales the text when the screen size changes but it also keeps text sizes consistent?

3 Likes

maybe automatic size? it’s a property you can enable

2 Likes

That would scale the textlabel rather than only affect the text size

1 Like

using text scaled it technically resizes the text based of the scale of the textlabel/box

2 Likes

If you look at this example:

image

The labels are the same size and both have text scaled enabled. However, they still have different text sizes because of the string length. I want their text sizes to be the same but still be able to scale their text sizes when the screen size is changed.

Roblox has a UITextSizeConstraint that lets you set a Maximum and a Minimum size to the parent label, which puts a limit on TextScaled text! (Creator Hub Docs - TextSizeConstraint)

2 Likes

Even if I use it, text scaled will still set the sizes differently since if I set the min text size to be 10 and the max to be 100, one label might have a size of 20 and one might have a size of 15

Yes, that’s the way it works. If the maximum is 100, then the text will scale to the size of the TextLabel, whereas if you set it to something like 30 or 40, both will be that exact font size. You can play around with the sizes to see what fits, then use it for every TextLabel.

1 Like

Despite that being the solution for one static screen size, when the size changes, the text size can become very small or can become very big.

Roblox offers a lot of constraints you can add to any gui.

1 Like

What constraint would I use to solve the issue

There are so many ways to deal with gui it becomes a personal choice.

I use a consistent frame size with an aspect ratio constraint. Then dupe that frame over and over for everything I need. That way if I need to swap things between frames my text sizes do not change.

I also you a maximum size constraint since mobile size labels can appear huge on a desktop display.

For buttons, I usually add text over the top of the button as a text label.

So many choices.

1 Like

Could you provide me with the solution for the problem because I don’t think all the things you stated will impact text labels having inconsistent text size unless I am mistaken.

Using offset will keep your gui from scaling:

offset

Using scale will allow your gui to scale:

scale

If you want your gui to scale to fit the screen then you need to use constraints. All the things I mentioned will affect your gui scaling.

1 Like

My gui scaling to fit the screen isn’t the problem. The problem is that the text size isn’t consistent because of textscaled but if I remove textscaled, then the text size won’t scale on screen size

1 Like

I understand.

That is why I use a text label that is independent of my button.

Change the HEIGHT of the TextLabel to be consistent for all TextLabels (of that size).

Then use a consistent backing frame size and you can move your buttons/text labels from frame to frame without problems.

What do you mean by consistent backing frame size?

An easy lazy solution could be to create a second label (or UIPadding inside of the text label instead of container > label) inside of your main container and just mess around with the sizes and such until you find a size that fits both labels.

Green is the size of the actual label, the white is a container frame
image

Or in the case of a UIPadding, create one inside of your TextLabel like so:

I guess it mostly depends on whether you’re creating your buttons programatically. Could you let me know if you’re looking for something programatic or if you’re ok with doing it manually?

1 Like

I place a Frame then add a AspectRatioConstraint inside of it.

Then I duplicate that Frame for all gui elements.

I find that I need to change my mind a lot and I hate when I drag a button from one frame to another and it gets messed up.

I was wondering if I could get something programatic