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 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.
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
Name | Type | Description |
---|---|---|
extraSpacingBottom [get, set]
|
long | Extra spacing at the bottom in pixels. |
extraSpacingChar [get, set]
|
long | Extra character spacing in pixels. |
extraSpacingSpace [get, set]
|
long | Extra space spacing in pixels. |
extraSpacingTop [get, set]
|
long | Extra spacing at the top in pixels. |
fontData [get, set]
|
DynamicFontData | The font data. |
outlineColor [get, set]
|
Color | The 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]
|
long | The font outline's thickness in pixels (not relative to the font size). |
size [get, set]
|
long | The font size in pixels. |
useFilter [get, set]
|
bool | If 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]
|
bool | If true , mipmapping is used. This improves the font's appearance when downscaling it if font oversampling is disabled or ineffective.
|
Methods
Name | Description |
---|---|
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
Name | Description |
---|---|
Constants
|
|
SpacingType
|