How to scale text perfectly (solved)

Hey! Does anyone have an idea on how I could scale text properly in a script? TextScaled can be too large at times and constraints don’t make much sense to me. This is a really simple problem I assume but I couldn’t find any answers so I’ve decided to post it here.

Example: Size 14 on PC could be Size 5 on Mobile but they’d both look the same

Right now it’s way too big on mobile, is there some sort of formula I can use to solve this?

Any idea how I can achieve this?

EDIT: I’ve solved this :smiley:

12 Likes

If you are doing it that way for mobile and computer, I like to use this AutoScale Plugin by ZacBytes, this is used to scale frames, textbuttons, textlabels and basically anything Gui to a good size for mobile and computer users.

Edit: sorry didn’t read your post thoroughly, btw this should be in the #help-and-feedback:art-design-support category, since this is Gui related and not script related.

1 Like

That only scales the size, not the TextSize which looks off. The size could look perfect on PC but horrible on mobile.

1 Like

You could try using offset for your text size but using scale for your position, This would keep the text size consistent on all platforms while maintaining the position on the screen.

I’d recommend making use of AnchorPoints and using constraints like UIAspectRatioConstraint and UIPadding to get the proper sizing and scaling you’re looking for.

The way I personally approach this problem is by designing my UI using Offset, and later scripting a custom scaling solution using UIScale. It’s not a perfect solution (especially if you’re working with absolute positions, in which case you’ll need to account for scale) but it’s so much easier than trying to make a consistently scaled UI using Scale.

1 Like

How would you use UIScale in your case with a script?

Warning There is no way to “perfectly” scale text.

How I Do It Make all Text GuiObjects scale-based in size. Parent them to scale-based GuiObjects like Frames with UIAspectRatioConstraint to maintain proportionality. For example, if I want a rectangular button with a text description inside of it, I make the button have a UIAspectRatioConstraint based on its absolute pixel width divided by its absolute pixel height then I add a child TextLabel of size UDim2.new(.9, 0, .7, 0), set the anchor points to .5,.5, center it at UDim2.new(.5, 0, .5, 0) and then set TextScaled to true. This will allow the text to always be a scale-based proportion of an already scaled and ratio’d parent. With TextScaled, the largest font size that can fit within the absolute pixel size of the text GuiObject will be utilized. This is probably the most adequate way to scale text…

36 Likes

If you want the TextSize to scale but using your own preferred TextSize then…

Here’s one way to do it, have the entire UI done on a device preferably S7 or iPhone 7. Make sure the Objects are inside a single Frame, and that it has an aspect ratio that scales proportionally. (You shouldn’t need UIAspectRatio but just in case.)

Then, increase the size of the Text based on the Frames size. For example if the original absolute x size of Frame is 412 on an S7 and its new absolute x size on a PC is 1200 just do 1200 / 412 to get how much it increased by and then multiply that to your text size.

S7XOffset = 412
PC = 1200

1200 / 412 = 2.912..

GuiObject.TextSize = math.floor((child.TextSize * Multiplier) + 0.5)
-- or if you don't want to round it
GuiObject.TextSize *= Multiplier

7 Likes