Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I "calculate" the functionality of "TextScaled"?

Asked by 5 years ago
Edited 5 years ago

Im creating a more updated and quicker Richtext module using itty bitty bits and pieces of Defaultio's Richtext module. One of the features of my Richtext module is the TextScaled behavior acting more like the inbuilt one roblox has, instead of Defaultio's system of getting the screen gui and dividing it by a percentage for "newlines".

I need to know how i would calculate a roblox TextScaled system in terms of its math, i would like to use as little functions as possible, because it will be ran on every character of the text. I have everything in place a simply need to make the textscaled feature to continue onwards with animations.

UPDATE: Some of you (coughpidgeycough) May not understand what im trying to achieve, not to be harsh on pidgey, his system for getting needed lines at a fontsize helps me 100% as i was going to probably use a more resource intensive way to calculate such system, i want something to get a reasonable FontSize using AbsoluteSize of the gui that makes sure that the FontSize will fit, while also being as big as the FontSize can get. Im not sure about a way on doing this. Dividing the AbsoluteSize by the string size could work but im not sure it would get the biggest size i can do (accounting for allowing lines too) seeing as it might get a fontsize that will fit if only for one line.

0
To get the amount of pixels your string has, multiply the amount of characters by the TextSize, then divide by 2. Divide that value by the AbsoluteSize of the GuiObject to get how many lines you would need to fit the string into whatever object. pidgey 548 — 5y
0
Also, you should round to the nearest 1 (use math.ceil). So StringSize = (14 * #"test string") / 2, then you can divide StringSize by the AbsoluteSize of the GuiObject. x = math.ceil(StringSize / AbsoluteSize.X). This is your unit number that represents how many 'lines' you need to fit the string. pidgey 548 — 5y
0
pidgey, Realized that this isnt for the system roblox uses for it's TextScaled. Its help i digress making lines for a set size easy, but i need to get biggest size i can do for the font, while trying to keep it as big as possible popgoesme700 113 — 5y
0
To put simpley, i need a system to calculate something with AbsoluteSize and try to generate a reasonable FontSize that will fit the frame but make said fontsize as big as possible. Like the TextScaled property on a roblox textlabel/textbutton/textbox to make the text fit on all screen sizes popgoesme700 113 — 5y

Answer this question