FontVariation
继承: Font
< Resource
< RefCounted
< Object
A variation of a font with additional settings.
描述
Provides OpenType variations, simulated bold / slant, and additional font settings like OpenType features and extra spacing.
To use simulated bold font variant:
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);
To set the coordinate of multiple variation axes:
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 ) |
属性说明
Font
base_font
Base font used to create a variation. If not set, default Theme
font is used.
float
baseline_offset = 0.0
Extra baseline offset (as a fraction of font height).
Dictionary
opentype_features = {}
void
set_opentype_features ( value:Dictionary
)Dictionary
get_opentype_features ( )
A set of OpenType feature tags. More info: OpenType feature tags.
int
spacing_bottom = 0
void
set_spacing ( spacing: SpacingType, value:int
)int
get_spacing ( )
Extra spacing at the bottom of the line in pixels.
int
spacing_glyph = 0
void
set_spacing ( spacing: SpacingType, value:int
)int
get_spacing ( )
Extra spacing between graphical glyphs.
int
spacing_space = 0
void
set_spacing ( spacing: SpacingType, value:int
)int
get_spacing ( )
Extra width of the space glyphs.
int
spacing_top = 0
void
set_spacing ( spacing: SpacingType, value:int
)int
get_spacing ( )
Extra spacing at the top of the line in pixels.
float
variation_embolden = 0.0
If is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
Note: Emboldened fonts might have self-intersecting outlines, which will prevent MSDF fonts and TextMesh
from working correctly.
int
variation_face_index = 0
Active face index in the TrueType / OpenType collection file.
Dictionary
variation_opentype = {}
void
set_variation_opentype ( value:Dictionary
)Dictionary
get_variation_opentype ( )
Font OpenType variation coordinates. More info: OpenType variation tags.
Note: This Dictionary
uses OpenType tags as keys. Variation axes can be identified both by tags (int
, e.g. 0x77678674
) and names (String
, e.g. wght
). Some axes might be accessible by multiple names. For example, wght
refers to the same axis as weight
. Tags on the other hand are unique. To convert between names and tags, use TextServer.name_to_tag
and TextServer.tag_to_name
.
Note: To get available variation axes of a font, use 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 transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.
For example, to simulate italic typeface by slanting, apply the following transform Transform2D(1.0, slant, 0.0, 1.0, 0.0, 0.0)
.
方法说明
void
set_spacing ( spacing: SpacingType, value: int
)
Sets the spacing for spacing
(see SpacingType) to value
in pixels (not relative to the font size).
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。