用户界面 富文本 使用简单的标记标签来格式化字符串的部分,用粗体、斜体、下划线、填充颜色、边框变化等来装饰。你可以将样式标签应用到 TextLabel , TextButton , 和 TextBox 对象。
启用富文本
您必须通过其 富文本 属性在 属性 窗口启用富文本,或将属性设置为 true 在 LocalScript 中。

local title = Instance.new("TextLabel")title.RichText = truetitle.Text = "Use a <b>bold title</b>"
支持标签
富文本标签与 XML/HTML 标签类似,你必须在格式化的文本周围包含一个开启和关闭标签。
<b>Formatted text</b>
你也可以将标签叠加在一起,只要你按照打开它们的反向顺序关闭它们。
<b><i><u>Formatted text</u></i></b>
字体颜色
<font color=""> </font>
I want the <font color="#FF7800">orange</font> candy. I want the <font color="rgb(255,125,0)">orange</font> candy.

字体大小
<font size=""> </font>
<font size="40">This is big.</font> <font size="20">This is small.</font>

字体面
<font face=""> </font>
<font face="Michroma">This is Michroma face.</font>

字体家族
<font family=""> </font>
<font family="rbxasset://fonts/families/Michroma.json">This is Michroma face.</font>

字体重量
<font weight=""> </font>
This is normal. <font weight="heavy">This is heavy.</font> This is normal. <font weight="900">This is heavy.</font>

字体透明度
<font transparency=""> </font>
Text at <font transparency="0.5">50% transparency</font>.

轮廓
<stroke> </stroke>
You won <stroke color="#00A2FF" joins="miter" thickness="2" transparency="0.25">25 gems</stroke>.

粗体
<b> </b>
Text in <b>bold</b>.

斜体字
<i> </i>
Text <i>italicized</i>.

下划线
<u> </u>
Text <u>underlined</u>.

撤销线
<s> </s>
Text with <s>strikethrough</s> applied.

行间分割
<br/>
New line occurs after this sentence.<br/>Next sentence...

大写
<uppercase> </uppercase> <uc> </uc>
<uppercase>Uppercase</uppercase> makes words read loudly! <uc>Uppercase</uc> makes words read loudly!

小帽子
<smallcaps> </smallcaps> <sc> </sc>
My name is <smallcaps>Diva Dragonslayer</smallcaps>. My name is <sc>Diva Dragonslayer</sc>.

标记
<mark> </mark>
Text <mark color="#009966" transparency="0">highlighted</mark>.

评论
<!-- -->
After this is a comment...<!--This does not appear in the final text--> and now more text...

逃离表单
如果您想渲染特定字符,例如 < 或 > 并将它们从考虑富文本标签的范围中排除,您可以在其 逃生形式 中写入它们。
角色 | 逃脱 | 例子 | 结果 |
---|---|---|---|
< | < | 10 < 100 | 10 < 100 |
> | > | 100 > 10 | 100 > 10 |
" | " | Meet "Diva Dragonslayer" | 遇见“迷魂龙杀手” |
' | ' | Diva's pet is a falcon! | Diva的宠物是一只猎鹰! |
& | & | Render another escape form <b>&lt;</b> by escaping an ampersand | 通过逃离撇号来渲染另一个逃生形式 < 通过逃离撇号来渲染另一个逃生形式 |