I’m bad at GUIs but I want to learn how to Calculate the TextSize.
I want to achieve cool effect where the Text is hidding when it’s getting smaller at X axis.
There how it looks:
To do that I have to turn off the TextScaled and TextWrapped (TextScaled turns off after turning off TextWrapped).
When using other devices the Text is too big and I want to solve this by calculatix TextSize
I tried to find the solution but I only found something about Chat TextBound Calculation where we need to use TextService to get the TextSize.
TextBounds Vector2
The read-only property TextBounds reflects the absolute size of rendered text in offsets. In other words, if you were to try to fit text into a rectangle, this property would reflect the minimum dimensions of the rectangle you would need in order to fit the text.
Maybe I’m stupid, but it still give me no idea how to calculate it.
Edit:
Okay I found the solution.
I have to divide the AbsoluteSize of TextLabel or TextButton by the TextBounds.
So it would look like this:
local TextLabel = -- Your Path to your TextLabel or TextButton
local TextSize = TextLabel.TextSize
local TextBoundsX = TextLabel.TextBounds.X
local TextBoundsY = TextLabel.TextBounds.Y
local TextLabelSizeX = TextLabel.AbsoluteSize.X
local TextLabelSizeY = TextLabel.AbsoluteSize.Y
local XScale = TextLabelSizeX / TextBoundsX
local YScale = TextLabelSizeY / TextBoundsY
local MinScale = math.min(XScale, YScale)
TextSize *= MinScale