DynamicFont

Inherits: Font < Resource < Reference < Object

DynamicFont renderiza archivos de fuentes vectoriales en tiempo de ejecución.

Descripción

DynamicFont renders vector font files 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 FreeType library for rasterization. Supported formats are TrueType (.ttf), OpenType (.otf) and Web Open Font Format 1 (.woff). Web Open Font Format 2 (.woff2) is not supported.

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 FontForge to do so. In FontForge, use File > Generate Fonts, click Options, choose the desired features then generate the font.

Tutoriales

Propiedades

int

extra_spacing_bottom

0

int

extra_spacing_char

0

int

extra_spacing_space

0

int

extra_spacing_top

0

DynamicFontData

font_data

Color

outline_color

Color( 1, 1, 1, 1 )

int

outline_size

0

int

size

16

bool

use_filter

false

bool

use_mipmaps

false

Métodos

void

add_fallback ( DynamicFontData data )

String

get_available_chars ( ) const

DynamicFontData

get_fallback ( int idx ) const

int

get_fallback_count ( ) const

int

get_spacing ( int type ) const

void

remove_fallback ( int idx )

void

set_fallback ( int idx, DynamicFontData data )

void

set_spacing ( int type, int value )

Enumeraciones

enum SpacingType:

  • SPACING_TOP = 0 --- El espacio en la parte superior.

  • SPACING_BOTTOM = 1 --- El espacio en la parte inferior.

  • SPACING_CHAR = 2 --- Spacing for each character.

  • SPACING_SPACE = 3 --- Spacing for the space character.

Descripciones de Propiedades

  • int extra_spacing_bottom

Default

0

Setter

set_spacing(value)

Getter

get_spacing()

Espacio extra en la parte inferior en píxeles.


  • int extra_spacing_char

Default

0

Setter

set_spacing(value)

Getter

get_spacing()

Extra spacing for each character in pixels.

This can be a negative number to make the distance between characters smaller.


  • int extra_spacing_space

Default

0

Setter

set_spacing(value)

Getter

get_spacing()

Extra spacing for the space character (in addition to extra_spacing_char) in pixels.

This can be a negative number to make the distance between words smaller.


  • int extra_spacing_top

Default

0

Setter

set_spacing(value)

Getter

get_spacing()

Espacio extra en la parte superior en píxeles.


Setter

set_font_data(value)

Getter

get_font_data()

Los datos de la fuente.


Default

Color( 1, 1, 1, 1 )

Setter

set_outline_color(value)

Getter

get_outline_color()

El color del contorno de la fuente.

Nota: Se recomienda dejar este valor por defecto para poder ajustarlo en los controles individuales. Por ejemplo, si el contorno se hace negro aquí, no será posible cambiar su color usando un elemento del tema modular el contorno de la fuente de una etiqueta.


  • int outline_size

Default

0

Setter

set_outline_size(value)

Getter

get_outline_size()

El grosor del contorno de la fuente en píxeles (no en relación con el tamaño de la fuente).


Default

16

Setter

set_size(value)

Getter

get_size()

El tamaño de la fuente en píxeles.


Default

false

Setter

set_use_filter(value)

Getter

get_use_filter()

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.


Default

false

Setter

set_use_mipmaps(value)

Getter

get_use_mipmaps()

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

Descripciones de Métodos

Añade una fuente alternativa.


  • String get_available_chars ( ) const

Devuelve una string que contiene todos los caracteres disponibles en la fuente principal y en todas las fuentes secundarias.

Si un carácter determinado se incluye en más de una fuente, aparece sólo una vez en la cadena devuelta.


Devuelve la fuente de reserva en el índice idx.


  • int get_fallback_count ( ) const

Devuelve el número de fuentes de reserva.


  • int get_spacing ( int type ) const

Devuelve el espacio para el type dado (véase SpacingType).


  • void remove_fallback ( int idx )

Elimina la fuente de reserva en el índice idx.


Establece la fuente alternativa en el índice idx.


  • void set_spacing ( int type, int value )

Establece el espacio para type (véase SpacingType) en value en píxeles (no en relación con el tamaño de la fuente).