Struct DynamicFont

DynamicFont renders vector font files at runtime.

struct DynamicFont ;

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 BitmapFonts 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.

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)

Properties

NameTypeDescription
extraSpacingBottom[get, set] longExtra spacing at the bottom in pixels.
extraSpacingChar[get, set] longExtra character spacing in pixels.
extraSpacingSpace[get, set] longExtra space spacing in pixels.
extraSpacingTop[get, set] longExtra spacing at the top in pixels.
fontData[get, set] DynamicFontDataThe font data.
outlineColor[get, set] ColorThe font outline's color. Note: 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.
outlineSize[get, set] longThe font outline's thickness in pixels (not relative to the font size).
size[get, set] longThe font size in pixels.
useFilter[get, set] boolIf true, 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.
useMipmaps[get, set] boolIf true, mipmapping is used. This improves the font's appearance when downscaling it if font oversampling is disabled or ineffective.

Methods

NameDescription
addFallback Adds a fallback font.
getFallback Returns the fallback font at index idx.
getFallbackCount Returns the number of fallback fonts.
getFontData
getOutlineColor
getOutlineSize
getSize
getSpacing Returns the spacing for the given type (see spacingtype).
getUseFilter
getUseMipmaps
removeFallback Removes the fallback font at index idx.
setFallback Sets the fallback font at index idx.
setFontData
setOutlineColor
setOutlineSize
setSize
setSpacing Sets the spacing for type (see spacingtype) to value in pixels (not relative to the font size).
setUseFilter
setUseMipmaps

Enums

NameDescription
Constants
SpacingType