跳转到内容

Apply Typeface

Apply Typeface 可作为 Style Behaviour 使用,以程序化方式动态设置在 Text Shape 中使用的字体。例如,将最后一个词的字体设为 Times New Roman,或将字符串中每次出现的 Cavalry 设为 Helvetica。

Font - 选择字体和字重。

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 了解更多信息。

  1. 创建一个 Text Shape
  2. 输入字符串 Here's to the crazy ones
  3. 点击 Style Behaviours 属性右侧的 +
  4. 从列表中选择 Apply Typeface
  5. 双击 Scene Window 中的 Apply Typeface 图层,将其 UI 加载到 Attribute Editor。
  6. 设置一个 Font
  7. Regex 属性中输入字符串 crazy

Text Shape 中单词 crazy 将被设为步骤 6 中选择的字体。