富文本標記

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

UI 豐富文字 使用簡單的標記標籤來格式化字串的部分,以粗體、斜體、潛線、填色、線條變化等來裝飾。您可以將樣式標籤應用到 TextLabelTextButtonTextBox 對象。

啟用豐富文字

您必須通過其 RichText 屬性在 屬性 視窗中啟用豐富文字,或將屬性設置為 trueLocalScript 中。


local title = Instance.new("TextLabel")
title.RichText = true
title.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...

逃離表單

如果您想渲染特定字符,例如 <> 並將它們從考慮富文本標籤的一部分中除外,您可以在其 逃生形式 中寫入它們。

角色逃脫範例結果
<&lt;10 &lt; 10010 < 100
>&gt;100 &gt; 10100 > 10
"&quot;Meet &quot;Diva Dragonslayer&quot;遇見「迷你龍殺手」
'&apos;Diva&apos;s pet is a falcon!迪瓦的寵物是一隻隼!
&&amp;Render another escape form <b>&amp;lt;</b> by escaping an ampersand透過逃脫撇號來渲染另一個逃生形式 < 由逃脫撇號