跳到內容

Apply OpenType

Apply OpenType 可作為 Style Behaviour 使用,以程序化方式動態啟用在 Text Shape 中使用的 OpenType 功能。

Mode - 選擇選取模式:

  • Regex - 設定一個正規表示式來決定字串的哪些部分被選取。在 Attribute Editor UI 頂部有幾個預設可用。
  • Specific Indices - 手動輸入索引來決定哪些行/詞/字元被選取。
  • All - 當與 Behaviour 一起使用 Apply Typeface 時使用此設定。參見 Create > Demo Scenes > Text > Variable Font

Index Mode - 當 Mode 設為 Specific Indices 時,選擇受影響的層級:

  • Line - 填充 Specific Indices 定義的每一行。
  • Word - 填充 Specific Indices 定義的每個詞。
  • Character - 填充 Specific Indices 定義的每個字元。

Specific Indices - 當 Mode 設為 Specific Indices 時,設定要選擇的索引。列表值使用逗號 , 分隔,範圍使用冒號 : 分隔。例如 0,1:3,8 將選擇索引 0、1、2、3 和 8。你也可以輸入 firstlast 來程序化選擇這些索引。注意空格字元也包括在索引中。

Regex - 輸入一個正規表示式。參見 Working with Regex 了解更多資訊。

Capture Group Indices - 當正規表示式包含捕獲群組時,決定傳回哪些群組。列表值使用逗號 , 分隔,範圍使用冒號 : 分隔。參見 Working with Regex 了解更多資訊。

Button iconAdd - 使用此按鈕向 UI 加入更多行(索引)。

Font Feature - 從列表中選擇一個 OpenType 功能。注意此列表不是基於字型過濾的,因此請確保使用的字型支援該功能。

Enabled - 勾選時,OpenType 功能被啟用。

  1. 建立一個 Text Shape
  2. Font 設為 Inter
  3. 輸入字串 I heard the store is open from 1st June to 3rd July.
  4. 點擊 Style Behaviours 屬性右側的 +
  5. 從列表中選擇 Apply OpenType
  6. 雙擊 Scene Window 中的 Apply OpenType 圖層,將其 UI 載入到 Attribute Editor。
  7. Mode 設為 Regex
  8. Regex 控制項中輸入字串 (\d+)(st|nd|rd|th)
  9. Capture Group Indices 控制項中輸入 2
  10. Font Feature 列表中選擇 ‘Superscript’。

只有當數字後面出現 strd 時,這些字元才會被設為上標。