Holds font source data and prerendered glyph cache, imported from a dynamic or a 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 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)If set to true, embedded font bitmap loading is disabled (bitmap-only and color fonts ignore this property).
Scaling mode, used only for the bitmap fonts with fixed_size greater than zero.
Weight (boldness) of the font. A value in the 100...999 range, normal font weight is 400, bold font weight is 700.
If set to true, auto-hinting is supported and preferred over font built-in hinting. Used by dynamic fonts only (MSDF fonts don't support hinting).
If set to true, when aligning glyphs to the pixel boundaries rounding remainders are accumulated to ensure more uniform glyph distribution. This setting has no effect if subpixel positioning is enabled.
If set to true, color modulation is applied when drawing colored glyphs, otherwise it's applied to the monochrome glyphs only.
The width of the range around the shape between the minimum and maximum representable signed distance. If using font outlines, msdf_pixel_range must be set to at least twice the size of the largest font outline. The default msdf_pixel_range value of 16 allows outline sizes up to 8 to look correct.
Source font size used to generate MSDF textures. Higher values allow for more precision, but are slower to render and require more memory. Only increase this value if you notice a visible lack of precision in glyph rendering.
If set to true, glyphs of all sizes are rendered using single multichannel signed distance field (MSDF) generated from the dynamic font vector data. Since this approach does not rely on rasterizing the font every time its size changes, this allows for resizing the font in real-time without any performance penalty. Text will also not look grainy for Controls that are scaled down (or for Label3Ds viewed from a long distance). As a downside, font hinting is not available with MSDF. The lack of font hinting may result in less crisp and less readable fonts at small sizes.
Note: If using font outlines, msdf_pixel_range must be set to at least twice the size of the largest font outline.
Note: MSDF font rendering does not render glyphs with overlapping shapes correctly. Overlapping shapes are not valid per the OpenType standard, but are still commonly found in many font files, especially those converted by Google Fonts. To avoid issues with overlapping glyphs, consider downloading the font file directly from the type foundry instead of relying on Google Fonts.
If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See Viewport.oversampling. This value doesn't override the [code skip-lint]oversampling[/code] parameter of [code skip-lint]draw_*[/code] methods.
Font glyph subpixel positioning mode. Subpixel positioning provides shaper text and better kerning for smaller font sizes, at the cost of higher memory usage and lower font rasterization speed. Use TextServer.SUBPIXEL_POSITIONING_AUTO to automatically enable it based on the font size.
Removes all rendered glyph information from the cache entry.
Note: This function will not remove textures associated with the glyphs, use remove_texture() to remove them manually.
Removes all textures from font cache entry.
Note: This function will not remove glyphs associated with the texture, use remove_glyph() to remove them manually.
Returns character code associated with glyph_index, or 0 if glyph_index is invalid. See get_glyph_index().
Returns embolden strength, if is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
Returns glyph advance (offset of the next glyph).
Note: Advance for glyphs outlines is the same as the base glyph advance and is not saved.
Returns list of the font sizes in the cache. Each size is Vector2i with font size and outline size.
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 Font.get_supported_variation_list() for more info.
Loads an AngelCode BMFont (.fnt, .font) bitmap font from file path.
Warning: 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 user:// directory.
Loads a TrueType (.ttf), OpenType (.otf), WOFF (.woff), WOFF2 (.woff2) or Type 1 (.pfb, .pfm) dynamic font from file path.
Warning: 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 user:// directory.
Removes specified rendered glyph information from the cache entry.
Note: This function will not remove textures associated with the glyphs, use remove_texture() to remove them manually.
Removes specified texture from the cache entry.
Note: This function will not remove glyphs associated with the texture. Remove them manually using remove_glyph().
Sets embolden strength, if is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
Sets glyph advance (offset of the next glyph).
Note: Advance for glyphs outlines is the same as the base glyph advance and is not saved.
Adds override for Font.is_language_supported().
Adds override for Font.is_script_supported().
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 Font.get_supported_variation_list() for more info.