TextLabel property TextFits fails when text fits exactly and TextWrapped == true

I’ve run across this bug in several cases. I’m using it in basically the same way in each case. Here’s one.

I automatically generate a changelog gui:


from a list that just has all the dates and strings in it:


Some entries take up more than one line. To figure out how tall each entry has to be vertically, I add one line’s worth of height to the TextLabel at a time until the TextFits property becomes true. I just stop there and I know I’ve got the height right.

Sometimes, it doesn’t work though. The TextFits property will never go true and this happens:


Since it never becomes true, more height keeps being added until it hits a hard limit that I set. I have to always check the changelog to make sure it comes out right whenever I add an entry. If this happens, I have to reword it until it works. It’s a pain.

It looks like a thing where TextFits is set to true when the pixel size of the text < the frame width, but the text will wrap to a new line if the text >= the frame width. This allows a case in which the text width == the frame width, in which the text wraps, but TextFits is still not true.

3 Likes

I had this exact same issue with TextFits and I never knew what the exact cause of it was. Hoping to see this get fixed.

You’ll have to wrap the lines yourself.
You should also see if .TextBounds displays the right dimensions for the text.


Wrapping yourself is quite easy:
Keep adding words as long the resulting string has TextLabel.TextBounds.X < Frame.AbsoluteSize.X.
When the width is too great, just move to a new line and continue.

That defeats the purpose of the built in ROBLOX functionality though. It should still be fixed.
TextFits should ALWAYS return true if its <= and false if its >

Making my chatGUI was a huge pain because of issues like this. It shouldn’t be a pain. I should be able to rely on ROBLOX’s API to function correctly.

4 Likes