Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
FontVariation
继承: Font < Resource < RefCounted < Object
字体的变体,提供额外的设置。
描述
提供 OpenType 变体,模拟的粗体/斜体,以及 OpenType 特性和额外间距等额外的字体设置。
要使用模拟的粗体变体:
var fv = FontVariation.new()
fv.base_font = load("res://BarlowCondensed-Regular.ttf")
fv.variation_embolden = 1.2
$Label.add_theme_font_override("font", fv)
$Label.add_theme_font_size_override("font_size", 64)
var fv = new FontVariation();
fv.SetBaseFont(ResourceLoader.Load<FontFile>("res://BarlowCondensed-Regular.ttf"));
fv.SetVariationEmbolden(1.2);
GetNode("Label").AddThemeFontOverride("font", fv);
GetNode("Label").AddThemeFontSizeOverride("font_size", 64);
要设置多个变体轴的坐标:
var fv = FontVariation.new();
var ts = TextServerManager.get_primary_interface()
fv.base_font = load("res://BarlowCondensed-Regular.ttf")
fv.variation_opentype = { ts.name_to_tag("wght"): 900, ts.name_to_tag("custom_hght"): 900 }
属性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
void |
set_spacing(spacing: SpacingType, value: int) |
属性说明
用于创建变体的基础字体。如果未设置,则使用默认的 Theme 字体。
额外的基线偏移(作为字体高度的一部分)。
Dictionary opentype_features = {} 🔗
void set_opentype_features(value: Dictionary)
Dictionary get_opentype_features()
一组 OpenType 功能标签。更多信息:OpenType 功能标签。
PackedColorArray palette_custom_colors = PackedColorArray() 🔗
void set_palette_custom_colors(value: PackedColorArray)
PackedColorArray get_palette_custom_colors()
用于覆盖预定义调色板的颜色数组。在特定位置使用 Color(0, 0, 0, 0) 以保留预定义调色板中的原有颜色。
Note: The returned array is copied and any changes to it will not update the original property value. See PackedColorArray for more details.
一个调色板索引。
void set_spacing(spacing: SpacingType, value: int)
int get_spacing()
行底部的额外间距,单位为像素。
void set_spacing(spacing: SpacingType, value: int)
int get_spacing()
图形字形之间的额外间距。
void set_spacing(spacing: SpacingType, value: int)
int get_spacing()
空格字形的额外宽度。
void set_spacing(spacing: SpacingType, value: int)
int get_spacing()
行顶部的额外间距,单位为像素。
float variation_embolden = 0.0 🔗
如果不等于零,则加粗字体轮廓。负值会减小轮廓厚度。
注意:加粗字体可能有自相交的轮廓,这将阻止 MSDF 字体和 TextMesh 正常工作。
int variation_face_index = 0 🔗
在 TrueType / OpenType 集合文件中的活动字体索引。
Dictionary variation_opentype = {} 🔗
void set_variation_opentype(value: Dictionary)
Dictionary get_variation_opentype()
字体 OpenType 变体坐标。详见:OpenType 变体标签。
注意:这个 Dictionary 使用 OpenType 标签作为键。变体轴既可以用标签来标识(int,例如 0x77678674),也可以用名称来标识(String,例如 wght)。有些轴可以通过多个名称来访问。例如,wght 和 weight 引用的是同一个轴。而标签则是唯一的。要在名称和标签之间转换,请使用 TextServer.name_to_tag() 和 TextServer.tag_to_name()。
注意:要获取字体的可用变体轴,请使用 Font.get_supported_variation_list()。
Transform2D variation_transform = Transform2D(1, 0, 0, 1, 0, 0) 🔗
void set_variation_transform(value: Transform2D)
Transform2D get_variation_transform()
应用于字体轮廓的 2D 变换,可用于倾斜、翻转和旋转字形。
例如,要通过倾斜来模拟斜体字体,请应用以下变换 Transform2D(1.0, slant, 0.0, 1.0, 0.0, 0.0)。
方法说明
void set_spacing(spacing: SpacingType, value: int) 🔗
将 spacing 的间距设置为 value,单位为像素(与字体大小无关)。