TextService:GetTextSize needs an option for rich text

Right now, it is very difficult to get the bounds of a string with rich text components. I am attempting to upgrade my chat GUI to not use a custom rich text module in favor of Roblox’s built-in renderer, and part of the system relied on using TextService to gauge how big a chat’s container frame needed to be.

Due to the TextService not providing an option to handle rich text, it is nearly impossible to get an appropriate size. While manually cutting out XML tags does partially work, this causes problems for things like bold text, which has a different scale than its non-bold counterpart.

The current workaround I use is to create a dummy TextLabel that mimics a TextLabel in my chat GUI, set its text and parent it to the player’s GUI in an off-screen location, and grab the TextBounds property. This is, for obvious reasons, less than ideal.


Adding onto this, a parameter for LineHeight would be appreciated as well. Wanting to add some spacing between lines doesn’t seem to be accounted for with the current method.


Adding to this. Pretty sure it doesn’t obey RichText either and scales it as a full string.


I’ll bump again since this feature is much needed.

As far as I can see it could be as simple as extending an additional property onto GetTextBoundsParams for the GetTextBoundsAsync(params) TextService method. For instance ObeyRichText which defaults to false:

local params = Instance.new("GetTextBoundsParams")
params.Text = "<b>Shop</b>"
params.Font = Font.new("rbxasset://fonts/families/GrenzeGotisch.json", Enum.FontWeight.Thin)
params.ObeyRichText = true

local result = TextService:GetTextBoundsAsync(params)