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...
SystemFont
继承: Font < Resource < RefCounted < Object
从系统字体加载的字体。如果未在宿主操作系统上实现,则回退到默认主题字体。
描述
SystemFont 会从系统字体中加载一个字体,该字体是名称能与 font_names 匹配的第一个字体。
会尝试匹配字体样式,但是并不保证。
返回的字体可能属于某个字体合集,也可能是设置了 OpenType“字重”“宽度”和/或“斜体”特性的可变字体。
你可以创建系统字体的 FontVariation,以便对其特征进行精细控制。
注意:这个类在 iOS、Linux、macOS、Windows 上实现,在其他平台上会回退到默认主题字体。
属性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
属性说明
bool allow_system_fallback = true
🔗
如果设置为 true
,则可以自动将系统字体作为回退使用。
FontAntialiasing antialiasing = 1
🔗
void set_antialiasing(value: FontAntialiasing)
FontAntialiasing get_antialiasing()
字体抗锯齿模式。
bool disable_embedded_bitmaps = true
🔗
如果为 true
,则会禁用内嵌字体位图的加载(仅包含位图的字体以及彩色字体会禁用该属性)。
如果设置为 true
,则优先使用斜体(italic)或伪斜体(oblique)。
PackedStringArray font_names = PackedStringArray()
🔗
void set_font_names(value: PackedStringArray)
PackedStringArray get_font_names()
要搜索的字体家族名称数组,会使用第一个与之匹配的字体。
Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray for more details.
字体优先使用的拉伸量,相对于正常宽度。介于 50%
和 200%
之间的百分比。
字体优先使用的字重(粗度)。在 100...999
范围内的值,正常字重为 400
,粗体字重为 700
。
bool force_autohinter = false
🔗
如果设置为 true
,则支持自动微调,优先于字体内置微调。
bool generate_mipmaps = false
🔗
如果设置为 true
,则为字体纹理生成 mipmap。
字体微调模式。
bool keep_rounding_remainders = true
🔗
如果设置为 true
,则将字形与像素边界对齐时会累积舍入余数,确保字形的分布更加均匀。如果启用了次像素定位则该设置无效。
最小和最大可表示的有符号距离之间的形状周围的范围宽度。如果使用字体轮廓,msdf_pixel_range 必须至少设置为最大字体轮廓大小的两倍。msdf_pixel_range 的默认值为 16
,允许大小最大到 8
的轮廓看起来正确。
用于生成 MSDF 纹理的源字体大小。较高的值允许更高的精度,但渲染速度较慢并且需要更多内存。只有当注意到字形渲染中明显缺乏精度时,才增加该属性的值。
bool multichannel_signed_distance_field = false
🔗
void set_multichannel_signed_distance_field(value: bool)
bool is_multichannel_signed_distance_field()
如果设置为 true
,则所有大小的字形都将使用从动态字体矢量数据生成的单个多通道带符号距离场渲染。
字体过采样系数,如果设置为 0.0
则使用全局过采样系数。
SubpixelPositioning subpixel_positioning = 1
🔗
void set_subpixel_positioning(value: SubpixelPositioning)
SubpixelPositioning get_subpixel_positioning()
字体字形的次像素定位模式。次像素定位为较小的字体提供了更清晰的文本和更好的字偶距,但会牺牲内存占用和字体栅格化速度。使用 TextServer.SUBPIXEL_POSITIONING_AUTO 可以根据字体大小自动启用。