DynamicFont

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

More...
@GodotBaseClass
struct DynamicFont {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

Constants
enum Constants
SpacingType
enum SpacingType

Functions

addFallback
void addFallback(DynamicFontData data)

Adds a fallback font.

getAvailableChars
String getAvailableChars()

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.

getFallback
Ref!DynamicFontData getFallback(long idx)

Returns the fallback font at index idx.

getFallbackCount
long getFallbackCount()

Returns the number of fallback fonts.

getFontData
Ref!DynamicFontData getFontData()
getOutlineColor
Color getOutlineColor()
getOutlineSize
long getOutlineSize()
getSize
long getSize()
getSpacing
long getSpacing(long type)

Returns the spacing for the given type (see spacingtype).

getUseFilter
bool getUseFilter()
getUseMipmaps
bool getUseMipmaps()
opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(DynamicFont other)
opEquals
bool opEquals(typeof(null) n)
removeFallback
void removeFallback(long idx)

Removes the fallback font at index idx.

setFallback
void setFallback(long idx, DynamicFontData data)

Sets the fallback font at index idx.

setFontData
void setFontData(DynamicFontData data)
setOutlineColor
void setOutlineColor(Color color)
setOutlineSize
void setOutlineSize(long size)
setSize
void setSize(long data)
setSpacing
void setSpacing(long type, long value)

Sets the spacing for type (see spacingtype) to value in pixels (not relative to the font size).

setUseFilter
void setUseFilter(bool enable)
setUseMipmaps
void setUseMipmaps(bool enable)
toHash
size_t toHash()

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

extraSpacingBottom
long extraSpacingBottom [@property getter]
long extraSpacingBottom [@property setter]

Extra spacing at the bottom in pixels.

extraSpacingChar
long extraSpacingChar [@property getter]
long extraSpacingChar [@property setter]

Extra spacing for each character in pixels. This can be a negative number to make the distance between characters smaller.

extraSpacingSpace
long extraSpacingSpace [@property getter]
long extraSpacingSpace [@property setter]

Extra spacing for the space character (in addition to extraSpacingChar) in pixels. This can be a negative number to make the distance between words smaller.

extraSpacingTop
long extraSpacingTop [@property getter]
long extraSpacingTop [@property setter]

Extra spacing at the top in pixels.

fontData
DynamicFontData fontData [@property getter]
DynamicFontData fontData [@property setter]

The font data.

outlineColor
Color outlineColor [@property getter]
Color outlineColor [@property setter]

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
long outlineSize [@property getter]
long outlineSize [@property setter]

The font outline's thickness in pixels (not relative to the font size).

size
long size [@property getter]
long size [@property setter]

The font size in pixels.

useFilter
bool useFilter [@property getter]
bool useFilter [@property setter]

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
bool useMipmaps [@property getter]
bool useMipmaps [@property setter]

If true, mipmapping is used. This improves the font's appearance when downscaling it if font oversampling is disabled or ineffective.

Static functions

_new
DynamicFont _new()

Construct a new instance of DynamicFont. Note: use memnew!DynamicFont instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Detailed Description

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)

Note: DynamicFont doesn't support features such as kerning, 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 File > Generate Fonts, click Options, choose the desired features then generate the font.

Meta