godot/doc/classes/DynamicFont.xml

127 lines
4.7 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8" ?>
2020-02-01 09:03:48 +08:00
<class name="DynamicFont" inherits="Font" version="4.0">
<brief_description>
2017-10-11 06:08:59 +08:00
DynamicFont renders vector font files at runtime.
</brief_description>
<description>
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 fallbacks fonts, which will be used when displaying a character not supported by the main font.
DynamicFont uses the [url=https://www.freetype.org/]FreeType[/url] library for rasterization.
[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]
</description>
<tutorials>
</tutorials>
<methods>
<method name="add_fallback">
<return type="void">
</return>
<argument index="0" name="data" type="DynamicFontData">
</argument>
<description>
2017-10-11 06:08:59 +08:00
Adds a fallback font.
</description>
</method>
<method name="get_fallback" qualifiers="const">
<return type="DynamicFontData">
</return>
<argument index="0" name="idx" type="int">
</argument>
<description>
2017-10-11 06:08:59 +08:00
Returns the fallback font at index [code]idx[/code].
</description>
</method>
<method name="get_fallback_count" qualifiers="const">
<return type="int">
</return>
<description>
2017-10-11 06:08:59 +08:00
Returns the number of fallback fonts.
</description>
</method>
<method name="get_spacing" qualifiers="const">
<return type="int">
</return>
<argument index="0" name="type" type="int">
</argument>
<description>
Returns the spacing for the given [code]type[/code] (see [enum SpacingType]).
</description>
</method>
<method name="remove_fallback">
<return type="void">
</return>
<argument index="0" name="idx" type="int">
</argument>
<description>
2017-10-11 06:08:59 +08:00
Removes the fallback font at index [code]idx[/code].
</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-11 06:08:59 +08:00
Sets the fallback font at index [code]idx[/code].
</description>
</method>
<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>
Sets the spacing for [code]type[/code] (see [enum SpacingType]) to [code]value[/code] in pixels (not relative to the font size).
</description>
</method>
</methods>
<members>
<member name="extra_spacing_bottom" type="int" setter="set_spacing" getter="get_spacing" default="0">
2017-10-11 06:08:59 +08:00
Extra spacing at the bottom in pixels.
</member>
<member name="extra_spacing_char" type="int" setter="set_spacing" getter="get_spacing" default="0">
2017-10-11 06:08:59 +08:00
Extra character spacing in pixels.
</member>
<member name="extra_spacing_space" type="int" setter="set_spacing" getter="get_spacing" default="0">
2017-10-11 06:08:59 +08:00
Extra space spacing in pixels.
</member>
<member name="extra_spacing_top" type="int" setter="set_spacing" getter="get_spacing" default="0">
2017-10-11 06:08:59 +08:00
Extra spacing at the top in pixels.
</member>
2019-07-16 02:42:47 +08:00
<member name="font_data" type="DynamicFontData" setter="set_font_data" getter="get_font_data">
2017-10-11 06:08:59 +08:00
The font data.
</member>
<member name="outline_color" type="Color" setter="set_outline_color" getter="get_outline_color" default="Color( 1, 1, 1, 1 )">
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 15:38:00 +08:00
</member>
<member name="outline_size" type="int" setter="set_outline_size" getter="get_outline_size" default="0">
The font outline's thickness in pixels (not relative to the font size).
2018-05-12 15:38:00 +08:00
</member>
<member name="size" type="int" setter="set_size" getter="get_size" default="16">
The font size in pixels.
</member>
</members>
<constants>
2017-11-25 06:16:30 +08:00
<constant name="SPACING_TOP" value="0" enum="SpacingType">
2017-10-11 06:08:59 +08:00
Spacing at the top.
</constant>
2017-11-25 06:16:30 +08:00
<constant name="SPACING_BOTTOM" value="1" enum="SpacingType">
2017-10-11 06:08:59 +08:00
Spacing at the bottom.
</constant>
2017-11-25 06:16:30 +08:00
<constant name="SPACING_CHAR" value="2" enum="SpacingType">
2017-10-11 06:08:59 +08:00
Character spacing.
</constant>
2017-11-25 06:16:30 +08:00
<constant name="SPACING_SPACE" value="3" enum="SpacingType">
2017-10-11 06:08:59 +08:00
Space spacing.
</constant>
</constants>
</class>