GetTextSize with TextScaled?

I don’t think this has been asked and if it did, I can’t find a solution all over the internet yet.

So in GetTextSize, it requires you to input the text size, what text size should I input if the text has TextScaled property enabled?

local textservice = game:GetService("TextService")
game:GetService("RunService").RenderStepped:Connect(function()
	local size = textservice:GetTextSize( script.Parent.TextLabel.Text, script.Parent.TextLabel.TextSize, script.Parent.TextLabel.Font, script.Parent.AbsoluteSize )
	script.Parent.TextLabel.Size = UDim2.new(0, size.X, 0, size.Y)
end)

I don’t think it would matter, since the TextScaled property makes whatever you put in for TextSize property obsolete. Although I may be wrong.

If you selected text scaled, when you change the text size it shows no difference. Due to the text being scaled.

1 Like

The number does affect the result despite that I have TextScaled on, I inputed 100 for the font size, and this is the result, there are some white spaces.
https://gyazo.com/ae75a58b5cadfb0807d587dfbada543c

game:GetService("RunService").RenderStepped:Connect(function()
local size = textservice:GetTextSize( script.Parent.TextLabel.Text, 
	100,
	script.Parent.TextLabel.Font, 
	script.Parent.AbsoluteSize )
local scale = OffsetToScale(size.X, size.Y)
script.Parent.TextLabel.Size = UDim2.new( math.clamp(scale.X, 0, max), 0, 0.04 ,0)

end)

Sorry to bump but this is useful information,

TextScaled is calculated as a whole number with the max of 100, the TextScaled TextSize is the Y Offset Size. Though, with legacy font it is doubled.

6 Likes

Oh my god, THANK YOU!! THIS helped me so much!!