Up to date
This page is up to date for Godot 4.0
.
If you still find outdated information, please open an issue.
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);
Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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_embolden ( int cache_index ) 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 ) const |
|
get_language_support_override ( String language ) const |
|
get_language_support_overrides ( ) const |
|
get_script_support_override ( String script ) const |
|
get_script_support_overrides ( ) const |
|
get_size_cache_list ( int cache_index ) const |
|
get_texture_count ( int cache_index, Vector2i size ) const |
|
get_texture_image ( int cache_index, Vector2i size, int texture_index ) const |
|
get_texture_offsets ( int cache_index, Vector2i size, int texture_index ) const |
|
get_transform ( int cache_index ) const |
|
get_variation_coordinates ( int cache_index ) const |
|
load_bitmap_font ( String path ) |
|
load_dynamic_font ( String path ) |
|
void |
remove_cache ( int cache_index ) |
void |
remove_glyph ( int cache_index, Vector2i size, int glyph ) |
void |
remove_kerning ( int cache_index, int size, Vector2i glyph_pair ) |
void |
remove_language_support_override ( String language ) |
void |
remove_script_support_override ( String script ) |
void |
remove_size_cache ( int cache_index, Vector2i size ) |
void |
remove_texture ( int cache_index, Vector2i size, int texture_index ) |
void |
render_glyph ( int cache_index, Vector2i size, int index ) |
void |
render_range ( int cache_index, Vector2i size, int start, int end ) |
void |
set_cache_ascent ( int cache_index, int size, float ascent ) |
void |
set_cache_descent ( int cache_index, int size, float descent ) |
void |
set_cache_scale ( int cache_index, int size, float scale ) |
void |
set_cache_underline_position ( int cache_index, int size, float underline_position ) |
void |
set_cache_underline_thickness ( int cache_index, int size, float underline_thickness ) |
void |
set_embolden ( int cache_index, float strength ) |
void |
set_face_index ( int cache_index, int face_index ) |
void |
set_glyph_advance ( int cache_index, int size, int glyph, Vector2 advance ) |
void |
set_glyph_offset ( int cache_index, Vector2i size, int glyph, Vector2 offset ) |
void |
set_glyph_size ( int cache_index, Vector2i size, int glyph, Vector2 gl_size ) |
void |
set_glyph_texture_idx ( int cache_index, Vector2i size, int glyph, int texture_idx ) |
void |
set_glyph_uv_rect ( int cache_index, Vector2i size, int glyph, Rect2 uv_rect ) |
void |
set_kerning ( int cache_index, int size, Vector2i glyph_pair, Vector2 kerning ) |
void |
set_language_support_override ( String language, bool supported ) |
void |
set_script_support_override ( String script, bool supported ) |
void |
set_texture_image ( int cache_index, Vector2i size, int texture_index, Image image ) |
void |
set_texture_offsets ( int cache_index, Vector2i size, int texture_index, PackedInt32Array offset ) |
void |
set_transform ( int cache_index, Transform2D transform ) |
void |
set_variation_coordinates ( int cache_index, Dictionary variation_coordinates ) |
Property Descriptions¶
bool allow_system_fallback = true
If set to true
, system fonts can be automatically used as fallbacks.
FontAntialiasing antialiasing = 1
void set_antialiasing ( FontAntialiasing value )
FontAntialiasing get_antialiasing ( )
Font anti-aliasing mode.
PackedByteArray data = PackedByteArray()
void set_data ( PackedByteArray value )
PackedByteArray get_data ( )
Contents of the dynamic font source file.
Font[] fallbacks = []
Array of fallback Fonts.
int fixed_size = 0
Font size, used only for the bitmap fonts.
String font_name = ""
Font family name.
int font_stretch = 100
Font stretch amount, compared to a normal width. A percentage value between 50%
and 200%
.
FontStyle font_style = 0
Font style flags, see FontStyle.
int font_weight = 400
Weight (boldness) of the font. A value in the 100...999
range, normal font weight is