Font source data and prerendered glyph cache, imported from dynamic or bitmap font.
[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 [Font]s 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.
[b]Note:[/b] A character is a symbol that represents an item (letter, digit etc.) in an abstract way.
[b]Note:[/b] A glyph is a bitmap or shape used to draw a one or more characters in a context-dependent manner. Glyph indices are bound to the specific font data source.
[b]Note:[/b] If a 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.
[codeblocks]
[gdscript]
var f = load("res://BarlowCondensed-Bold.ttf")
$"Label".set("custom_fonts/font", f)
$"Label".set("custom_fonts/font_size", 64)
[/gdscript]
[csharp]
var f = ResourceLoader.Load<FontFile>("res://BarlowCondensed-Bold.ttf");
GetNode("Label").Set("custom_fonts/font", f);
GetNode("Label").Set("custom_font_sizes/font_size", 64);
[/csharp]
[/codeblocks]
Removes all font cache entries.
Removes all rendered glyphs information from the cache entry.
[b]Note:[/b] This function will not remove textures associated with the glyphs, use [method remove_texture] to remove them manually.
Removes all kerning overrides.
Removes all font sizes from the cache entry
Removes all textures from font cache entry.
[b]Note:[/b] This function will not remove glyphs associated with the texture, use [method remove_glyph] to remove them manually.
Returns the font ascent (number of pixels above the baseline).
Returns number of the font cache entries.
Returns embolden strength, if is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
Recturns an active face index in the TrueType / OpenType collection.
Returns glyph advance (offset of the next glyph).
[b]Note:[/b] Advance for glyphs outlines is the same as the base glyph advance and is not saved.
Returns the glyph index of a [param char], optionally modified by the [param variation_selector].
Returns list of rendered glyphs in the cache entry.
Returns glyph offset from the baseline.
Returns glyph size.
Returns index of the cache texture containing the glyph.
Returns rectangle in the cache texture containing the glyph.
Returns kerning for the pair of glyphs.
Returns list of the kerning overrides.
Returns [code]true[/code] if support override is enabled for the [param language].
Returns list of language support overrides.
Returns [code]true[/code] if support override is enabled for the [param script].
Returns list of script support overrides.
Returns list of the font sizes in the cache. Each size is [code]Vector2i[/code] with font size and outline size.
Returns number of textures used by font cache entry.
Returns a copy of the font cache texture image.
Returns a copy of the array containing glyph packing data.
Returns 2D transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.
Returns variation coordinates for the specified font cache entry. See [method Font.get_supported_variation_list] for more info.
Loads an AngelCode BMFont (.fnt, .font) bitmap font from file [param path].
[b]Warning:[/b] This method should only be used in the editor or in cases when you need to load external fonts at run-time, such as fonts located at the [code]user://[/code] directory.
Loads a TrueType (.ttf), OpenType (.otf), WOFF (.woff), WOFF2 (.woff2) or Type 1 (.pfb, .pfm) dynamic font from file [param path].
[b]Warning:[/b] This method should only be used in the editor or in cases when you need to load external fonts at run-time, such as fonts located at the [code]user://[/code] directory.
Removes specified font cache entry.
Removes specified rendered glyph information from the cache entry.
[b]Note:[/b] This function will not remove textures associated with the glyphs, use [method remove_texture] to remove them manually.
Removes kerning override for the pair of glyphs.
Remove language support override.
Removes script support override.
Removes specified font size from the cache entry.
Removes specified texture from the cache entry.
[b]Note:[/b] This function will not remove glyphs associated with the texture. Remove them manually using [method remove_glyph].
Renders specified glyph to the font cache texture.
Renders the range of characters to the font cache texture.
Sets embolden strength, if is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
Sets an active face index in the TrueType / OpenType collection.
Sets glyph advance (offset of the next glyph).
[b]Note:[/b] Advance for glyphs outlines is the same as the base glyph advance and is not saved.
Sets glyph offset from the baseline.
Sets glyph size.
Sets index of the cache texture containing the glyph.
Sets rectangle in the cache texture containing the glyph.
Sets kerning for the pair of glyphs.
Adds override for [method Font.is_language_supported].
Adds override for [method Font.is_script_supported].
Sets font cache texture image.
Sets array containing glyph packing data.
Sets 2D transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.
Sets variation coordinates for the specified font cache entry. See [method Font.get_supported_variation_list] for more info.
Font anti-aliasing mode.
Contents of the dynamic font source file.
Array of fallback [Font]s.
Font size, used only for the bitmap fonts.
Font family name.
Font style flags, see [enum TextServer.FontStyle].
If set to [code]true[/code], auto-hinting is supported and preferred over font built-in hinting. Used by dynamic fonts only.
If set to [code]true[/code], generate mipmaps for the font textures.
Font hinting mode. Used by dynamic fonts only.
The width of the range around the shape between the minimum and maximum representable signed distance.
Source font size used to generate MSDF textures.
If set to [code]true[/code], glyphs of all sizes are rendered using single multichannel signed distance field generated from the dynamic font vector data.
Font OpenType feature set override.
Font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only.
Font style name.
Font glyph sub-pixel positioning mode. Subpixel positioning provides shaper text and better kerning for smaller font sizes, at the cost of memory usage and font rasterization speed. Use [constant TextServer.SUBPIXEL_POSITIONING_AUTO] to automatically enable it based on the font size.