Problem
As a Roblox developer, it is currently too hard to use rich formatted text when using
TextService:GetTextBoundsAsync()
to calculate space requirements of a container that holds text. Currently, the rich text markup is considered as part of the displayed text when calculating the needed space. This results in too much space being allocated for text. See the below visuals for illustration of the issue.
Normal
Rich Text
Video
robloxapp-20240401-1336153.wmv (161.3 KB)
One can load the below file into Studio so they can see the issue.
Engine - TextService-GetTextBoundsAsync.rbxl (58.9 KB)
Currently, the only ways around this is to
- Have two text strings. One contains rich text that is displayed, the other without the rich text which is used for space calculations.
- Have one text string, but use a function/method to produce a copy of the string with all rich text markup removed to be used in space calculations.
Conclusion
If Roblox is able to address this issue, it would improve my development experience because then rich text can be used as-is when calculating space requirements when using
TextService:GetTextBoundsAsync()
without the need for elaborate workarounds.