2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2020-01-26 15:01:49 +00:00
<class name= "DynamicFont" inherits= "Font" version= "3.2" >
2017-09-12 20:42:36 +00:00
<brief_description >
2017-10-10 22:08:59 +00:00
DynamicFont renders vector font files at runtime.
2017-09-12 20:42:36 +00:00
</brief_description>
<description >
2020-07-15 08:13:47 +00:00
DynamicFont renders vector font files (such as TTF or OTF) dynamically at runtime instead of using a prerendered texture atlas like [BitmapFont]. This trades the faster loading time of [BitmapFont]s for the ability to change font parameters like size and spacing during runtime. [DynamicFontData] is used for referencing the font file paths. DynamicFont also supports defining one or more fallback fonts, which will be used when displaying a character not supported by the main font.
2019-12-03 08:55:20 +00:00
DynamicFont uses the [url=https://www.freetype.org/]FreeType[/url] library for rasterization.
2019-04-06 10:06:08 +00:00
[codeblock]
var dynamic_font = DynamicFont.new()
dynamic_font.font_data = load("res://BarlowCondensed-Bold.ttf")
dynamic_font.size = 64
$"Label".set("custom_fonts/font", dynamic_font)
[/codeblock]
2020-08-07 13:03:35 +00:00
[b]Note:[/b] DynamicFont doesn't support features such as kerning, right-to-left typesetting, ligatures, text shaping, variable fonts and optional font features yet. If you wish to "bake" an optional font feature into a TTF font file, you can use [url=https://fontforge.org/]FontForge[/url] to do so. In FontForge, use [b]File > Generate Fonts[/b], click [b]Options[/b], choose the desired features then generate the font.
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
</tutorials>
<methods >
<method name= "add_fallback" >
<return type= "void" >
</return>
<argument index= "0" name= "data" type= "DynamicFontData" >
</argument>
<description >
2017-10-10 22:08:59 +00:00
Adds a fallback font.
2017-09-12 20:42:36 +00:00
</description>
</method>
2020-07-18 12:53:37 +00:00
<method name= "get_available_chars" qualifiers= "const" >
<return type= "String" >
</return>
<description >
Returns a string containing all the characters available in the main and all the fallback fonts.
If a given character is included in more than one font, it appears only once in the returned string.
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_fallback" qualifiers= "const" >
<return type= "DynamicFontData" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<description >
2017-10-10 22:08:59 +00:00
Returns the fallback font at index [code]idx[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_fallback_count" qualifiers= "const" >
<return type= "int" >
</return>
<description >
2017-10-10 22:08:59 +00:00
Returns the number of fallback fonts.
2017-09-12 20:42:36 +00:00
</description>
</method>
2019-06-27 14:10:09 +00:00
<method name= "get_spacing" qualifiers= "const" >
<return type= "int" >
</return>
<argument index= "0" name= "type" type= "int" >
</argument>
<description >
2019-12-03 08:55:20 +00:00
Returns the spacing for the given [code]type[/code] (see [enum SpacingType]).
2019-06-27 14:10:09 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "remove_fallback" >
<return type= "void" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<description >
2017-10-10 22:08:59 +00:00
Removes the fallback font at index [code]idx[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_fallback" >
<return type= "void" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<argument index= "1" name= "data" type= "DynamicFontData" >
</argument>
<description >
2017-10-10 22:08:59 +00:00
Sets the fallback font at index [code]idx[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
2019-06-27 14:10:09 +00:00
<method name= "set_spacing" >
<return type= "void" >
</return>
<argument index= "0" name= "type" type= "int" >
</argument>
<argument index= "1" name= "value" type= "int" >
</argument>
<description >
2019-12-03 08:55:20 +00:00
Sets the spacing for [code]type[/code] (see [enum SpacingType]) to [code]value[/code] in pixels (not relative to the font size).
2019-06-27 14:10:09 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
</methods>
<members >
2019-06-29 10:38:01 +00:00
<member name= "extra_spacing_bottom" type= "int" setter= "set_spacing" getter= "get_spacing" default= "0" >
2017-10-10 22:08:59 +00:00
Extra spacing at the bottom in pixels.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "extra_spacing_char" type= "int" setter= "set_spacing" getter= "get_spacing" default= "0" >
2017-10-10 22:08:59 +00:00
Extra character spacing in pixels.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "extra_spacing_space" type= "int" setter= "set_spacing" getter= "get_spacing" default= "0" >
2017-10-10 22:08:59 +00:00
Extra space spacing in pixels.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "extra_spacing_top" type= "int" setter= "set_spacing" getter= "get_spacing" default= "0" >
2017-10-10 22:08:59 +00:00
Extra spacing at the top in pixels.
2017-09-12 20:42:36 +00:00
</member>
2019-07-15 18:42:47 +00:00
<member name= "font_data" type= "DynamicFontData" setter= "set_font_data" getter= "get_font_data" >
2017-10-10 22:08:59 +00:00
The font data.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "outline_color" type= "Color" setter= "set_outline_color" getter= "get_outline_color" default= "Color( 1, 1, 1, 1 )" >
2019-12-03 08:55:20 +00:00
The font outline's color.
[b]Note:[/b] It's recommended to leave this at the default value so that you can adjust it in individual controls. For example, if the outline is made black here, it won't be possible to change its color using a Label's font outline modulate theme item.
2018-05-12 07:38:00 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "outline_size" type= "int" setter= "set_outline_size" getter= "get_outline_size" default= "0" >
2019-12-03 08:55:20 +00:00
The font outline's thickness in pixels (not relative to the font size).
2018-05-12 07:38:00 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "size" type= "int" setter= "set_size" getter= "get_size" default= "16" >
2019-12-03 08:55:20 +00:00
The font size in pixels.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "use_filter" type= "bool" setter= "set_use_filter" getter= "get_use_filter" default= "false" >
2019-12-03 08:55:20 +00:00
If [code]true[/code], filtering is used. This makes the font blurry instead of pixelated when scaling it if font oversampling is disabled or ineffective. It's recommended to enable this when using the font in a control whose size changes over time, unless a pixel art aesthetic is desired.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "use_mipmaps" type= "bool" setter= "set_use_mipmaps" getter= "get_use_mipmaps" default= "false" >
2019-12-03 08:55:20 +00:00
If [code]true[/code], mipmapping is used. This improves the font's appearance when downscaling it if font oversampling is disabled or ineffective.
2017-09-12 20:42:36 +00:00
</member>
</members>
<constants >
2017-11-24 22:16:30 +00:00
<constant name= "SPACING_TOP" value= "0" enum= "SpacingType" >
2017-10-10 22:08:59 +00:00
Spacing at the top.
2017-09-12 20:42:36 +00:00
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "SPACING_BOTTOM" value= "1" enum= "SpacingType" >
2017-10-10 22:08:59 +00:00
Spacing at the bottom.
2017-09-12 20:42:36 +00:00
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "SPACING_CHAR" value= "2" enum= "SpacingType" >
2017-10-10 22:08:59 +00:00
Character spacing.
2017-09-12 20:42:36 +00:00
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "SPACING_SPACE" value= "3" enum= "SpacingType" >
2017-10-10 22:08:59 +00:00
Space spacing.
2017-09-12 20:42:36 +00:00
</constant>
</constants>
</class>