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.

ResourceImporterImageFont

继承: ResourceImporter < RefCounted < Object

导入位图字体,所有字形使用的都是相同的宽高。

描述

这种基于图像的工作流程比 ResourceImporterBMFont 更易于使用,但它要求所有字形具有相同的宽度和高度,字形前进和绘制偏移可以自定义。这使得 ResourceImporterImageFont 最适合固定宽度的字体。

另见 ResourceImporterDynamicFont

教程

属性

int

ascent

0

Rect2i

character_margin

Rect2i(0, 0, 0, 0)

PackedStringArray

character_ranges

PackedStringArray()

int

columns

1

bool

compress

true

int

descent

0

Array

fallbacks

[]

Rect2i

image_margin

Rect2i(0, 0, 0, 0)

PackedStringArray

kerning_pairs

PackedStringArray()

int

rows

1

int

scaling_mode

2


属性说明

int ascent = 0 🔗

字体的上高(基线上方的像素数)。如果设为 0 则使用字符高度的一半。


Rect2i character_margin = Rect2i(0, 0, 0, 0) 🔗

在每个导入的字形周围应用边距。如果你的字体图像包含参考线(以字形之间的线的形式)或者字符之间的间距看起来不正确,请尝试调整 character_margin


PackedStringArray character_ranges = PackedStringArray() 🔗

从字体图像导入的字符范围。这是一个数组,能够对图像上的每一个位置做映射(使用图块坐标,而非像素坐标)。字体图集是从左到右、从上到下遍历的。可以使用十进制数字(127)、十六进制数字(0x007fU+007f)、单引号('~')来指定字符。在字符之间加上连字符指定的就是一个范围。

例如 0-127 表示的是完整的 ASCII 范围。这个范围也可以写作 0x0000-0x007f(或者 U+0000-U+007f)。再比如,' '-'~' 等价于 32-127,表示的是可打印(可见)ASCII 字符的范围。

指定范围时如果在后面加上三个用空格分隔的整数值,就可以自定义字符的前进量和偏移(额外前进量、X 偏移量、Y 偏移量)。例如 'a'-'b' 4 5 2 就是将 ab 这两个字符的前进量设为 char_width + 4 并将偏移量设为 Vector2(5, 2)

请确保 character_ranges 不超过 columns * rows 定义的数量。否则字体将无法导入。

Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray for more details.


int columns = 1 🔗

字体图像中的列数。另见 rows


bool compress = true 🔗

如果为 true,则会对得到的字体使用无损压缩。


int descent = 0 🔗

字体的下深(基线下方的像素数)。如果设为 0 则使用字符高度的一半。


Array fallbacks = [] 🔗

回退字体列表,在这个位图字体中未找到某个字形时使用。优先尝试靠前的字体。


Rect2i image_margin = Rect2i(0, 0, 0, 0) 🔗

整个图像两侧的裁减边距。这可被用于裁减该图像包含属性信息或类似信息的部分。


PackedStringArray kerning_pairs = PackedStringArray() 🔗

字体中的字偶列表。字偶的作用是调整特定的两个字符的间距。

每个字符串都是由空格分隔的三个值:“from”字符串、“to”字符串、整数偏移量。两个字符串中的字符两两组合成字偶,例如 ab cd -3 会创建字偶 acadbcbd,这些字偶的偏移量都是 -3。可以使用转义序列 \uXXXX 添加 Unicode 字符。

Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray for more details.


int rows = 1 🔗

字体图像中的行数。另见 columns


int scaling_mode = 2 🔗

字体缩放模式。