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

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.

Can’t you just enable TextScaled?

Yeah I could do that, but then it will have the text fit in the whole size of the TextBox like this :

174d116a68b21525bca6c7a0c2456de4112fe47d

instead of this :

bcdb6498229588f667b5ca709a2008852c50780f

1 Like

Sorry about that, I should have read all the replies more carefully.

I think you could utilise TextBox.AbsoluteSize. If you set the TextBox’s size with scale, you can multiply it by a number to set the size based on resolution. Depending on whether you want the same height or width, it would work like this:

TextBox.TextSize = TextBox.AbsoluteSize.X * MagicNumber

or

TextBox.TextSize = TextBox.AbsoluteSize.Y * MagicNumber

I tested this in Studio and it seems to work.

31 Likes

I’ll definitely try this and let you know!

EDIT :

Worked! Thank you :heart:

1 Like