DynamicFont renders vector font files at runtime.
DynamicFont renders vector font files (such as TTF or OTF) dynamically at runtime instead of using a prerendered texture atlas like [BitmapFont]. This trades the faster loading time of [BitmapFont]s for the ability to change font parameters like size and spacing during runtime. [DynamicFontData] is used for referencing the font file paths. DynamicFont also supports defining one or more fallbacks fonts, which will be used when displaying a character not supported by the main font.
DynamicFont uses the [url=https://www.freetype.org/]FreeType[/url] library for rasterization.
[codeblock]
var dynamic_font = DynamicFont.new()
dynamic_font.font_data = load("res://BarlowCondensed-Bold.ttf")
dynamic_font.size = 64
$"Label".set("custom_fonts/font", dynamic_font)
[/codeblock]
[b]Note:[/b] DynamicFont doesn't support features such as right-to-left typesetting, ligatures, text shaping, variable fonts and optional font features yet. If you wish to "bake" an optional font feature into a TTF font file, you can use [url=https://fontforge.org/]FontForge[/url] to do so. In FontForge, use [b]File > Generate Fonts[/b], click [b]Options[/b], choose the desired features then generate the font.
Adds a fallback font.
Returns a string containing all the characters available in the main and all the fallback fonts.
If a given character is included in more than one font, it appears only once in the returned string.
Returns the fallback font at index [code]idx[/code].
Returns the number of fallback fonts.
Returns the spacing for the given [code]type[/code] (see [enum SpacingType]).
Removes the fallback font at index [code]idx[/code].
Sets the fallback font at index [code]idx[/code].
Sets the spacing for [code]type[/code] (see [enum SpacingType]) to [code]value[/code] in pixels (not relative to the font size).
Extra spacing at the bottom in pixels.
Extra character spacing in pixels.
Extra space spacing in pixels.
Extra spacing at the top in pixels.
The font data.
The font outline's color.
[b]Note:[/b] It's recommended to leave this at the default value so that you can adjust it in individual controls. For example, if the outline is made black here, it won't be possible to change its color using a Label's font outline modulate theme item.
The font outline's thickness in pixels (not relative to the font size).
The font size in pixels.
If [code]true[/code], filtering is used. This makes the font blurry instead of pixelated when scaling it if font oversampling is disabled or ineffective. It's recommended to enable this when using the font in a control whose size changes over time, unless a pixel art aesthetic is desired.
If [code]true[/code], mipmapping is used. This improves the font's appearance when downscaling it if font oversampling is disabled or ineffective.
Spacing at the top.
Spacing at the bottom.
Character spacing.
Space spacing.