Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
FontFile¶
Inherits: Font < Resource < RefCounted < Object
Holds font source data and prerendered glyph cache, imported from a dynamic or a bitmap font.
Description¶
FontFile contains a set of glyphs to represent Unicode characters imported from a font file, as well as a cache of rasterized glyphs, and a set of fallback Fonts to use.
Use FontVariation to access specific OpenType variation of the font, create simulated bold / slanted version, and draw lines of text.
For more complex text processing, use FontVariation in conjunction with TextLine or TextParagraph.
Supported font formats:
Dynamic font importer: TrueType (.ttf), TrueType collection (.ttc), OpenType (.otf), OpenType collection (.otc), WOFF (.woff), WOFF2 (.woff2), Type 1 (.pfb, .pfm).
Bitmap font importer: AngelCode BMFont (.fnt, .font), text and binary (version 3) format variants.
Monospace image font importer: All supported image formats.
Note: A character is a symbol that represents an item (letter, digit etc.) in an abstract way.
Note: A glyph is a bitmap or a shape used to draw one or more characters in a context-dependent manner. Glyph indices are bound to the specific font data source.
Note: If none of the font data sources contain glyphs for a character used in a string, the character in question will be replaced with a box displaying its hexadecimal code.
var f = load("res://BarlowCondensed-Bold.ttf")
$Label.add_theme_font_override("font", f)
$Label.add_theme_font_size_override("font_size", 64)
var f = ResourceLoader.Load<FontFile>("res://BarlowCondensed-Bold.ttf");
GetNode("Label").AddThemeFontOverride("font", f);
GetNode("Label").AddThemeFontSizeOverride("font_size", 64);
Tutorials¶
Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
BitField<FontStyle> |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods¶
void |
clear_cache ( ) |
void |
clear_glyphs ( int cache_index, Vector2i size ) |
void |
clear_kerning_map ( int cache_index, int size ) |
void |
clear_size_cache ( int cache_index ) |
void |
clear_textures ( int cache_index, Vector2i size ) |
get_cache_ascent ( int cache_index, int size ) const |
|
get_cache_count ( ) const |
|
get_cache_descent ( int cache_index, int size ) const |
|
get_cache_scale ( int cache_index, int size ) const |
|
get_cache_underline_position ( int cache_index, int size ) const |
|
get_cache_underline_thickness ( int cache_index, int size ) const |
|
get_char_from_glyph_index ( int size, int glyph_index ) const |
|
get_embolden ( int cache_index ) const |
|
get_extra_spacing ( int cache_index, SpacingType spacing ) const |
|
get_face_index ( int cache_index ) const |
|
get_glyph_advance ( int cache_index, int size, int glyph ) const |
|
get_glyph_index ( int size, int char, int variation_selector ) const |
|
get_glyph_list ( int cache_index, Vector2i size ) const |
|
get_glyph_offset ( int cache_index, Vector2i size, int glyph ) const |
|
get_glyph_size ( int cache_index, Vector2i size, int glyph ) const |
|
get_glyph_texture_idx ( int cache_index, Vector2i size, int glyph ) const |
|
get_glyph_uv_rect ( int cache_index, Vector2i size, int glyph ) const |
|
get_kerning ( int cache_index, int size, Vector2i glyph_pair ) const |
|
get_kerning_list ( int cache_index, int size ) |