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() 🔗

The character ranges to import from the font image. This is an array that maps each position on the image (in tile coordinates, not pixels). The font atlas is traversed from left to right and top to bottom. Characters can be specified with decimal numbers (126), hexadecimal numbers (0x007e or U+007e), or between single quotes ('~'). Ranges can be specified with a hyphen between characters.

For example, 0-127 represents the full ASCII range. It can also be written as 0x0000-0x007f (or U+0000-U+007f). As another example, ' '-'~' is equivalent to 32-126 and represents the range of printable (visible) ASCII characters.

For any range, the character advance and offset can be customized by appending three space-separated integer values (additional advance, x offset, y offset) to the end. For example 'a'-'b' 4 5 2 sets the advance to char_width + 4 and offset to Vector2(5, 2) for both a and b characters.

Note: The overall number of characters must not exceed the number of columns multiplied by rows. Otherwise, the font will fail to import.

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 🔗

字体缩放模式。