Font

Inherits: Resource < Reference < Object

Inherited By: BitmapFont, DynamicFont

Soporte de fuentes y dibujos de texto internacionalizados.

Descripción

Font contains a Unicode-compatible character set, as well as the ability to draw it with variable width, ascent, descent and kerning. For creating fonts from TTF files (or other font formats), see the editor support for fonts.

Note: If a DynamicFont doesn't contain a character used in a string, the character in question will be replaced with codepoint 0xfffd if it's available in the DynamicFont. If this replacement character isn't available in the DynamicFont, the character will be hidden without displaying any replacement character in the string.

Note: If a BitmapFont doesn't contain a character used in a string, the character in question will be hidden without displaying any replacement character in the string.

Note: Unicode characters after 0xffff (such as most emoji) are not supported on Windows. They will display as unknown characters instead. This will be resolved in Godot 4.0.

Métodos

void

draw ( RID canvas_item, Vector2 position, String string, Color modulate=Color( 1, 1, 1, 1 ), int clip_w=-1, Color outline_modulate=Color( 1, 1, 1, 1 ) ) const

float

draw_char ( RID canvas_item, Vector2 position, int char, int next=-1, Color modulate=Color( 1, 1, 1, 1 ), bool outline=false ) const

float

get_ascent ( ) const

Vector2

get_char_size ( int char, int next=0 ) const

float

get_descent ( ) const

float

get_height ( ) const

Vector2

get_string_size ( String string ) const

Vector2

get_wordwrap_string_size ( String string, float width ) const

bool

has_outline ( ) const

bool

is_distance_field_hint ( ) const

void

update_changes ( )

Descripciones de Métodos

  • void draw ( RID canvas_item, Vector2 position, String string, Color modulate=Color( 1, 1, 1, 1 ), int clip_w=-1, Color outline_modulate=Color( 1, 1, 1, 1 ) ) const

Dibuja string en un elemento del lienzo utilizando la fuente en una posición determinada, con modulate color, y opcionalmente recortando el ancho. position especifica la línea de base, no la parte superior. Para dibujar desde la cima, ascent debe añadirse al eje Y.

Véase también CanvasItem.draw_string.


Dibuja el carácter char en un elemento del canvas utilizando la fuente en una posición determinada, con modular color, y opcionalmente kerning si se pasa next. recortando el ancho. position especifica la línea de base, no la parte superior. Para dibujar desde la cima, ascent debe añadirse al eje Y. Se devuelve el ancho utilizado por el carácter, lo que hace que esta función sea útil para dibujar cadenas carácter por carácter.


  • float get_ascent ( ) const

Devuelve el ascenso de la fuente (número de píxeles por encima de la línea de base).


Returns the size of a character, optionally taking kerning into account if the next character is provided. Note that the height returned is the font height (see get_height) and has no relation to the glyph height.


  • float get_descent ( ) const

Devuelve el descenso de la fuente (número de píxeles por debajo de la línea de base).


  • float get_height ( ) const

Devuelve el descenso de la fuente (número de píxeles por debajo de la línea de base).


Returns the size of a string, taking kerning and advance into account. Note that the height returned is the font height (see get_height) and has no relation to the string.


Devuelve el tamaño que tendría la string con la envoltura de palabras habilitada con un width fijo.


  • bool has_outline ( ) const

Devuelve true si la fuente tiene un contorno.


  • bool is_distance_field_hint ( ) const


  • void update_changes ( )

Después de editar una fuente (cambiar el tamaño, el ascenso, los caracteres, etc.). Llame a esta función para propagar los cambios a los controles que puedan utilizarla.