DynamicFont

Inherits: Font < Resource < Reference < Object

Category: Core

Brief Description

DynamicFont renders vector font files at runtime.

Properties

intextra_spacing_bottom
intextra_spacing_char
intextra_spacing_space
intextra_spacing_top
DynamicFontDatafont_data
Coloroutline_color
intoutline_size
intsize
booluse_filter
booluse_mipmaps

Methods

voidadd_fallback ( DynamicFontData data )
DynamicFontDataget_fallback ( int idx ) const
intget_fallback_count ( ) const
voidremove_fallback ( int idx )
voidset_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.

  1. var dynamic_font = DynamicFont.new()
  2. dynamic_font.font_data = load("res://BarlowCondensed-Bold.ttf")
  3. dynamic_font.size = 64
  4. $"Label".set("custom_fonts/font", dynamic_font)

Property Descriptions

  • int extra_spacing_bottom
Setterset_spacing(value)
Getterget_spacing()

Extra spacing at the bottom in pixels.


  • int extra_spacing_char
Setterset_spacing(value)
Getterget_spacing()

Extra character spacing in pixels.


  • int extra_spacing_space
Setterset_spacing(value)
Getterget_spacing()

Extra space spacing in pixels.


  • int extra_spacing_top
Setterset_spacing(value)
Getterget_spacing()

Extra spacing at the top in pixels.


Setterset_font_data(value)
Getterget_font_data()

The font data.


Setterset_outline_color(value)
Getterget_outline_color()

  • int outline_size
Setterset_outline_size(value)
Getterget_outline_size()

Setterset_size(value)
Getterget_size()

The font size.


Setterset_use_filter(value)
Getterget_use_filter()

If true, filtering is used.


Setterset_use_mipmaps(value)
Getterget_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.