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.set_base_font(load("res://BarlowCondensed-Regular.ttf"))
fv.set_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 ( SpacingType spacing, int value ) |
属性说明¶
Font base_font
用于创建变体的基础字体。如果未设置,则使用默认的 Theme 字体。
Dictionary opentype_features = {}
void set_opentype_features ( Dictionary value )
Dictionary get_opentype_features ( )
一组 OpenType 功能标签。更多信息:OpenType 功能标签。
int spacing_bottom = 0
void set_spacing ( SpacingType spacing, int value )
int get_spacing ( )
行底部的额外间距,单位为像素。
int spacing_glyph = 0
void set_spacing ( SpacingType spacing, int value )
int get_spacing ( )
图形字形之间的额外间距。
int spacing_space = 0
void set_spacing ( SpacingType spacing, int value )
int get_spacing ( )
空格字形的额外宽度。
int spacing_top = 0
void set_spacing ( SpacingType spacing, int value )
int get_spacing ( )
行顶部的额外间距,单位为像素。
float variation_embolden = 0.0
如果不等于零,则加粗字体轮廓。负值会减小轮廓厚度。
注意:加粗字体可能有自相交的轮廓,这将阻止 MSDF 字体和 TextMesh 正常工作。
int variation_face_index = 0
在 TrueType / OpenType 集合文件中的活动字体索引。
Dictionary variation_opentype = {}
void set_variation_opentype ( Dictionary value )
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 ( Transform2D value )
Transform2D get_variation_transform ( )
应用于字体轮廓的 2D 变换,可用于倾斜、翻转和旋转字形。
例如,要通过倾斜来模拟斜体字体,请应用以下变换 Transform2D(1.0, slant, 0.0, 1.0, 0.0, 0.0)
。
方法说明¶
void set_spacing ( SpacingType spacing, int value )
将 spacing
的间距(见 SpacingType)设置为 value
,单位为像素(与字体大小无关)。