Skip to content

Latest commit

 

History

History
239 lines (177 loc) · 6.45 KB

rich-text.md

File metadata and controls

239 lines (177 loc) · 6.45 KB
title description comments
Rich Text Markup
Rich Text Markup are simple markup tags to style sections of a string.
1. Replace numbered footnotes with dedicated style.

UI rich text utilizes simple markup tags to style sections of a string in bold, italics, underline, fill color, stroke variations, and more. You can apply styling tags to Class.TextLabel, Class.TextButton, and Class.TextBox objects.

Enabling Rich Text

You must enable rich text on a per-object basis through its RichText property in the Properties window, or by setting the property to true in a Class.LocalScript.

local title = Instance.new("TextLabel")
title.RichText = true

title.Text = "Use a <b>bold title</b>"
When editing an object's **Text** property in Studio, toggling the **RichText** checkbox in the [Properties](../studio/properties.md) window displays the text string as a final render. This is useful for identifying and correcting mistakes in any [supported tags](#supported-tags). Localizing a game to support other languages removes rich text formatting tags. To ensure formatting appears in other languages, re-apply the tags manually to your localized strings.

Supported Tags

Rich text tags are similar to XML/HTML tags and you must include both an opening and closing tag around the formatted text.

<b>Formatted Text</b>

You can also nest tags inside each other as long as you close them in the reverse order of how you opened them.

<b><i><u>Formatted Text</u></i></b>

Color

<font color=""> </font>

`I want the orange candy.`
`I want the orange candy.`

Size

<font size=""> </font>

`This is big. This is small.`

Font Face

<font face=""> </font>

`This is Michroma face.`
Font face/family names are listed on the `Datatype.Font` enum reference page.

Font Family

<font family=""> </font>

`This is Michroma face.`
Font face/family names are listed on the `Datatype.Font` enum reference page.

Font Weight

<font weight=""> </font>

`This is normal. This is heavy.`
`This is normal. This is heavy.`
Font weight can be a case-insensitive string name including `Thin`, `ExtraLight`, `Light`, `Regular`, `Medium`, `SemiBold`, `Bold`, `ExtraBold`, or `Heavy`; it can also be a number in factors of 100 between `100` and `900`.

Stroke

<stroke> </stroke>

`You won 25 gems.`
See [UIStroke](../ui/layout-and-appearance.md#uistroke) for details on `` tag parameters such as `joins` and `thickness`.

Transparency

<font transparency=""> </font>

`Text at 50% transparency.`

Bold

<b> </b>

`Text in bold.`

Italic

<i> </i>

`Text italicized.`

Underline

<u> </u>

`Text underlined.`

Strikethrough

<s> </s>

`Text with strikethrough applied.`

Line Break

<br />

`New line occurs after this sentence.
Next sentence...`

Uppercase

<uppercase> </uppercase>
<uc> </uc>

`Uppercase makes words read loudly!`
`Uppercase makes words read loudly!`

Small Caps

<smallcaps> </smallcaps>
<sc> </sc>

`My name is Diva Dragonslayer.`
`My name is Diva Dragonslayer.`

Comment

<!-- -->

`After this is a comment... and now more text...`

Escape Forms

If you want to render certain characters like < or > and exempt them from consideration as part of rich text tags, you can write them in their escape form.

Character Escape Example Result
**<** `<` `10 < 100` 10 < 100
**>** `>` `100 > 10` 100 > 10
**"** `"` `Meet "Diva Dragonslayer"` Meet "Diva Dragonslayer"
**'** `'` `Diva's pet is a falcon!` Diva's pet is a falcon!
**&** `&` `Render another escape form &lt; by escaping an ampersand` Render another escape form **&lt;** by escaping an ampersand