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。你也可以输入 first 或 last 来程序化选择这些索引。注意空格字符也包括在索引中。
Regex - 输入一个正则表达式。参见 Working with Regex 了解更多信息。
Capture Group Indices - 当正则表达式包含捕获组时,确定返回哪些组。列表值使用逗号 , 分隔,范围使用冒号 : 分隔。参见 Working with Regex 了解更多信息。
Add - 使用此按钮向 UI 添加更多行(索引)。
Font Feature - 从列表中选择一个 OpenType 功能。注意此列表不是基于字体过滤的,因此请确保使用的字体支持该功能。
Enabled - 勾选时,OpenType 功能被启用。
- 创建一个 Text Shape。
- 将 Font 设为 Inter。
- 输入字符串
I heard the store is open from 1st June to 3rd July.。 - 点击 Style Behaviours 属性右侧的
+。 - 从列表中选择 Apply OpenType。
- 双击 Scene Window 中的 Apply OpenType 图层,将其 UI 加载到 Attribute Editor。
- 将 Mode 设为 Regex。
- 在 Regex 控件中输入字符串
(\d+)(st|nd|rd|th)。 - 在 Capture Group Indices 控件中输入
2。 - 从 Font Feature 列表中选择 ‘Superscript’。
只有当数字后面出现 st 或 rd 时,这些字符才会被设为上标。