Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

ResourceImporterDynamicFont

Inherits: ResourceImporter < RefCounted < Object

Imports a TTF, TTC, OTF, OTC, WOFF or WOFF2 font file for font rendering that adapts to any size.

Description

Unlike bitmap fonts, dynamic fonts can be resized to any size and still look crisp. Dynamic fonts also optionally support MSDF font rendering, which allows for run-time scale changes with no re-rasterization cost.

While WOFF and especially WOFF2 tend to result in smaller file sizes, there is no universally "better" font format. In most situations, it's recommended to use the font format that was shipped on the font developer's website.

See also ResourceImporterBMFont and ResourceImporterImageFont.

Tutorials

Properties

bool

allow_system_fallback

true

int

antialiasing

1

bool

compress

true

Array

fallbacks

[]

bool

force_autohinter

false

bool

generate_mipmaps

false

int

hinting

1

Dictionary

language_support

{}

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

1


Property Descriptions

bool allow_system_fallback = true

If true, automatically use system fonts as a fallback if a glyph isn't found in this dynamic font. This makes supporting CJK characters or emoji more straightforward, as you don't need to include a CJK/emoji font in your project. See also fallbacks.

Note: The appearance of system fonts varies across platforms. Loading system fonts is only supported on Windows, macOS, Linux, Android and iOS.


int antialiasing = 1

The font antialiasing method to use.

Disabled: Most suited for pixel art fonts, although you do not have to change the antialiasing from the default Grayscale if the font file was well-created and the font is used at an integer multiple of its intended size. If pixel art fonts have a bad appearance at their intended size, try setting subpixel_positioning to Disabled instead.

Grayscale: Use grayscale antialiasing. This is the approach used by the operating system on macOS, Android and iOS.

LCD Subpixel: Use antialiasing with subpixel patterns to make fonts sharper on LCD displays. This is the approach used by the operating system on Windows and most Linux distributions. The downside is that this can introduce "fringing" on edges, especially on display technologies that don't use standard RGB subpixels (such as OLED displays). The LCD subpixel layout is globally controlled by ProjectSettings.gui/theme/lcd_subpixel_layout, which also allows falling back to grayscale antialiasing.


bool compress = true

If true, uses lossless compression for the resulting font.


Array fallbacks = []

List of font fallbacks to use if a glyph isn't found in this dynamic font. Fonts at the beginning of the array are attempted first, but fallback fonts that don't support the glyph's language and script are attempted last (see language_support and script_support). See also allow_system_fallback.


bool force_autohinter = false

If true, forces generation of hinting data for the font using FreeType's autohinter. This will make hinting effective with fonts that don't include hinting data.