ResourceImporterDynamicFont

繼承: ResourceImporter < RefCounted < Object

匯入 TTF、TTC、OTF、OTC、WOFF 或 WOFF2 字型檔案,用於適應任何大小的字形算繪。

說明

與點陣字形不同,動態字形可以調整為任意大小並且看起來仍然清晰。動態字形還可以選擇支援MSDF 字形算繪,這允許運作時比例更改而無需重新光柵化成本。

雖然 WOFF(尤其是 WOFF2)往往會產生較小的檔案大小,但不存在普遍「更好」的字形格式。在大多數情況下,建議使用字形開發人員網站上提供的字形格式。

另請參閱 ResourceImporterBMFontResourceImporterImageFont

教學

屬性

bool

allow_system_fallback

true

int

antialiasing

1

bool

compress

true

bool

disable_embedded_bitmaps

true

Array

fallbacks

[]

bool

force_autohinter

false

bool

generate_mipmaps

false

int

hinting

1

bool

keep_rounding_remainders

true

Dictionary

language_support

{}

bool

modulate_color_glyphs

false

int

msdf_pixel_range

8

int

msdf_size

48

bool

multichannel_signed_distance_field

false

Dictionary

opentype_features

{}

float

oversampling

0.0

Array

preload

[]

Dictionary

script_support

{}

int

subpixel_positioning

4


屬性說明

bool allow_system_fallback = true 🔗

如果true,如果在此動態字形中找不到字形,則自動使用系統字形作為後備。這使得支援CJK 字元或表情符號更加簡單,因為您不需要在專案中包含 CJK/emoji 字形。另請參閱fallbacks

注意: 系統字形的外觀會因平台而異。僅 Windows、macOS、Linux、Android 和 iOS 支援載入系統字形。


int antialiasing = 1 🔗

要使用的字型抗鋸齒方法。

禁用:最適合像素藝術字形,儘管如果字形檔案良好的話,您沒有*更改預設灰度的抗鋸齒效果-建立並且字形以其預期大小的整數倍使用。如果像素藝術字形在其預期大小下外觀不佳,請嘗試將 subpixel_positioning 設定為 Disabled

灰階:使用灰階抗鋸齒。這是 macOS、Android 和 iOS 上的作業系統所使用的方法。

LCD 子像素: 使用子像素模式的抗鋸齒功能使 LCD 顯示器上的字形更加清晰。這是 Windows 和大多數 Linux 發行版上的作業系統所使用的方法。缺點是這可能會在邊緣引入“邊緣”,尤其是在不使用標準 RGB 子像素的顯示技術(例如 OLED 顯示器)上。 LCD 子像素佈局由 ProjectSettings.gui/theme/lcd_subpixel_layout 全域控制,這也允許退回到灰階抗鋸齒。


bool compress = true 🔗

如果為 true,則對二進位資源使用無失真壓縮。


bool disable_embedded_bitmaps = true 🔗

If set to true, embedded font bitmap loading is disabled (bitmap-only and color fonts ignore this property).


Array fallbacks = [] 🔗

如果在此動態字形中找不到字形,則要使用的字形後備列表。首先嘗試陣列開頭的字形,但不支援該字形的後備字形最後嘗試語言和腳本(請參閱language_supportscript_support)。另請參閱allow_system_fallback


bool force_autohinter = false 🔗

如果 true,則使用 FreeType 的自動提示器強制產生字型的提示資料。這將使hinting對不包含提示資料的字形有效。


bool generate_mipmaps = false 🔗

If true, this font will have mipmaps generated. This prevents text from looking grainy when a Control is scaled down, or when a Label3D is viewed from a long distance (if Label3D.texture_filter is set to a mode that displays mipmaps).

Enabling generate_mipmaps increases font generation time and memory usage. Only enable this setting if you actually need it.


int hinting = 1 🔗

要使用的提示模式。這控制在光柵化字形時應如何積極地將字形邊緣捕捉到像素。根據個人喜好,您可能更喜歡使用一種提示模式而不是另一種。除 None 之外的模式僅在字形包含提示資料時才有效(請參閱force_autohinter)。

無:最平滑的外觀,這會使字形在小尺寸下看起來模糊。

Light: 僅將字形邊緣捕捉到 Y 軸上的像素來獲得清晰的結果。

全: 透過將字形邊緣捕捉到 X 軸和 Y 軸上的像素來實作最清晰。


bool keep_rounding_remainders = true 🔗

If set to true, when aligning glyphs to the pixel boundaries rounding remainders are accumulated to ensure more uniform glyph distribution. This setting has no effect if subpixel positioning is enabled.


Dictionary language_support = {} 🔗

覆蓋此字形支援的語言列表。如果留空,則由字形元資料提供。通常不需要更改它。另請參閱 script_support。 ,“,“ “,“錯誤的”,””,”,””


bool modulate_color_glyphs = false 🔗

If set to true, color modulation is applied when drawing colored glyphs, otherwise it's applied to the monochrome glyphs only.


int msdf_pixel_range = 8 🔗

最小和最大可表示的有符號距離之間的形狀周圍的範圍寬度。如果使用字形輪廓,msdf_pixel_range 必須至少設定為最大字形輪廓大小的兩倍msdf_pixel_range 的預設值為 16,允許大小最大到 8 的輪廓看起來正確。


int msdf_size = 48 🔗

用於生成 MSDF 紋理的源字形大小。較高的值允許更高的精度,但算繪速度較慢並且需要更多記憶體。只有當注意到字形算繪中明顯缺乏精度時,才增加該屬性的值。


bool multichannel_signed_distance_field = false 🔗

If set to true, the font will use multichannel signed distance field (MSDF) for crisp rendering at any size. Since this approach does not rely on rasterizing the font every time its size changes, this allows for resizing the font in real-time without any performance penalty. Text will also not look grainy for Controls that are scaled down (or for Label3Ds viewed from a long distance).

MSDF font rendering can be combined with generate_mipmaps to further improve font rendering quality when scaled down.


Dictionary opentype_features = {} 🔗

OpenType 功能可啟用、停用此字型或設定此字型的值。這可用於啟用字型提供的選用功能,例如連字或替代字形。支援的列表OpenType 功能因每種字形而異。


float oversampling = 0.0 🔗

If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See Viewport.oversampling. This value doesn't override the oversampling parameter of draw_* methods.


Array preload = [] 🔗

要預先算繪的字形範圍。這可以避免在遊戲過程中需要算繪新角色時出現卡頓,特別是在啟用subpixel_positioning 的情況下。使用預先載入的缺點是初始專案載入時間會增加,記憶體使用量也會增加。


Dictionary script_support = {} 🔗

覆寫此字形支援的語言腳本列表。如果留空,則由字形元資料提供。通常不需要更改它。另請參閱language_support


int subpixel_positioning = 4 🔗

Subpixel positioning improves font rendering appearance, especially at smaller font sizes. The downside is that it takes more time to initially render the font, which can cause stuttering during gameplay, especially if used with large font sizes. This should be set to Disabled for fonts with a pixel art appearance.

Disabled: No subpixel positioning. Lowest quality, fastest rendering.

Auto: Use subpixel positioning at small font sizes (the chosen quality varies depending on font size). Large fonts will not use subpixel positioning. This is a good tradeoff between performance and quality.

One Half of a Pixel: Always perform intermediate subpixel positioning regardless of font size. High quality, slow rendering.

One Quarter of a Pixel: Always perform precise subpixel positioning regardless of font size. Highest quality, slowest rendering.

Auto (Except Pixel Fonts): Disabled for the pixel style fonts (each glyph contours contain only straight horizontal and vertical lines), Auto for the other fonts.