TextScaled and TextWrapped are off.The TextSize is 14. The size of the TextLabel is (0, 100, 0, 14). The TextBounds are (9, 14). To me, that would suggest that if you have a GUI with size (0, 9, 0, 14), then the text would fit within that container. That sounds reasonable, right?
Yet, as shown by the image, the “g” doesn’t fit within the TextLabel. I put a border of size 1 around the TextLabel to show that it doesn’t fit. Why doesn’t the text fit in the TextLabel if TextBounds.Y is equal to AbsoluteSize.Y?
Additionally, TextFits is true. I can understand this, as TextFits probably just returns true if the TextBounds values are less than or equal to the AbsoluteSize values. But again, my text doesn’t fit. And then the wiki describes TextFits as follows:
The TextFits is a read-only property that is true if rendered TextLabel.Text content does not fit within the GuiBase2d.AbsoluteSize
So TextFits, “text fits,” is true if and only if the text doesn’t fit? What? How does that make any sense? This is wrong, right? TextFits seems to change to false if TextLabel.TextBounds.X > TextLabel.AbsoluteSize.X, but not if TextLabel.TextBounds.Y > TextLabel.AbsoluteSize. Y. What is the reason for this?
If someone could enlighten me I’d really appreciate it, because these two problems have caused me a lot of issues this morning. Thanks.
I’m wondering, are you talking about it fitting in the X axis or the Y axis? It’s not really guaranteed that it’ll fit in the Y axis because typeface sizing is really stupid. And by really stupid, I mean… this is an old art, basically. It didn’t translate all that well to computers.
As you can see, Roblox considers the height from the baseline to… I’m not really sure, it might be the cap height, might be the ascender height, or it could be something totally arbitrary. However, I do know that Roblox normalizes font sizes such that the TextSize is equal to the Y size that TextBounds and TextService:GetTextSize() will give you.
Other than that, I’m not sure what to tell you, since I doubt anyone has plans to change this API. I always design my UI with 4-8 pixels of padding all around any text, otherwise it just looks bad even if there are no descenders to cut off. It could be that we could request an extra method for getting other metrics like the descender height, but I doubt it’d be a very high priority item.
This is likely caused by the way text is considered sized. The text or font size refers to the pixels (in height) from the base line to the median line of text, however some characters go outside of this bounding (‘g’, ‘y’, ‘p’, ‘q’, ‘j’, ‘,’ for starters) as they go under the base line. A line of text is not measured from the top pixel rendered to the bottom pixel rendered, but instead the base lines used to define the font.
By all technical standards your text does fit, because the bounding boxes of the height of the font and the width of the letters placed together.
It’s meant for a chatbox that would resize its y-value based on the amount of text. Based on the other responses, it seems like the best bet is just to add a few extra pixels on the y-axis because of how the text size is defined.
I’m only able to reproduce this with Arial font, I don’t run into this issue when using SourceSans. This might be a pixel rounding issue, I’ll look into it.
I’m so happy to hear Roblox makes sure to adhere to a standard that makes sense! <3 I’m used to working with large font repositories where each font makes it’s own rules.
Thanks for updating (and @'ing) so we can be on the same page.