DynamicFont

Inherits: Font < Resource < Reference < Object

Category: Core

Brief Description

DynamicFont renders vector font files at runtime.

Methods

void add_fallback ( DynamicFontData data )
DynamicFontData get_fallback ( int idx ) const
int get_fallback_count ( ) const
void remove_fallback ( int idx )
void set_fallback ( int idx, DynamicFontData data )

Enumerations

enum SpacingType:

  • SPACING_TOP = 0 — Spacing at the top.
  • SPACING_BOTTOM = 1 — Spacing at the bottom.
  • SPACING_CHAR = 2 — Character spacing.
  • SPACING_SPACE = 3 — Space spacing.

Description

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.

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)

Property Descriptions

  • int extra_spacing_bottom
Setter set_spacing(value)
Getter get_spacing()

Extra spacing at the bottom in pixels.


  • int extra_spacing_char
Setter set_spacing(value)
Getter get_spacing()

Extra character spacing in pixels.


  • int extra_spacing_space
Setter set_spacing(value)
Getter get_spacing()

Extra space spacing in pixels.


  • int extra_spacing_top
Setter set_spacing(value)
Getter get_spacing()

Extra spacing at the top in pixels.


Setter set_font_data(value)
Getter get_font_data()

The font data.


Setter set_outline_color(value)
Getter get_outline_color()

  • int outline_size
Setter set_outline_size(value)
Getter get_outline_size()

Setter set_size(value)
Getter get_size()

The font size.


Setter set_use_filter(value)
Getter get_use_filter()

If true, filtering is used.


Setter set_use_mipmaps(value)
Getter get_use_mipmaps()

If true, mipmapping is used.

Method Descriptions

Adds a fallback font.


Returns the fallback font at index idx.


  • int get_fallback_count ( ) const

Returns the number of fallback fonts.


  • void remove_fallback ( int idx )

Removes the fallback font at index idx.


Sets the fallback font at index idx.