Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Font configuration and import UI, and Font resources [with font size]. #61473

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/templates/lru.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class LRUCache {
}

_FORCE_INLINE_ size_t get_capacity() const { return capacity; }
_FORCE_INLINE_ size_t get_size() const { return _map.size(); }

void set_capacity(size_t p_capacity) {
if (capacity > 0) {
Expand Down
27 changes: 2 additions & 25 deletions doc/classes/Button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,6 @@
<link title="2D Dodge The Creeps Demo">https://godotengine.org/asset-library/asset/515</link>
<link title="OS Test Demo">https://godotengine.org/asset-library/asset/677</link>
</tutorials>
<methods>
<method name="clear_opentype_features">
<return type="void" />
<description>
Removes all OpenType features.
</description>
</method>
<method name="get_opentype_feature" qualifiers="const">
<return type="int" />
<argument index="0" name="tag" type="String" />
<description>
Returns OpenType feature [code]tag[/code].
</description>
</method>
<method name="set_opentype_feature">
<return type="void" />
<argument index="0" name="tag" type="String" />
<argument index="1" name="value" type="int" />
<description>
Sets OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url].
</description>
</method>
</methods>
<members>
<member name="alignment" type="int" setter="set_text_alignment" getter="get_text_alignment" enum="HorizontalAlignment" default="1">
Text alignment policy for the button's text, use one of the [enum @GlobalScope.HorizontalAlignment] constants.
Expand Down Expand Up @@ -142,8 +119,8 @@
<theme_item name="outline_size" data_type="constant" type="int" default="0">
The size of the text outline.
</theme_item>
<theme_item name="font" data_type="font" type="Font">
[Font] of the [Button]'s text.
<theme_item name="font" data_type="font" type="FontConfig">
[FontConfig] of the [Button]'s text.
</theme_item>
<theme_item name="font_size" data_type="font_size" type="int">
Font size of the [Button]'s text.
Expand Down
84 changes: 64 additions & 20 deletions doc/classes/CanvasItem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,26 @@
</description>
</method>
<method name="draw_char" qualifiers="const">
<return type="float" />
<argument index="0" name="font" type="Font" />
<return type="void" />
<argument index="0" name="font" type="FontConfig" />
<argument index="1" name="pos" type="Vector2" />
<argument index="2" name="char" type="String" />
<argument index="3" name="font_size" type="int" default="16" />
<argument index="4" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<description>
Draws a string first character using a custom font.
</description>
</method>
<method name="draw_char_outline" qualifiers="const">
<return type="void" />
<argument index="0" name="font" type="FontConfig" />
<argument index="1" name="pos" type="Vector2" />
<argument index="2" name="char" type="String" />
<argument index="3" name="next" type="String" default="&quot;&quot;" />
<argument index="4" name="size" type="int" default="16" />
<argument index="3" name="font_size" type="int" default="16" />
<argument index="4" name="size" type="int" default="-1" />
<argument index="5" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<argument index="6" name="outline_size" type="int" default="0" />
<argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
<description>
Draws a string character using a custom font. Returns the advance, depending on the character width and kerning with an optional next character.
Draws a string first character outline using a custom font.
</description>
</method>
<method name="draw_circle">
Expand Down Expand Up @@ -127,7 +136,7 @@
<argument index="4" name="outline" type="float" default="0.0" />
<argument index="5" name="pixel_range" type="float" default="4.0" />
<description>
Draws a textured rectangle region of the multi-channel signed distance field texture at a given position, optionally modulated by a color. See [member FontData.multichannel_signed_distance_field] for more information and caveats about MSDF font rendering.
Draws a textured rectangle region of the multi-channel signed distance field texture at a given position, optionally modulated by a color. See [member Font.multichannel_signed_distance_field] for more information and caveats about MSDF font rendering.
If [code]outline[/code] is positive, each alpha channel value of pixel in region is set to maximum value of true distance in the [code]outline[/code] radius.
Value of the [code]pixel_range[/code] should the same that was used during distance field texture generation.
</description>
Expand All @@ -152,21 +161,39 @@
</method>
<method name="draw_multiline_string" qualifiers="const">
<return type="void" />
<argument index="0" name="font" type="Font" />
<argument index="0" name="font" type="FontConfig" />
<argument index="1" name="pos" type="Vector2" />
<argument index="2" name="text" type="String" />
<argument index="3" name="alignment" type="int" enum="HorizontalAlignment" default="0" />
<argument index="4" name="width" type="float" default="-1" />
<argument index="5" name="max_lines" type="int" default="-1" />
<argument index="6" name="size" type="int" default="16" />
<argument index="5" name="font_size" type="int" default="16" />
<argument index="6" name="max_lines" type="int" default="-1" />
<argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<argument index="8" name="outline_size" type="int" default="0" />
<argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
<argument index="10" name="flags" type="int" default="99" />
<argument index="8" name="flags" type="int" default="99" />
<argument index="9" name="direction" type="int" enum="TextServer.Direction" default="0" />
<argument index="10" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
<description>
Breaks [code]text[/code] to the lines and draws it using the specified [code]font[/code] at the [code]position[/code] (top-left corner). The text will have its color multiplied by [code]modulate[/code]. If [code]clip_w[/code] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
</description>
</method>
<method name="draw_multiline_string_outline" qualifiers="const">
<return type="void" />
<argument index="0" name="font" type="FontConfig" />
<argument index="1" name="pos" type="Vector2" />
<argument index="2" name="text" type="String" />
<argument index="3" name="alignment" type="int" enum="HorizontalAlignment" default="0" />
<argument index="4" name="width" type="float" default="-1" />
<argument index="5" name="font_size" type="int" default="16" />
<argument index="6" name="max_lines" type="int" default="-1" />
<argument index="7" name="size" type="int" default="1" />
<argument index="8" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<argument index="9" name="flags" type="int" default="99" />
<argument index="10" name="direction" type="int" enum="TextServer.Direction" default="0" />
<argument index="11" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
<description>
Breaks [code]text[/code] to the lines and draws text outline using the specified [code]font[/code] at the [code]position[/code] (top-left corner). The text will have its color multiplied by [code]modulate[/code]. If [code]clip_w[/code] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
</description>
</method>
<method name="draw_multimesh">
<return type="void" />
<argument index="0" name="multimesh" type="MultiMesh" />
Expand Down Expand Up @@ -245,16 +272,16 @@
</method>
<method name="draw_string" qualifiers="const">
<return type="void" />
<argument index="0" name="font" type="Font" />
<argument index="0" name="font" type="FontConfig" />
<argument index="1" name="pos" type="Vector2" />
<argument index="2" name="text" type="String" />
<argument index="3" name="alignment" type="int" enum="HorizontalAlignment" default="0" />
<argument index="4" name="width" type="float" default="-1" />
<argument index="5" name="size" type="int" default="16" />
<argument index="5" name="font_size" type="int" default="16" />
<argument index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<argument index="7" name="outline_size" type="int" default="0" />
<argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
<argument index="9" name="flags" type="int" default="3" />
<argument index="7" name="flags" type="int" default="3" />
<argument index="8" name="direction" type="int" enum="TextServer.Direction" default="0" />
<argument index="9" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
<description>
Draws [code]text[/code] using the specified [code]font[/code] at the [code]position[/code] (bottom-left corner using the baseline of the font). The text will have its color multiplied by [code]modulate[/code]. If [code]clip_w[/code] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
[b]Example using the default project font:[/b]
Expand All @@ -276,7 +303,24 @@
DrawString(defaultFont, new Vector2(64, 64), "Hello world", HORIZONTAL_ALIGNMENT_LEFT, -1, defaultFontSize);
[/csharp]
[/codeblocks]
See also [method Font.draw_string].
See also [method FontConfig.draw_string].
</description>
</method>
<method name="draw_string_outline" qualifiers="const">
<return type="void" />
<argument index="0" name="font" type="FontConfig" />
<argument index="1" name="pos" type="Vector2" />
<argument index="2" name="text" type="String" />
<argument index="3" name="alignment" type="int" enum="HorizontalAlignment" default="0" />
<argument index="4" name="width" type="float" default="-1" />
<argument index="5" name="font_size" type="int" default="16" />
<argument index="6" name="size" type="int" default="1" />
<argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<argument index="8" name="flags" type="int" default="3" />
<argument index="9" name="direction" type="int" enum="TextServer.Direction" default="0" />
<argument index="10" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
<description>
Draws [code]text[/code] outline using the specified [code]font[/code] at the [code]position[/code] (bottom-left corner using the baseline of the font). The text will have its color multiplied by [code]modulate[/code]. If [code]clip_w[/code] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
</description>
</method>
<method name="draw_style_box">
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/CheckBox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<theme_item name="outline_size" data_type="constant" type="int" default="0">
The size of the text outline.
</theme_item>
<theme_item name="font" data_type="font" type="Font">
The [Font] to use for the [CheckBox] text.
<theme_item name="font" data_type="font" type="FontConfig">
The [FontConfig] to use for the [CheckBox] text.
</theme_item>
<theme_item name="font_size" data_type="font_size" type="int">
Font size of the [CheckBox]'s text.
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/CheckButton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<theme_item name="outline_size" data_type="constant" type="int" default="0">
The size of the text outline.
</theme_item>
<theme_item name="font" data_type="font" type="Font">
The [Font] to use for the [CheckButton] text.
<theme_item name="font" data_type="font" type="FontConfig">
The [FontConfig] to use for the [CheckButton] text.
</theme_item>
<theme_item name="font_size" data_type="font_size" type="int">
Font size of the [CheckButton]'s text.
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/CodeEdit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,8 @@
<theme_item name="outline_size" data_type="constant" type="int" default="0">
The size of the text outline.
</theme_item>
<theme_item name="font" data_type="font" type="Font">
Sets the default [Font].
<theme_item name="font" data_type="font" type="FontConfig">
Sets the default [FontConfig].
</theme_item>
<theme_item name="font_size" data_type="font_size" type="int">
Sets default font size.
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/ColorPickerButton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
<theme_item name="outline_size" data_type="constant" type="int" default="0">
The size of the text outline.
</theme_item>
<theme_item name="font" data_type="font" type="Font">
[Font] of the [ColorPickerButton]'s text.
<theme_item name="font" data_type="font" type="FontConfig">
[FontConfig] of the [ColorPickerButton]'s text.
</theme_item>
<theme_item name="font_size" data_type="font_size" type="int">
Font size of the [ColorPickerButton]'s text.
Expand Down
14 changes: 7 additions & 7 deletions doc/classes/Control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@
<method name="add_theme_font_override">
<return type="void" />
<argument index="0" name="name" type="StringName" />
<argument index="1" name="font" type="Font" />
<argument index="1" name="font" type="FontConfig" />
<description>
Creates a local override for a theme [Font] with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_font_override].
Creates a local override for a theme [FontConfig] with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_font_override].
See also [method get_theme_font].
</description>
</method>
Expand Down Expand Up @@ -474,7 +474,7 @@
</description>
</method>
<method name="get_theme_default_font" qualifiers="const">
<return type="Font" />
<return type="FontConfig" />
<description>
Returns the default font from the first matching [Theme] in the tree if that [Theme] has a valid [member Theme.default_font] value.
See [method get_theme_color] for details.
Expand All @@ -488,11 +488,11 @@
</description>
</method>
<method name="get_theme_font" qualifiers="const">
<return type="Font" />
<return type="FontConfig" />
<argument index="0" name="name" type="StringName" />
<argument index="1" name="theme_type" type="StringName" default="&quot;&quot;" />
<description>
Returns a [Font] from the first matching [Theme] in the tree if that [Theme] has a font item with the specified [code]name[/code] and [code]theme_type[/code].
Returns a [FontConfig] from the first matching [Theme] in the tree if that [Theme] has a font item with the specified [code]name[/code] and [code]theme_type[/code].
See [method get_theme_color] for details.
</description>
</method>
Expand Down Expand Up @@ -607,7 +607,7 @@
<return type="bool" />
<argument index="0" name="name" type="StringName" />
<description>
Returns [code]true[/code] if there is a local override for a theme [Font] with the specified [code]name[/code] in this [Control] node.
Returns [code]true[/code] if there is a local override for a theme [FontConfig] with the specified [code]name[/code] in this [Control] node.
See [method add_theme_font_override].
</description>
</method>
Expand Down Expand Up @@ -699,7 +699,7 @@
<return type="void" />
<argument index="0" name="name" type="StringName" />
<description>
Removes a local override for a theme [Font] with the specified [code]name[/code] previously added by [method add_theme_font_override] or via the Inspector dock.
Removes a local override for a theme [FontConfig] with the specified [code]name[/code] previously added by [method add_theme_font_override] or via the Inspector dock.
</description>
</method>
<method name="remove_theme_font_size_override">
Expand Down
9 changes: 9 additions & 0 deletions doc/classes/EditorFontPicker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorFontPicker" inherits="EditorResourcePicker" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
</class>
Loading