RichText adds paragraph indentation only after the first newline

Re-posting since this thread was put in the wrong category:

OP:

Enabling RichText on a TextLabel creates unexpected spaces beyond the first newline (\n) character.

Without richtext:


With richtext:

There are no tags on the text, it is simply raw text.


I rely on RichText to adapt to the DevForum’s markdown (as I am porting text directly from it). Beyond the first header, it creates a weird effect where each line afterwards is followed by a space or some form of whitespace, which is not the behavior I expect. The text itself does not include any spaces.

Some other statistics:

It only applies to TextXAlignment Centered and Left
TextYAlignment does not affect it
TextScaled is false
TextWrapped is true
A UIPadding element exists, but doesn’t seem to be the problem
It affects ScreenGuis as well
It probably affects BillboardGuis


The going workaround is to set the font size of the last newline in a series to 0:

My code:

local function fixParagraphIndents(text: string)
    return text
        :gsub("<br%s*/>", "\n")
        :gsub("(\n)([^\n])", "<font size='0'>\n</font>%2")
end
3 Likes

Thanks for the report. I filed a ticket to our internal database.

2 Likes

Hey, I just want to let you know that this issue appears to be fixed: RichText creating unexpected spaces? - #13 by 0xabcdef1234

1 Like

We are closing this issue based on the reply from our Roblox Staff:

If the issue is still occurring, please file a new bug report!

Thank you!

2 Likes