TextBox How to keep the same text size for every screen resolution?

Hello!

I have a TextBox and what I need is basically having the text size scale depending on a screen resolution.

I tried enabling TextScaled which keeps the size same but I don’t want the text to be scaled to fit the whole TextBox like this :

Screenshot_2

Instead, when I disable TextScaled I get the result I want but then the text doesn’t stay the same on all sceen resolutions :

Screenshot_3

^ That’s what I want to achieve.

Thank you for reading.

8 Likes

Try using UITextSizeConstraint to set a minimum and maximum size for the text and force it on that size you want.

1 Like

Does that auto change the size depending on the screen resolution though?

No it does not. It only resizes it depending on the label’s size from what I have tested.

You know any way how I would achieve having the size of the text same on every resolution?

Not sure what you mean as some users might have bigger and others smaller resolution screens which would show the TextBox bigger on one and smaller on another. For that you would use the pixels rather than the scale property in the Gui’s size.

1 Like

I’m not talking about the gui size. I’m talking about the TextSize.

Yes I know, but what I’m trying to achieve is having the TextBox TextSize staying the same on every screen (resolution), so it’s not bigger or smaller.

Then just disable the TextScaled property (un ticked).

That solves the size of the text not filling the whole frame but results in what I’ve mentioned already :

Resolution : 640x480
Screenshot_4

Resolution : 1920x1080
Screenshot_5

This is what happens when TextScaled = false.

You might be able to fix this if the UI size is same for all devices. You could use plugins such as Autoscale to make the UI same for all devices.

The UI size is same for all devices, yet the TextSize changes.

Seems to be working good on my end

Reproduction:
Default Label Properties with text allignment X on left and Y on top.
Place UITextSizeConstraint in the Label with MaxTextSize of 30

Could you try using TextBox please.

1 Like

TextBox.rbxl (20.4 KB)

Yeah that works, but only when using pixels. If I use scale + UIAspectRatioConstraint to make the gui size be the same it stops working.
TextBox.rbxl (21.0 KB)

Sorry I’m not sure I know a solution to your issue. All I can tell you is to set the TextBox’s size using the Offset rather than the Scale so it all looks same size on every device.

Offset doesn’t make the UI look same size on every device or does it?

Well, thank you for your time and trying!

Would also like to know the solution to this problem, if anyone knows please lend a hand!

1 Like

Offset makes UI the same physical size on all devices, if that’s what you’re asking, provided they have the same density of pixels.

Scale is about keeping objects covering the same percentage of your screen, whether it’s big or small, portrait or landscape.

On the UIConstraints, if they will help depends on your question. Do you want the text to take up the same percentage of space inside the TextBox on all screens?

Yeah, thats what I want pretty much.