Merge pull request #54221 from bruvzg/remove_base_size
This commit is contained in:
commit
a29cca65dd
|
@ -53,7 +53,7 @@
|
||||||
<argument index="1" name="pos" type="Vector2" />
|
<argument index="1" name="pos" type="Vector2" />
|
||||||
<argument index="2" name="char" type="String" />
|
<argument index="2" name="char" type="String" />
|
||||||
<argument index="3" name="next" type="String" default="""" />
|
<argument index="3" name="next" type="String" default="""" />
|
||||||
<argument index="4" name="size" type="int" default="-1" />
|
<argument index="4" name="size" type="int" default="16" />
|
||||||
<argument index="5" name="modulate" type="Color" default="Color(1, 1, 1, 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="6" name="outline_size" type="int" default="0" />
|
||||||
<argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
<argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
<argument index="3" name="align" type="int" enum="HAlign" default="0" />
|
<argument index="3" name="align" type="int" enum="HAlign" default="0" />
|
||||||
<argument index="4" name="width" type="float" default="-1" />
|
<argument index="4" name="width" type="float" default="-1" />
|
||||||
<argument index="5" name="max_lines" type="int" default="-1" />
|
<argument index="5" name="max_lines" type="int" default="-1" />
|
||||||
<argument index="6" name="size" type="int" default="-1" />
|
<argument index="6" name="size" type="int" default="16" />
|
||||||
<argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 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="8" name="outline_size" type="int" default="0" />
|
||||||
<argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
<argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
||||||
|
@ -238,7 +238,7 @@
|
||||||
<argument index="2" name="text" type="String" />
|
<argument index="2" name="text" type="String" />
|
||||||
<argument index="3" name="align" type="int" enum="HAlign" default="0" />
|
<argument index="3" name="align" type="int" enum="HAlign" default="0" />
|
||||||
<argument index="4" name="width" type="float" default="-1" />
|
<argument index="4" name="width" type="float" default="-1" />
|
||||||
<argument index="5" name="size" type="int" default="-1" />
|
<argument index="5" name="size" type="int" default="16" />
|
||||||
<argument index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
|
<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="7" name="outline_size" type="int" default="0" />
|
||||||
<argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
<argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
<argument index="1" name="pos" type="Vector2" />
|
<argument index="1" name="pos" type="Vector2" />
|
||||||
<argument index="2" name="char" type="int" />
|
<argument index="2" name="char" type="int" />
|
||||||
<argument index="3" name="next" type="int" default="0" />
|
<argument index="3" name="next" type="int" default="0" />
|
||||||
<argument index="4" name="size" type="int" default="-1" />
|
<argument index="4" name="size" type="int" default="16" />
|
||||||
<argument index="5" name="modulate" type="Color" default="Color(1, 1, 1, 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="6" name="outline_size" type="int" default="0" />
|
||||||
<argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
<argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
||||||
|
@ -99,7 +99,7 @@
|
||||||
<argument index="3" name="align" type="int" enum="HAlign" default="0" />
|
<argument index="3" name="align" type="int" enum="HAlign" default="0" />
|
||||||
<argument index="4" name="width" type="float" default="-1" />
|
<argument index="4" name="width" type="float" default="-1" />
|
||||||
<argument index="5" name="max_lines" type="int" default="-1" />
|
<argument index="5" name="max_lines" type="int" default="-1" />
|
||||||
<argument index="6" name="size" type="int" default="-1" />
|
<argument index="6" name="size" type="int" default="16" />
|
||||||
<argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 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="8" name="outline_size" type="int" default="0" />
|
||||||
<argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
<argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
<argument index="2" name="text" type="String" />
|
<argument index="2" name="text" type="String" />
|
||||||
<argument index="3" name="align" type="int" enum="HAlign" default="0" />
|
<argument index="3" name="align" type="int" enum="HAlign" default="0" />
|
||||||
<argument index="4" name="width" type="float" default="-1" />
|
<argument index="4" name="width" type="float" default="-1" />
|
||||||
<argument index="5" name="size" type="int" default="-1" />
|
<argument index="5" name="size" type="int" default="16" />
|
||||||
<argument index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
|
<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="7" name="outline_size" type="int" default="0" />
|
||||||
<argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
<argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" />
|
||||||
|
@ -128,7 +128,7 @@
|
||||||
</method>
|
</method>
|
||||||
<method name="get_ascent" qualifiers="const">
|
<method name="get_ascent" qualifiers="const">
|
||||||
<return type="float" />
|
<return type="float" />
|
||||||
<argument index="0" name="size" type="int" default="-1" />
|
<argument index="0" name="size" type="int" default="16" />
|
||||||
<description>
|
<description>
|
||||||
Returns the average font ascent (number of pixels above the baseline).
|
Returns the average font ascent (number of pixels above the baseline).
|
||||||
[b]Note:[/b] Real ascent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the ascent of empty line).
|
[b]Note:[/b] Real ascent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the ascent of empty line).
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
<return type="Vector2" />
|
<return type="Vector2" />
|
||||||
<argument index="0" name="char" type="int" />
|
<argument index="0" name="char" type="int" />
|
||||||
<argument index="1" name="next" type="int" default="0" />
|
<argument index="1" name="next" type="int" default="0" />
|
||||||
<argument index="2" name="size" type="int" default="-1" />
|
<argument index="2" name="size" type="int" default="16" />
|
||||||
<description>
|
<description>
|
||||||
Returns the size of a character, optionally taking kerning into account if the next character is provided.
|
Returns the size of a character, optionally taking kerning into account if the next character is provided.
|
||||||
[b]Note:[/b] Do not use this function to calculate width of the string character by character, use [method get_string_size] or [TextLine] instead. The height returned is the font height (see also [method get_height]) and has no relation to the glyph height.
|
[b]Note:[/b] Do not use this function to calculate width of the string character by character, use [method get_string_size] or [TextLine] instead. The height returned is the font height (see also [method get_height]) and has no relation to the glyph height.
|
||||||
|
@ -166,7 +166,7 @@
|
||||||
</method>
|
</method>
|
||||||
<method name="get_descent" qualifiers="const">
|
<method name="get_descent" qualifiers="const">
|
||||||
<return type="float" />
|
<return type="float" />
|
||||||
<argument index="0" name="size" type="int" default="-1" />
|
<argument index="0" name="size" type="int" default="16" />
|
||||||
<description>
|
<description>
|
||||||
Returns the average font descent (number of pixels below the baseline).
|
Returns the average font descent (number of pixels below the baseline).
|
||||||
[b]Note:[/b] Real descent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the descent of empty line).
|
[b]Note:[/b] Real descent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the descent of empty line).
|
||||||
|
@ -174,7 +174,7 @@
|
||||||
</method>
|
</method>
|
||||||
<method name="get_height" qualifiers="const">
|
<method name="get_height" qualifiers="const">
|
||||||
<return type="float" />
|
<return type="float" />
|
||||||
<argument index="0" name="size" type="int" default="-1" />
|
<argument index="0" name="size" type="int" default="16" />
|
||||||
<description>
|
<description>
|
||||||
Returns the total average font height (ascent plus descent) in pixels.
|
Returns the total average font height (ascent plus descent) in pixels.
|
||||||
[b]Note:[/b] Real height of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the height of empty line).
|
[b]Note:[/b] Real height of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the height of empty line).
|
||||||
|
@ -184,7 +184,7 @@
|
||||||
<return type="Vector2" />
|
<return type="Vector2" />
|
||||||
<argument index="0" name="text" type="String" />
|
<argument index="0" name="text" type="String" />
|
||||||
<argument index="1" name="width" type="float" default="-1" />
|
<argument index="1" name="width" type="float" default="-1" />
|
||||||
<argument index="2" name="size" type="int" default="-1" />
|
<argument index="2" name="size" type="int" default="16" />
|
||||||
<argument index="3" name="flags" type="int" default="96" />
|
<argument index="3" name="flags" type="int" default="96" />
|
||||||
<description>
|
<description>
|
||||||
Returns the size of a bounding box of a string broken into the lines, taking kerning and advance into account.
|
Returns the size of a bounding box of a string broken into the lines, taking kerning and advance into account.
|
||||||
|
@ -201,7 +201,7 @@
|
||||||
<method name="get_string_size" qualifiers="const">
|
<method name="get_string_size" qualifiers="const">
|
||||||
<return type="Vector2" />
|
<return type="Vector2" />
|
||||||
<argument index="0" name="text" type="String" />
|
<argument index="0" name="text" type="String" />
|
||||||
<argument index="1" name="size" type="int" default="-1" />
|
<argument index="1" name="size" type="int" default="16" />
|
||||||
<argument index="2" name="align" type="int" enum="HAlign" default="0" />
|
<argument index="2" name="align" type="int" enum="HAlign" default="0" />
|
||||||
<argument index="3" name="width" type="float" default="-1" />
|
<argument index="3" name="width" type="float" default="-1" />
|
||||||
<argument index="4" name="flags" type="int" default="3" />
|
<argument index="4" name="flags" type="int" default="3" />
|
||||||
|
@ -220,7 +220,7 @@
|
||||||
</method>
|
</method>
|
||||||
<method name="get_underline_position" qualifiers="const">
|
<method name="get_underline_position" qualifiers="const">
|
||||||
<return type="float" />
|
<return type="float" />
|
||||||
<argument index="0" name="size" type="int" default="-1" />
|
<argument index="0" name="size" type="int" default="16" />
|
||||||
<description>
|
<description>
|
||||||
Return average pixel offset of the underline below the baseline.
|
Return average pixel offset of the underline below the baseline.
|
||||||
[b]Note:[/b] Real underline position of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate.
|
[b]Note:[/b] Real underline position of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate.
|
||||||
|
@ -228,7 +228,7 @@
|
||||||
</method>
|
</method>
|
||||||
<method name="get_underline_thickness" qualifiers="const">
|
<method name="get_underline_thickness" qualifiers="const">
|
||||||
<return type="float" />
|
<return type="float" />
|
||||||
<argument index="0" name="size" type="int" default="-1" />
|
<argument index="0" name="size" type="int" default="16" />
|
||||||
<description>
|
<description>
|
||||||
Return average thickness of the underline.
|
Return average thickness of the underline.
|
||||||
[b]Note:[/b] Real underline thickness of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate.
|
[b]Note:[/b] Real underline thickness of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate.
|
||||||
|
@ -272,9 +272,6 @@
|
||||||
</method>
|
</method>
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
<member name="base_size" type="int" setter="set_base_size" getter="get_base_size" default="16">
|
|
||||||
Default font size.
|
|
||||||
</member>
|
|
||||||
<member name="spacing_bottom" type="int" setter="set_spacing" getter="get_spacing" default="0">
|
<member name="spacing_bottom" type="int" setter="set_spacing" getter="get_spacing" default="0">
|
||||||
Extra spacing at the bottom of the line in pixels.
|
Extra spacing at the bottom of the line in pixels.
|
||||||
</member>
|
</member>
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
m_name->add_data(FontJapanese); \
|
m_name->add_data(FontJapanese); \
|
||||||
m_name->add_data(FontFallback);
|
m_name->add_data(FontFallback);
|
||||||
|
|
||||||
#define MAKE_DEFAULT_FONT(m_name, m_variations, m_base_size) \
|
#define MAKE_DEFAULT_FONT(m_name, m_variations) \
|
||||||
Ref<Font> m_name; \
|
Ref<Font> m_name; \
|
||||||
m_name.instantiate(); \
|
m_name.instantiate(); \
|
||||||
if (CustomFont.is_valid()) { \
|
if (CustomFont.is_valid()) { \
|
||||||
|
@ -89,12 +89,11 @@
|
||||||
} \
|
} \
|
||||||
m_name->set_variation_coordinates(variations); \
|
m_name->set_variation_coordinates(variations); \
|
||||||
} \
|
} \
|
||||||
m_name->set_base_size(m_base_size); \
|
|
||||||
m_name->set_spacing(TextServer::SPACING_TOP, -EDSCALE); \
|
m_name->set_spacing(TextServer::SPACING_TOP, -EDSCALE); \
|
||||||
m_name->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); \
|
m_name->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); \
|
||||||
MAKE_FALLBACKS(m_name);
|
MAKE_FALLBACKS(m_name);
|
||||||
|
|
||||||
#define MAKE_BOLD_FONT(m_name, m_variations, m_base_size) \
|
#define MAKE_BOLD_FONT(m_name, m_variations) \
|
||||||
Ref<Font> m_name; \
|
Ref<Font> m_name; \
|
||||||
m_name.instantiate(); \
|
m_name.instantiate(); \
|
||||||
if (CustomFontBold.is_valid()) { \
|
if (CustomFontBold.is_valid()) { \
|
||||||
|
@ -116,12 +115,11 @@
|
||||||
} \
|
} \
|
||||||
m_name->set_variation_coordinates(variations); \
|
m_name->set_variation_coordinates(variations); \
|
||||||
} \
|
} \
|
||||||
m_name->set_base_size(m_base_size); \
|
|
||||||
m_name->set_spacing(TextServer::SPACING_TOP, -EDSCALE); \
|
m_name->set_spacing(TextServer::SPACING_TOP, -EDSCALE); \
|
||||||
m_name->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); \
|
m_name->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); \
|
||||||
MAKE_FALLBACKS_BOLD(m_name);
|
MAKE_FALLBACKS_BOLD(m_name);
|
||||||
|
|
||||||
#define MAKE_SOURCE_FONT(m_name, m_variations, m_base_size) \
|
#define MAKE_SOURCE_FONT(m_name, m_variations) \
|
||||||
Ref<Font> m_name; \
|
Ref<Font> m_name; \
|
||||||
m_name.instantiate(); \
|
m_name.instantiate(); \
|
||||||
if (CustomFontSource.is_valid()) { \
|
if (CustomFontSource.is_valid()) { \
|
||||||
|
@ -143,7 +141,6 @@
|
||||||
} \
|
} \
|
||||||
m_name->set_variation_coordinates(variations); \
|
m_name->set_variation_coordinates(variations); \
|
||||||
} \
|
} \
|
||||||
m_name->set_base_size(m_base_size); \
|
|
||||||
m_name->set_spacing(TextServer::SPACING_TOP, -EDSCALE); \
|
m_name->set_spacing(TextServer::SPACING_TOP, -EDSCALE); \
|
||||||
m_name->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); \
|
m_name->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); \
|
||||||
MAKE_FALLBACKS(m_name);
|
MAKE_FALLBACKS(m_name);
|
||||||
|
@ -275,7 +272,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
|
||||||
Ref<FontData> dfmono = load_cached_internal_font(_font_Hack_Regular, _font_Hack_Regular_size, font_hinting, font_antialiased, true);
|
Ref<FontData> dfmono = load_cached_internal_font(_font_Hack_Regular, _font_Hack_Regular_size, font_hinting, font_antialiased, true);
|
||||||
|
|
||||||
// Default font
|
// Default font
|
||||||
MAKE_DEFAULT_FONT(df, String(), default_font_size);
|
MAKE_DEFAULT_FONT(df, String());
|
||||||
p_theme->set_default_theme_font(df); // Default theme font
|
p_theme->set_default_theme_font(df); // Default theme font
|
||||||
p_theme->set_default_theme_font_size(default_font_size);
|
p_theme->set_default_theme_font_size(default_font_size);
|
||||||
|
|
||||||
|
@ -283,7 +280,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
|
||||||
p_theme->set_font("main", "EditorFonts", df);
|
p_theme->set_font("main", "EditorFonts", df);
|
||||||
|
|
||||||
// Bold font
|
// Bold font
|
||||||
MAKE_BOLD_FONT(df_bold, String(), default_font_size);
|
MAKE_BOLD_FONT(df_bold, String());
|
||||||
p_theme->set_font_size("bold_size", "EditorFonts", default_font_size);
|
p_theme->set_font_size("bold_size", "EditorFonts", default_font_size);
|
||||||
p_theme->set_font("bold", "EditorFonts", df_bold);
|
p_theme->set_font("bold", "EditorFonts", df_bold);
|
||||||
|
|
||||||
|
@ -310,7 +307,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
|
||||||
|
|
||||||
// Documentation fonts
|
// Documentation fonts
|
||||||
String code_font_custom_variations = EditorSettings::get_singleton()->get("interface/editor/code_font_custom_variations");
|
String code_font_custom_variations = EditorSettings::get_singleton()->get("interface/editor/code_font_custom_variations");
|
||||||
MAKE_SOURCE_FONT(df_code, code_font_custom_variations, default_font_size);
|
MAKE_SOURCE_FONT(df_code, code_font_custom_variations);
|
||||||
p_theme->set_font_size("doc_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
|
p_theme->set_font_size("doc_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
|
||||||
p_theme->set_font("doc", "EditorFonts", df);
|
p_theme->set_font("doc", "EditorFonts", df);
|
||||||
p_theme->set_font_size("doc_bold_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
|
p_theme->set_font_size("doc_bold_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
|
||||||
|
|
|
@ -884,10 +884,11 @@ public:
|
||||||
flag_rects.push_back(rect2);
|
flag_rects.push_back(rect2);
|
||||||
|
|
||||||
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
|
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
|
||||||
|
int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
|
||||||
Vector2 offset;
|
Vector2 offset;
|
||||||
offset.y = rect2.size.y * 0.75;
|
offset.y = rect2.size.y * 0.75;
|
||||||
|
|
||||||
draw_string(font, rect2.position + offset, itos(layer_index + 1), HALIGN_CENTER, rect2.size.x, -1, on ? text_color_on : text_color);
|
draw_string(font, rect2.position + offset, itos(layer_index + 1), HALIGN_CENTER, rect2.size.x, font_size, on ? text_color_on : text_color);
|
||||||
|
|
||||||
ofs.x += bsize + 1;
|
ofs.x += bsize + 1;
|
||||||
|
|
||||||
|
|
|
@ -3565,7 +3565,7 @@ void CanvasItemEditor::_draw_hover() {
|
||||||
|
|
||||||
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
|
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
|
||||||
int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
|
int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
|
||||||
Size2 node_name_size = font->get_string_size(node_name);
|
Size2 node_name_size = font->get_string_size(node_name, font_size);
|
||||||
Size2 item_size = Size2(node_icon->get_size().x + 4 + node_name_size.x, MAX(node_icon->get_size().y, node_name_size.y - 3));
|
Size2 item_size = Size2(node_icon->get_size().x + 4 + node_name_size.x, MAX(node_icon->get_size().y, node_name_size.y - 3));
|
||||||
|
|
||||||
Point2 pos = transform.xform(hovering_results[i].position) - Point2(0, item_size.y) + (Point2(node_icon->get_size().x, -node_icon->get_size().y) / 4);
|
Point2 pos = transform.xform(hovering_results[i].position) - Point2(0, item_size.y) + (Point2(node_icon->get_size().x, -node_icon->get_size().y) / 4);
|
||||||
|
@ -4777,10 +4777,6 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||||
if (key_pos) {
|
if (key_pos) {
|
||||||
ctrl->set_position(Point2());
|
ctrl->set_position(Point2());
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (key_scale)
|
|
||||||
AnimationPlayerEditor::get_singleton()->get_track_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size());
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ void ThemeEditorPreview::_draw_picker_overlay() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect2 highlight_label_rect = highlight_rect;
|
Rect2 highlight_label_rect = highlight_rect;
|
||||||
highlight_label_rect.size = theme_cache.preview_picker_font->get_string_size(highlight_name);
|
highlight_label_rect.size = theme_cache.preview_picker_font->get_string_size(highlight_name, theme_cache.font_size);
|
||||||
|
|
||||||
int margin_top = theme_cache.preview_picker_label->get_margin(SIDE_TOP);
|
int margin_top = theme_cache.preview_picker_label->get_margin(SIDE_TOP);
|
||||||
int margin_left = theme_cache.preview_picker_label->get_margin(SIDE_LEFT);
|
int margin_left = theme_cache.preview_picker_label->get_margin(SIDE_LEFT);
|
||||||
|
@ -133,7 +133,7 @@ void ThemeEditorPreview::_draw_picker_overlay() {
|
||||||
Point2 label_pos = highlight_label_rect.position;
|
Point2 label_pos = highlight_label_rect.position;
|
||||||
label_pos.y += highlight_label_rect.size.y - margin_bottom;
|
label_pos.y += highlight_label_rect.size.y - margin_bottom;
|
||||||
label_pos.x += margin_left;
|
label_pos.x += margin_left;
|
||||||
picker_overlay->draw_string(theme_cache.preview_picker_font, label_pos, highlight_name);
|
picker_overlay->draw_string(theme_cache.preview_picker_font, label_pos, highlight_name, HALIGN_LEFT, -1, theme_cache.font_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,6 +188,7 @@ void ThemeEditorPreview::_notification(int p_what) {
|
||||||
theme_cache.preview_picker_overlay_color = get_theme_color(SNAME("preview_picker_overlay_color"), SNAME("ThemeEditor"));
|
theme_cache.preview_picker_overlay_color = get_theme_color(SNAME("preview_picker_overlay_color"), SNAME("ThemeEditor"));
|
||||||
theme_cache.preview_picker_label = get_theme_stylebox(SNAME("preview_picker_label"), SNAME("ThemeEditor"));
|
theme_cache.preview_picker_label = get_theme_stylebox(SNAME("preview_picker_label"), SNAME("ThemeEditor"));
|
||||||
theme_cache.preview_picker_font = get_theme_font(SNAME("status_source"), SNAME("EditorFonts"));
|
theme_cache.preview_picker_font = get_theme_font(SNAME("status_source"), SNAME("EditorFonts"));
|
||||||
|
theme_cache.font_size = get_theme_font_size(SNAME("font_size"), SNAME("EditorFonts"));
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_PROCESS: {
|
case NOTIFICATION_PROCESS: {
|
||||||
time_left -= get_process_delta_time();
|
time_left -= get_process_delta_time();
|
||||||
|
|
|
@ -65,6 +65,7 @@ class ThemeEditorPreview : public VBoxContainer {
|
||||||
Color preview_picker_overlay_color;
|
Color preview_picker_overlay_color;
|
||||||
Ref<StyleBox> preview_picker_label;
|
Ref<StyleBox> preview_picker_label;
|
||||||
Ref<Font> preview_picker_font;
|
Ref<Font> preview_picker_font;
|
||||||
|
int font_size = 16;
|
||||||
} theme_cache;
|
} theme_cache;
|
||||||
|
|
||||||
double time_left = 0;
|
double time_left = 0;
|
||||||
|
|
|
@ -987,6 +987,7 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2
|
||||||
p_canvas_item->draw_rect(rect, value);
|
p_canvas_item->draw_rect(rect, value);
|
||||||
} else {
|
} else {
|
||||||
Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
||||||
|
int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
||||||
String text;
|
String text;
|
||||||
switch (value.get_type()) {
|
switch (value.get_type()) {
|
||||||
case Variant::INT:
|
case Variant::INT:
|
||||||
|
@ -1018,8 +1019,8 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 string_size = font->get_string_size(text);
|
Vector2 string_size = font->get_string_size(text, font_size);
|
||||||
p_canvas_item->draw_string(font, p_transform.get_origin() + Vector2i(-string_size.x / 2, string_size.y / 2), text, HALIGN_CENTER, string_size.x, -1, color, 1, Color(0, 0, 0, 1));
|
p_canvas_item->draw_string(font, p_transform.get_origin() + Vector2i(-string_size.x / 2, string_size.y / 2), text, HALIGN_CENTER, string_size.x, font_size, color, 1, Color(0, 0, 0, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1582,6 +1583,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas
|
||||||
|
|
||||||
// Dim terrains with wrong terrain set.
|
// Dim terrains with wrong terrain set.
|
||||||
Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
||||||
|
int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
||||||
for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) {
|
for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) {
|
||||||
Vector2i coords = p_tile_set_atlas_source->get_tile_id(i);
|
Vector2i coords = p_tile_set_atlas_source->get_tile_id(i);
|
||||||
if (coords != hovered_coords) {
|
if (coords != hovered_coords) {
|
||||||
|
@ -1604,8 +1606,8 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas
|
||||||
} else {
|
} else {
|
||||||
text = "-";
|
text = "-";
|
||||||
}
|
}
|
||||||
Vector2 string_size = font->get_string_size(text);
|
Vector2 string_size = font->get_string_size(text, font_size);
|
||||||
p_canvas_item->draw_string(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HALIGN_CENTER, string_size.x, -1, color, 1, Color(0, 0, 0, 1));
|
p_canvas_item->draw_string(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HALIGN_CENTER, string_size.x, font_size, color, 1, Color(0, 0, 0, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1755,6 +1757,7 @@ void TileDataTerrainsEditor::forward_draw_over_alternatives(TileAtlasView *p_til
|
||||||
|
|
||||||
// Dim terrains with wrong terrain set.
|
// Dim terrains with wrong terrain set.
|
||||||
Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
||||||
|
int font_size = TileSetEditor::get_singleton()->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
||||||
for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) {
|
for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) {
|
||||||
Vector2i coords = p_tile_set_atlas_source->get_tile_id(i);
|
Vector2i coords = p_tile_set_atlas_source->get_tile_id(i);
|
||||||
for (int j = 1; j < p_tile_set_atlas_source->get_alternative_tiles_count(coords); j++) {
|
for (int j = 1; j < p_tile_set_atlas_source->get_alternative_tiles_count(coords); j++) {
|
||||||
|
@ -1779,8 +1782,8 @@ void TileDataTerrainsEditor::forward_draw_over_alternatives(TileAtlasView *p_til
|
||||||
} else {
|
} else {
|
||||||
text = "-";
|
text = "-";
|
||||||
}
|
}
|
||||||
Vector2 string_size = font->get_string_size(text);
|
Vector2 string_size = font->get_string_size(text, font_size);
|
||||||
p_canvas_item->draw_string(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HALIGN_CENTER, string_size.x, -1, color, 1, Color(0, 0, 0, 1));
|
p_canvas_item->draw_string(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HALIGN_CENTER, string_size.x, font_size, color, 1, Color(0, 0, 0, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1211,6 +1211,7 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_glyph(FontDataAdvanced *p_font_d
|
||||||
}
|
}
|
||||||
|
|
||||||
_FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced *p_font_data, const Vector2i &p_size) const {
|
_FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced *p_font_data, const Vector2i &p_size) const {
|
||||||
|
ERR_FAIL_COND_V(p_size.x <= 0, false);
|
||||||
if (p_font_data->cache.has(p_size)) {
|
if (p_font_data->cache.has(p_size)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -670,6 +670,7 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_glyph(FontDataFallback *p_font_d
|
||||||
}
|
}
|
||||||
|
|
||||||
_FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontDataFallback *p_font_data, const Vector2i &p_size) const {
|
_FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontDataFallback *p_font_data, const Vector2i &p_size) const {
|
||||||
|
ERR_FAIL_COND_V(p_size.x <= 0, false);
|
||||||
if (p_font_data->cache.has(p_size)) {
|
if (p_font_data->cache.has(p_size)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ void CodeEdit::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const int scroll_width = code_completion_options_count > code_completion_max_lines ? code_completion_scroll_width : 0;
|
const int scroll_width = code_completion_options_count > code_completion_max_lines ? code_completion_scroll_width : 0;
|
||||||
const int code_completion_base_width = font->get_string_size(code_completion_base).width;
|
const int code_completion_base_width = font->get_string_size(code_completion_base, font_size).width;
|
||||||
if (caret_pos.x - code_completion_base_width + code_completion_rect.size.width + scroll_width > get_size().width) {
|
if (caret_pos.x - code_completion_base_width + code_completion_rect.size.width + scroll_width > get_size().width) {
|
||||||
code_completion_rect.position.x = get_size().width - code_completion_rect.size.width - scroll_width;
|
code_completion_rect.position.x = get_size().width - code_completion_rect.size.width - scroll_width;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -400,7 +400,7 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||||
usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
|
usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
|
||||||
}
|
}
|
||||||
|
|
||||||
p_list->push_back(PropertyInfo(Variant::INT, "theme_override_font_sizes/" + E, PROPERTY_HINT_NONE, "", usage));
|
p_list->push_back(PropertyInfo(Variant::INT, "theme_override_font_sizes/" + E, PROPERTY_HINT_RANGE, "1,256,1,or_greater", usage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -985,7 +985,7 @@ Ref<StyleBox> Control::get_theme_stylebox(const StringName &p_name, const String
|
||||||
Ref<Font> Control::get_theme_font(const StringName &p_name, const StringName &p_theme_type) const {
|
Ref<Font> Control::get_theme_font(const StringName &p_name, const StringName &p_theme_type) const {
|
||||||
if (p_theme_type == StringName() || p_theme_type == get_class_name() || p_theme_type == data.theme_type_variation) {
|
if (p_theme_type == StringName() || p_theme_type == get_class_name() || p_theme_type == data.theme_type_variation) {
|
||||||
const Ref<Font> *font = data.font_override.getptr(p_name);
|
const Ref<Font> *font = data.font_override.getptr(p_name);
|
||||||
if (font) {
|
if (font && (*font)->get_data_count() > 0) {
|
||||||
return *font;
|
return *font;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -998,7 +998,7 @@ Ref<Font> Control::get_theme_font(const StringName &p_name, const StringName &p_
|
||||||
int Control::get_theme_font_size(const StringName &p_name, const StringName &p_theme_type) const {
|
int Control::get_theme_font_size(const StringName &p_name, const StringName &p_theme_type) const {
|
||||||
if (p_theme_type == StringName() || p_theme_type == get_class_name() || p_theme_type == data.theme_type_variation) {
|
if (p_theme_type == StringName() || p_theme_type == get_class_name() || p_theme_type == data.theme_type_variation) {
|
||||||
const int *font_size = data.font_size_override.getptr(p_name);
|
const int *font_size = data.font_size_override.getptr(p_name);
|
||||||
if (font_size) {
|
if (font_size && (*font_size) > 0) {
|
||||||
return *font_size;
|
return *font_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2586,16 +2586,6 @@ void Control::warp_mouse(const Point2 &p_to_pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Control::is_text_field() const {
|
bool Control::is_text_field() const {
|
||||||
/*
|
|
||||||
if (get_script_instance()) {
|
|
||||||
Variant v=p_point;
|
|
||||||
const Variant *p[2]={&v,&p_data};
|
|
||||||
Callable::CallError ce;
|
|
||||||
Variant ret = get_script_instance()->call("is_text_field",p,2,ce);
|
|
||||||
if (ce.error==Callable::CallError::CALL_OK)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4037,7 +4037,7 @@ int Tree::get_column_minimum_width(int p_column) const {
|
||||||
|
|
||||||
// Check if the visible title of the column is wider.
|
// Check if the visible title of the column is wider.
|
||||||
if (show_column_titles) {
|
if (show_column_titles) {
|
||||||
min_width = MAX(cache.font->get_string_size(columns[p_column].title).width + cache.bg->get_margin(SIDE_LEFT) + cache.bg->get_margin(SIDE_RIGHT), min_width);
|
min_width = MAX(cache.font->get_string_size(columns[p_column].title, cache.font_size).width + cache.bg->get_margin(SIDE_LEFT) + cache.bg->get_margin(SIDE_RIGHT), min_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!columns[p_column].clip_content) {
|
if (!columns[p_column].clip_content) {
|
||||||
|
|
|
@ -892,9 +892,9 @@ void CanvasItem::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture", "width"), &CanvasItem::draw_primitive, DEFVAL(Ref<Texture2D>()), DEFVAL(1.0));
|
ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture", "width"), &CanvasItem::draw_primitive, DEFVAL(Ref<Texture2D>()), DEFVAL(1.0));
|
||||||
ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture"), &CanvasItem::draw_polygon, DEFVAL(PackedVector2Array()), DEFVAL(Ref<Texture2D>()));
|
ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture"), &CanvasItem::draw_polygon, DEFVAL(PackedVector2Array()), DEFVAL(Ref<Texture2D>()));
|
||||||
ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture"), &CanvasItem::draw_colored_polygon, DEFVAL(PackedVector2Array()), DEFVAL(Ref<Texture2D>()));
|
ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture"), &CanvasItem::draw_colored_polygon, DEFVAL(PackedVector2Array()), DEFVAL(Ref<Texture2D>()));
|
||||||
ClassDB::bind_method(D_METHOD("draw_string", "font", "pos", "text", "align", "width", "size", "modulate", "outline_size", "outline_modulate", "flags"), &CanvasItem::draw_string, DEFVAL(HALIGN_LEFT), DEFVAL(-1), DEFVAL(-1), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND));
|
ClassDB::bind_method(D_METHOD("draw_string", "font", "pos", "text", "align", "width", "size", "modulate", "outline_size", "outline_modulate", "flags"), &CanvasItem::draw_string, DEFVAL(HALIGN_LEFT), DEFVAL(-1), DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND));
|
||||||
ClassDB::bind_method(D_METHOD("draw_multiline_string", "font", "pos", "text", "align", "width", "max_lines", "size", "modulate", "outline_size", "outline_modulate", "flags"), &CanvasItem::draw_multiline_string, DEFVAL(HALIGN_LEFT), DEFVAL(-1), DEFVAL(-1), DEFVAL(-1), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND));
|
ClassDB::bind_method(D_METHOD("draw_multiline_string", "font", "pos", "text", "align", "width", "max_lines", "size", "modulate", "outline_size", "outline_modulate", "flags"), &CanvasItem::draw_multiline_string, DEFVAL(HALIGN_LEFT), DEFVAL(-1), DEFVAL(-1), DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND));
|
||||||
ClassDB::bind_method(D_METHOD("draw_char", "font", "pos", "char", "next", "size", "modulate", "outline_size", "outline_modulate"), &CanvasItem::draw_char, DEFVAL(""), DEFVAL(-1), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)));
|
ClassDB::bind_method(D_METHOD("draw_char", "font", "pos", "char", "next", "size", "modulate", "outline_size", "outline_modulate"), &CanvasItem::draw_char, DEFVAL(""), DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)));
|
||||||
ClassDB::bind_method(D_METHOD("draw_mesh", "mesh", "texture", "transform", "modulate"), &CanvasItem::draw_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1, 1)));
|
ClassDB::bind_method(D_METHOD("draw_mesh", "mesh", "texture", "transform", "modulate"), &CanvasItem::draw_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1, 1)));
|
||||||
ClassDB::bind_method(D_METHOD("draw_multimesh", "multimesh", "texture"), &CanvasItem::draw_multimesh);
|
ClassDB::bind_method(D_METHOD("draw_multimesh", "multimesh", "texture"), &CanvasItem::draw_multimesh);
|
||||||
ClassDB::bind_method(D_METHOD("draw_set_transform", "position", "rotation", "scale"), &CanvasItem::draw_set_transform, DEFVAL(0.0), DEFVAL(Size2(1.0, 1.0)));
|
ClassDB::bind_method(D_METHOD("draw_set_transform", "position", "rotation", "scale"), &CanvasItem::draw_set_transform, DEFVAL(0.0), DEFVAL(Size2(1.0, 1.0)));
|
||||||
|
|
|
@ -34,10 +34,10 @@
|
||||||
#include "scene/main/node.h"
|
#include "scene/main/node.h"
|
||||||
#include "scene/main/scene_tree.h"
|
#include "scene/main/scene_tree.h"
|
||||||
#include "scene/resources/canvas_item_material.h"
|
#include "scene/resources/canvas_item_material.h"
|
||||||
|
#include "scene/resources/font.h"
|
||||||
#include "servers/text_server.h"
|
#include "servers/text_server.h"
|
||||||
|
|
||||||
class CanvasLayer;
|
class CanvasLayer;
|
||||||
class Font;
|
|
||||||
class MultiMesh;
|
class MultiMesh;
|
||||||
class StyleBox;
|
class StyleBox;
|
||||||
class Window;
|
class Window;
|
||||||
|
@ -235,9 +235,9 @@ public:
|
||||||
void draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1));
|
void draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1));
|
||||||
void draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture);
|
void draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture);
|
||||||
|
|
||||||
void draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HAlign p_align = HALIGN_LEFT, real_t p_width = -1, int p_size = -1, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0), uint16_t p_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND) const;
|
void draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HAlign p_align = HALIGN_LEFT, real_t p_width = -1, int p_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0), uint16_t p_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND) const;
|
||||||
void draw_multiline_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HAlign p_align = HALIGN_LEFT, real_t p_width = -1, int p_max_lines = -1, int p_size = -1, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0), uint16_t p_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND) const;
|
void draw_multiline_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HAlign p_align = HALIGN_LEFT, real_t p_width = -1, int p_max_lines = -1, int p_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0), uint16_t p_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND) const;
|
||||||
real_t draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next = "", int p_size = -1, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0)) const;
|
real_t draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next = "", int p_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0)) const;
|
||||||
|
|
||||||
void draw_set_transform(const Point2 &p_offset, real_t p_rot = 0.0, const Size2 &p_scale = Size2(1.0, 1.0));
|
void draw_set_transform(const Point2 &p_offset, real_t p_rot = 0.0, const Size2 &p_scale = Size2(1.0, 1.0));
|
||||||
void draw_set_transform_matrix(const Transform2D &p_matrix);
|
void draw_set_transform_matrix(const Transform2D &p_matrix);
|
||||||
|
|
|
@ -1030,7 +1030,6 @@ void make_default_theme(bool p_hidpi, Ref<Font> p_font) {
|
||||||
dynamic_font_data.instantiate();
|
dynamic_font_data.instantiate();
|
||||||
dynamic_font_data->set_data_ptr(_font_OpenSans_SemiBold, _font_OpenSans_SemiBold_size);
|
dynamic_font_data->set_data_ptr(_font_OpenSans_SemiBold, _font_OpenSans_SemiBold_size);
|
||||||
dynamic_font->add_data(dynamic_font_data);
|
dynamic_font->add_data(dynamic_font_data);
|
||||||
dynamic_font->set_base_size(default_font_size);
|
|
||||||
|
|
||||||
default_font = dynamic_font;
|
default_font = dynamic_font;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1072,10 +1072,6 @@ void Font::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("clear_data"), &Font::clear_data);
|
ClassDB::bind_method(D_METHOD("clear_data"), &Font::clear_data);
|
||||||
ClassDB::bind_method(D_METHOD("remove_data", "idx"), &Font::remove_data);
|
ClassDB::bind_method(D_METHOD("remove_data", "idx"), &Font::remove_data);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_base_size", "size"), &Font::set_base_size);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_base_size"), &Font::get_base_size);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "base_size"), "set_base_size", "get_base_size");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_variation_coordinates", "variation_coordinates"), &Font::set_variation_coordinates);
|
ClassDB::bind_method(D_METHOD("set_variation_coordinates", "variation_coordinates"), &Font::set_variation_coordinates);
|
||||||
ClassDB::bind_method(D_METHOD("get_variation_coordinates"), &Font::get_variation_coordinates);
|
ClassDB::bind_method(D_METHOD("get_variation_coordinates"), &Font::get_variation_coordinates);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "variation_coordinates"), "set_variation_coordinates", "get_variation_coordinates");
|
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "variation_coordinates"), "set_variation_coordinates", "get_variation_coordinates");
|
||||||
|
@ -1087,20 +1083,20 @@ void Font::_bind_methods() {
|
||||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "spacing_top"), "set_spacing", "get_spacing", TextServer::SPACING_TOP);
|
ADD_PROPERTYI(PropertyInfo(Variant::INT, "spacing_top"), "set_spacing", "get_spacing", TextServer::SPACING_TOP);
|
||||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "spacing_bottom"), "set_spacing", "get_spacing", TextServer::SPACING_BOTTOM);
|
ADD_PROPERTYI(PropertyInfo(Variant::INT, "spacing_bottom"), "set_spacing", "get_spacing", TextServer::SPACING_BOTTOM);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_height", "size"), &Font::get_height, DEFVAL(-1));
|
ClassDB::bind_method(D_METHOD("get_height", "size"), &Font::get_height, DEFVAL(DEFAULT_FONT_SIZE));
|
||||||
ClassDB::bind_method(D_METHOD("get_ascent", "size"), &Font::get_ascent, DEFVAL(-1));
|
ClassDB::bind_method(D_METHOD("get_ascent", "size"), &Font::get_ascent, DEFVAL(DEFAULT_FONT_SIZE));
|
||||||
ClassDB::bind_method(D_METHOD("get_descent", "size"), &Font::get_descent, DEFVAL(-1));
|
ClassDB::bind_method(D_METHOD("get_descent", "size"), &Font::get_descent, DEFVAL(DEFAULT_FONT_SIZE));
|
||||||
ClassDB::bind_method(D_METHOD("get_underline_position", "size"), &Font::get_underline_position, DEFVAL(-1));
|
ClassDB::bind_method(D_METHOD("get_underline_position", "size"), &Font::get_underline_position, DEFVAL(DEFAULT_FONT_SIZE));
|
||||||
ClassDB::bind_method(D_METHOD("get_underline_thickness", "size"), &Font::get_underline_thickness, DEFVAL(-1));
|
ClassDB::bind_method(D_METHOD("get_underline_thickness", "size"), &Font::get_underline_thickness, DEFVAL(DEFAULT_FONT_SIZE));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_string_size", "text", "size", "align", "width", "flags"), &Font::get_string_size, DEFVAL(-1), DEFVAL(HALIGN_LEFT), DEFVAL(-1), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND));
|
ClassDB::bind_method(D_METHOD("get_string_size", "text", "size", "align", "width", "flags"), &Font::get_string_size, DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(HALIGN_LEFT), DEFVAL(-1), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND));
|
||||||
ClassDB::bind_method(D_METHOD("get_multiline_string_size", "text", "width", "size", "flags"), &Font::get_multiline_string_size, DEFVAL(-1), DEFVAL(-1), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND));
|
ClassDB::bind_method(D_METHOD("get_multiline_string_size", "text", "width", "size", "flags"), &Font::get_multiline_string_size, DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("draw_string", "canvas_item", "pos", "text", "align", "width", "size", "modulate", "outline_size", "outline_modulate", "flags"), &Font::draw_string, DEFVAL(HALIGN_LEFT), DEFVAL(-1), DEFVAL(-1), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND));
|
ClassDB::bind_method(D_METHOD("draw_string", "canvas_item", "pos", "text", "align", "width", "size", "modulate", "outline_size", "outline_modulate", "flags"), &Font::draw_string, DEFVAL(HALIGN_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND));
|
||||||
ClassDB::bind_method(D_METHOD("draw_multiline_string", "canvas_item", "pos", "text", "align", "width", "max_lines", "size", "modulate", "outline_size", "outline_modulate", "flags"), &Font::draw_multiline_string, DEFVAL(HALIGN_LEFT), DEFVAL(-1), DEFVAL(-1), DEFVAL(-1), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND));
|
ClassDB::bind_method(D_METHOD("draw_multiline_string", "canvas_item", "pos", "text", "align", "width", "max_lines", "size", "modulate", "outline_size", "outline_modulate", "flags"), &Font::draw_multiline_string, DEFVAL(HALIGN_LEFT), DEFVAL(-1), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_char_size", "char", "next", "size"), &Font::get_char_size, DEFVAL(0), DEFVAL(-1));
|
ClassDB::bind_method(D_METHOD("get_char_size", "char", "next", "size"), &Font::get_char_size, DEFVAL(0), DEFVAL(DEFAULT_FONT_SIZE));
|
||||||
ClassDB::bind_method(D_METHOD("draw_char", "canvas_item", "pos", "char", "next", "size", "modulate", "outline_size", "outline_modulate"), &Font::draw_char, DEFVAL(0), DEFVAL(-1), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)));
|
ClassDB::bind_method(D_METHOD("draw_char", "canvas_item", "pos", "char", "next", "size", "modulate", "outline_size", "outline_modulate"), &Font::draw_char, DEFVAL(0), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(1, 1, 1, 0)));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("has_char", "char"), &Font::has_char);
|
ClassDB::bind_method(D_METHOD("has_char", "char"), &Font::has_char);
|
||||||
ClassDB::bind_method(D_METHOD("get_supported_chars"), &Font::get_supported_chars);
|
ClassDB::bind_method(D_METHOD("get_supported_chars"), &Font::get_supported_chars);
|
||||||
|
@ -1195,7 +1191,6 @@ void Font::reset_state() {
|
||||||
data.clear();
|
data.clear();
|
||||||
rids.clear();
|
rids.clear();
|
||||||
|
|
||||||
base_size = 16;
|
|
||||||
variation_coordinates.clear();
|
variation_coordinates.clear();
|
||||||
spacing_bottom = 0;
|
spacing_bottom = 0;
|
||||||
spacing_top = 0;
|
spacing_top = 0;
|
||||||
|
@ -1308,14 +1303,6 @@ void Font::remove_data(int p_idx) {
|
||||||
notify_property_list_changed();
|
notify_property_list_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::set_base_size(int p_size) {
|
|
||||||
base_size = p_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Font::get_base_size() const {
|
|
||||||
return base_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Font::set_variation_coordinates(const Dictionary &p_variation_coordinates) {
|
void Font::set_variation_coordinates(const Dictionary &p_variation_coordinates) {
|
||||||
_data_changed();
|
_data_changed();
|
||||||
variation_coordinates = p_variation_coordinates;
|
variation_coordinates = p_variation_coordinates;
|
||||||
|
@ -1355,51 +1342,46 @@ int Font::get_spacing(TextServer::SpacingType p_spacing) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t Font::get_height(int p_size) const {
|
real_t Font::get_height(int p_size) const {
|
||||||
int size = (p_size <= 0) ? base_size : p_size;
|
|
||||||
real_t ret = 0.f;
|
real_t ret = 0.f;
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
_ensure_rid(i);
|
_ensure_rid(i);
|
||||||
ret = MAX(ret, TS->font_get_ascent(rids[i], size) + TS->font_get_descent(rids[i], size));
|
ret = MAX(ret, TS->font_get_ascent(rids[i], p_size) + TS->font_get_descent(rids[i], p_size));
|
||||||
}
|
}
|
||||||
return ret + spacing_bottom + spacing_top;
|
return ret + spacing_bottom + spacing_top;
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t Font::get_ascent(int p_size) const {
|
real_t Font::get_ascent(int p_size) const {
|
||||||
int size = (p_size <= 0) ? base_size : p_size;
|
|
||||||
real_t ret = 0.f;
|
real_t ret = 0.f;
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
_ensure_rid(i);
|
_ensure_rid(i);
|
||||||
ret = MAX(ret, TS->font_get_ascent(rids[i], size));
|
ret = MAX(ret, TS->font_get_ascent(rids[i], p_size));
|
||||||
}
|
}
|
||||||
return ret + spacing_top;
|
return ret + spacing_top;
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t Font::get_descent(int p_size) const {
|
real_t Font::get_descent(int p_size) const {
|
||||||
int size = (p_size <= 0) ? base_size : p_size;
|
|
||||||
real_t ret = 0.f;
|
real_t ret = 0.f;
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
_ensure_rid(i);
|
_ensure_rid(i);
|
||||||
ret = MAX(ret, TS->font_get_descent(rids[i], size));
|
ret = MAX(ret, TS->font_get_descent(rids[i], p_size));
|
||||||
}
|
}
|
||||||
return ret + spacing_bottom;
|
return ret + spacing_bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t Font::get_underline_position(int p_size) const {
|
real_t Font::get_underline_position(int p_size) const {
|
||||||
int size = (p_size <= 0) ? base_size : p_size;
|
|
||||||
real_t ret = 0.f;
|
real_t ret = 0.f;
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
_ensure_rid(i);
|
_ensure_rid(i);
|
||||||
ret = MAX(ret, TS->font_get_underline_position(rids[i], size));
|
ret = MAX(ret, TS->font_get_underline_position(rids[i], p_size));
|
||||||
}
|
}
|
||||||
return ret + spacing_top;
|
return ret + spacing_top;
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t Font::get_underline_thickness(int p_size) const {
|
real_t Font::get_underline_thickness(int p_size) const {
|
||||||
int size = (p_size <= 0) ? base_size : p_size;
|
|
||||||
real_t ret = 0.f;
|
real_t ret = 0.f;
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
_ensure_rid(i);
|
_ensure_rid(i);
|
||||||
ret = MAX(ret, TS->font_get_underline_thickness(rids[i], size));
|
ret = MAX(ret, TS->font_get_underline_thickness(rids[i], p_size));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1407,8 +1389,6 @@ real_t Font::get_underline_thickness(int p_size) const {
|
||||||
Size2 Font::get_string_size(const String &p_text, int p_size, HAlign p_align, real_t p_width, uint16_t p_flags) const {
|
Size2 Font::get_string_size(const String &p_text, int p_size, HAlign p_align, real_t p_width, uint16_t p_flags) const {
|
||||||
ERR_FAIL_COND_V(data.is_empty(), Size2());
|
ERR_FAIL_COND_V(data.is_empty(), Size2());
|
||||||
|
|
||||||
int size = (p_size <= 0) ? base_size : p_size;
|
|
||||||
|
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
_ensure_rid(i);
|
_ensure_rid(i);
|
||||||
}
|
}
|
||||||
|
@ -1418,14 +1398,14 @@ Size2 Font::get_string_size(const String &p_text, int p_size, HAlign p_align, re
|
||||||
hash = hash_djb2_one_64(hash_djb2_one_float(p_width), hash);
|
hash = hash_djb2_one_64(hash_djb2_one_float(p_width), hash);
|
||||||
hash = hash_djb2_one_64(p_flags, hash);
|
hash = hash_djb2_one_64(p_flags, hash);
|
||||||
}
|
}
|
||||||
hash = hash_djb2_one_64(size, hash);
|
hash = hash_djb2_one_64(p_size, hash);
|
||||||
|
|
||||||
Ref<TextLine> buffer;
|
Ref<TextLine> buffer;
|
||||||
if (cache.has(hash)) {
|
if (cache.has(hash)) {
|
||||||
buffer = cache.get(hash);
|
buffer = cache.get(hash);
|
||||||
} else {
|
} else {
|
||||||
buffer.instantiate();
|
buffer.instantiate();
|
||||||
buffer->add_string(p_text, Ref<Font>(this), size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
|
buffer->add_string(p_text, Ref<Font>(this), p_size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
|
||||||
cache.insert(hash, buffer);
|
cache.insert(hash, buffer);
|
||||||
}
|
}
|
||||||
return buffer->get_size();
|
return buffer->get_size();
|
||||||
|
@ -1434,8 +1414,6 @@ Size2 Font::get_string_size(const String &p_text, int p_size, HAlign p_align, re
|
||||||
Size2 Font::get_multiline_string_size(const String &p_text, real_t p_width, int p_size, uint16_t p_flags) const {
|
Size2 Font::get_multiline_string_size(const String &p_text, real_t p_width, int p_size, uint16_t p_flags) const {
|
||||||
ERR_FAIL_COND_V(data.is_empty(), Size2());
|
ERR_FAIL_COND_V(data.is_empty(), Size2());
|
||||||
|
|
||||||
int size = (p_size <= 0) ? base_size : p_size;
|
|
||||||
|
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
_ensure_rid(i);
|
_ensure_rid(i);
|
||||||
}
|
}
|
||||||
|
@ -1443,14 +1421,14 @@ Size2 Font::get_multiline_string_size(const String &p_text, real_t p_width, int
|
||||||
uint64_t hash = p_text.hash64();
|
uint64_t hash = p_text.hash64();
|
||||||
uint64_t wrp_hash = hash_djb2_one_64(hash_djb2_one_float(p_width), hash);
|
uint64_t wrp_hash = hash_djb2_one_64(hash_djb2_one_float(p_width), hash);
|
||||||
wrp_hash = hash_djb2_one_64(p_flags, wrp_hash);
|
wrp_hash = hash_djb2_one_64(p_flags, wrp_hash);
|
||||||
wrp_hash = hash_djb2_one_64(size, wrp_hash);
|
wrp_hash = hash_djb2_one_64(p_size, wrp_hash);
|
||||||
|
|
||||||
Ref<TextParagraph> lines_buffer;
|
Ref<TextParagraph> lines_buffer;
|
||||||
if (cache_wrap.has(wrp_hash)) {
|
if (cache_wrap.has(wrp_hash)) {
|
||||||
lines_buffer = cache_wrap.get(wrp_hash);
|
lines_buffer = cache_wrap.get(wrp_hash);
|
||||||
} else {
|
} else {
|
||||||
lines_buffer.instantiate();
|
lines_buffer.instantiate();
|
||||||
lines_buffer->add_string(p_text, Ref<Font>(this), size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
|
lines_buffer->add_string(p_text, Ref<Font>(this), p_size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
|
||||||
lines_buffer->set_width(p_width);
|
lines_buffer->set_width(p_width);
|
||||||
lines_buffer->set_flags(p_flags);
|
lines_buffer->set_flags(p_flags);
|
||||||
cache_wrap.insert(wrp_hash, lines_buffer);
|
cache_wrap.insert(wrp_hash, lines_buffer);
|
||||||
|
@ -1473,8 +1451,6 @@ Size2 Font::get_multiline_string_size(const String &p_text, real_t p_width, int
|
||||||
void Font::draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HAlign p_align, real_t p_width, int p_size, const Color &p_modulate, int p_outline_size, const Color &p_outline_modulate, uint16_t p_flags) const {
|
void Font::draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HAlign p_align, real_t p_width, int p_size, const Color &p_modulate, int p_outline_size, const Color &p_outline_modulate, uint16_t p_flags) const {
|
||||||
ERR_FAIL_COND(data.is_empty());
|
ERR_FAIL_COND(data.is_empty());
|
||||||
|
|
||||||
int size = (p_size <= 0) ? base_size : p_size;
|
|
||||||
|
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
_ensure_rid(i);
|
_ensure_rid(i);
|
||||||
}
|
}
|
||||||
|
@ -1484,14 +1460,14 @@ void Font::draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_t
|
||||||
hash = hash_djb2_one_64(hash_djb2_one_float(p_width), hash);
|
hash = hash_djb2_one_64(hash_djb2_one_float(p_width), hash);
|
||||||
hash = hash_djb2_one_64(p_flags, hash);
|
hash = hash_djb2_one_64(p_flags, hash);
|
||||||
}
|
}
|
||||||
hash = hash_djb2_one_64(size, hash);
|
hash = hash_djb2_one_64(p_size, hash);
|
||||||
|
|
||||||
Ref<TextLine> buffer;
|
Ref<TextLine> buffer;
|
||||||
if (cache.has(hash)) {
|
if (cache.has(hash)) {
|
||||||
buffer = cache.get(hash);
|
buffer = cache.get(hash);
|
||||||
} else {
|
} else {
|
||||||
buffer.instantiate();
|
buffer.instantiate();
|
||||||
buffer->add_string(p_text, Ref<Font>(this), size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
|
buffer->add_string(p_text, Ref<Font>(this), p_size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
|
||||||
cache.insert(hash, buffer);
|
cache.insert(hash, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1515,8 +1491,6 @@ void Font::draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_t
|
||||||
void Font::draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HAlign p_align, float p_width, int p_max_lines, int p_size, const Color &p_modulate, int p_outline_size, const Color &p_outline_modulate, uint16_t p_flags) const {
|
void Font::draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HAlign p_align, float p_width, int p_max_lines, int p_size, const Color &p_modulate, int p_outline_size, const Color &p_outline_modulate, uint16_t p_flags) const {
|
||||||
ERR_FAIL_COND(data.is_empty());
|
ERR_FAIL_COND(data.is_empty());
|
||||||
|
|
||||||
int size = (p_size <= 0) ? base_size : p_size;
|
|
||||||
|
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
_ensure_rid(i);
|
_ensure_rid(i);
|
||||||
}
|
}
|
||||||
|
@ -1524,14 +1498,14 @@ void Font::draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const S
|
||||||
uint64_t hash = p_text.hash64();
|
uint64_t hash = p_text.hash64();
|
||||||
uint64_t wrp_hash = hash_djb2_one_64(hash_djb2_one_float(p_width), hash);
|
uint64_t wrp_hash = hash_djb2_one_64(hash_djb2_one_float(p_width), hash);
|
||||||
wrp_hash = hash_djb2_one_64(p_flags, wrp_hash);
|
wrp_hash = hash_djb2_one_64(p_flags, wrp_hash);
|
||||||
wrp_hash = hash_djb2_one_64(size, wrp_hash);
|
wrp_hash = hash_djb2_one_64(p_size, wrp_hash);
|
||||||
|
|
||||||
Ref<TextParagraph> lines_buffer;
|
Ref<TextParagraph> lines_buffer;
|
||||||
if (cache_wrap.has(wrp_hash)) {
|
if (cache_wrap.has(wrp_hash)) {
|
||||||
lines_buffer = cache_wrap.get(wrp_hash);
|
lines_buffer = cache_wrap.get(wrp_hash);
|
||||||
} else {
|
} else {
|
||||||
lines_buffer.instantiate();
|
lines_buffer.instantiate();
|
||||||
lines_buffer->add_string(p_text, Ref<Font>(this), size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
|
lines_buffer->add_string(p_text, Ref<Font>(this), p_size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
|
||||||
lines_buffer->set_width(p_width);
|
lines_buffer->set_width(p_width);
|
||||||
lines_buffer->set_flags(p_flags);
|
lines_buffer->set_flags(p_flags);
|
||||||
cache_wrap.insert(wrp_hash, lines_buffer);
|
cache_wrap.insert(wrp_hash, lines_buffer);
|
||||||
|
@ -1573,16 +1547,14 @@ void Font::draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const S
|
||||||
}
|
}
|
||||||
|
|
||||||
Size2 Font::get_char_size(char32_t p_char, char32_t p_next, int p_size) const {
|
Size2 Font::get_char_size(char32_t p_char, char32_t p_next, int p_size) const {
|
||||||
int size = (p_size <= 0) ? base_size : p_size;
|
|
||||||
|
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
_ensure_rid(i);
|
_ensure_rid(i);
|
||||||
if (data[i]->has_char(p_char)) {
|
if (data[i]->has_char(p_char)) {
|
||||||
int32_t glyph_a = TS->font_get_glyph_index(rids[i], size, p_char, 0);
|
int32_t glyph_a = TS->font_get_glyph_index(rids[i], p_size, p_char, 0);
|
||||||
Size2 ret = Size2(TS->font_get_glyph_advance(rids[i], size, glyph_a).x, TS->font_get_ascent(rids[i], size) + TS->font_get_descent(rids[i], size));
|
Size2 ret = Size2(TS->font_get_glyph_advance(rids[i], p_size, glyph_a).x, TS->font_get_ascent(rids[i], p_size) + TS->font_get_descent(rids[i], p_size));
|
||||||
if ((p_next != 0) && data[i]->has_char(p_next)) {
|
if ((p_next != 0) && data[i]->has_char(p_next)) {
|
||||||
int32_t glyph_b = TS->font_get_glyph_index(rids[i], size, p_next, 0);
|
int32_t glyph_b = TS->font_get_glyph_index(rids[i], p_size, p_next, 0);
|
||||||
ret.x -= TS->font_get_kerning(rids[i], size, Vector2i(glyph_a, glyph_b)).x;
|
ret.x -= TS->font_get_kerning(rids[i], p_size, Vector2i(glyph_a, glyph_b)).x;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1591,22 +1563,20 @@ Size2 Font::get_char_size(char32_t p_char, char32_t p_next, int p_size) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t Font::draw_char(RID p_canvas_item, const Point2 &p_pos, char32_t p_char, char32_t p_next, int p_size, const Color &p_modulate, int p_outline_size, const Color &p_outline_modulate) const {
|
real_t Font::draw_char(RID p_canvas_item, const Point2 &p_pos, char32_t p_char, char32_t p_next, int p_size, const Color &p_modulate, int p_outline_size, const Color &p_outline_modulate) const {
|
||||||
int size = (p_size <= 0) ? base_size : p_size;
|
|
||||||
|
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
_ensure_rid(i);
|
_ensure_rid(i);
|
||||||
if (data[i]->has_char(p_char)) {
|
if (data[i]->has_char(p_char)) {
|
||||||
int32_t glyph_a = TS->font_get_glyph_index(rids[i], size, p_char, 0);
|
int32_t glyph_a = TS->font_get_glyph_index(rids[i], p_size, p_char, 0);
|
||||||
real_t ret = TS->font_get_glyph_advance(rids[i], size, glyph_a).x;
|
real_t ret = TS->font_get_glyph_advance(rids[i], p_size, glyph_a).x;
|
||||||
if ((p_next != 0) && data[i]->has_char(p_next)) {
|
if ((p_next != 0) && data[i]->has_char(p_next)) {
|
||||||
int32_t glyph_b = TS->font_get_glyph_index(rids[i], size, p_next, 0);
|
int32_t glyph_b = TS->font_get_glyph_index(rids[i], p_size, p_next, 0);
|
||||||
ret -= TS->font_get_kerning(rids[i], size, Vector2i(glyph_a, glyph_b)).x;
|
ret -= TS->font_get_kerning(rids[i], p_size, Vector2i(glyph_a, glyph_b)).x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_outline_size > 0 && p_outline_modulate.a != 0.0f) {
|
if (p_outline_size > 0 && p_outline_modulate.a != 0.0f) {
|
||||||
TS->font_draw_glyph_outline(rids[i], p_canvas_item, size, p_outline_size, p_pos, glyph_a, p_outline_modulate);
|
TS->font_draw_glyph_outline(rids[i], p_canvas_item, p_size, p_outline_size, p_pos, glyph_a, p_outline_modulate);
|
||||||
}
|
}
|
||||||
TS->font_draw_glyph(rids[i], p_canvas_item, size, p_pos, glyph_a, p_modulate);
|
TS->font_draw_glyph(rids[i], p_canvas_item, p_size, p_pos, glyph_a, p_modulate);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,6 @@ class Font : public Resource {
|
||||||
mutable Vector<RID> rids;
|
mutable Vector<RID> rids;
|
||||||
|
|
||||||
// Font config.
|
// Font config.
|
||||||
int base_size = 16;
|
|
||||||
Dictionary variation_coordinates;
|
Dictionary variation_coordinates;
|
||||||
int spacing_bottom = 0;
|
int spacing_bottom = 0;
|
||||||
int spacing_top = 0;
|
int spacing_top = 0;
|
||||||
|
@ -237,6 +236,8 @@ protected:
|
||||||
virtual void reset_state() override;
|
virtual void reset_state() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static const int DEFAULT_FONT_SIZE = 16;
|
||||||
|
|
||||||
Dictionary get_feature_list() const;
|
Dictionary get_feature_list() const;
|
||||||
|
|
||||||
// Font data.
|
// Font data.
|
||||||
|
@ -249,9 +250,6 @@ public:
|
||||||
virtual void remove_data(int p_idx);
|
virtual void remove_data(int p_idx);
|
||||||
|
|
||||||
// Font configuration.
|
// Font configuration.
|
||||||
virtual void set_base_size(int p_size);
|
|
||||||
virtual int get_base_size() const;
|
|
||||||
|
|
||||||
virtual void set_variation_coordinates(const Dictionary &p_variation_coordinates);
|
virtual void set_variation_coordinates(const Dictionary &p_variation_coordinates);
|
||||||
virtual Dictionary get_variation_coordinates() const;
|
virtual Dictionary get_variation_coordinates() const;
|
||||||
|
|
||||||
|
@ -259,26 +257,26 @@ public:
|
||||||
virtual int get_spacing(TextServer::SpacingType p_spacing) const;
|
virtual int get_spacing(TextServer::SpacingType p_spacing) const;
|
||||||
|
|
||||||
// Font metrics.
|
// Font metrics.
|
||||||
virtual real_t get_height(int p_size = -1) const;
|
virtual real_t get_height(int p_size = DEFAULT_FONT_SIZE) const;
|
||||||
virtual real_t get_ascent(int p_size = -1) const;
|
virtual real_t get_ascent(int p_size = DEFAULT_FONT_SIZE) const;
|
||||||
virtual real_t get_descent(int p_size = -1) const;
|
virtual real_t get_descent(int p_size = DEFAULT_FONT_SIZE) const;
|
||||||
virtual real_t get_underline_position(int p_size = -1) const;
|
virtual real_t get_underline_position(int p_size = DEFAULT_FONT_SIZE) const;
|
||||||
virtual real_t get_underline_thickness(int p_size = -1) const;
|
virtual real_t get_underline_thickness(int p_size = DEFAULT_FONT_SIZE) const;
|
||||||
|
|
||||||
// Drawing string.
|
// Drawing string.
|
||||||
virtual Size2 get_string_size(const String &p_text, int p_size = -1, HAlign p_align = HALIGN_LEFT, real_t p_width = -1, uint16_t p_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND) const;
|
virtual Size2 get_string_size(const String &p_text, int p_size = DEFAULT_FONT_SIZE, HAlign p_align = HALIGN_LEFT, real_t p_width = -1, uint16_t p_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND) const;
|
||||||
virtual Size2 get_multiline_string_size(const String &p_text, real_t p_width = -1, int p_size = -1, uint16_t p_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND) const;
|
virtual Size2 get_multiline_string_size(const String &p_text, real_t p_width = -1, int p_size = DEFAULT_FONT_SIZE, uint16_t p_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND) const;
|
||||||
|
|
||||||
virtual void draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HAlign p_align = HALIGN_LEFT, real_t p_width = -1, int p_size = -1, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0), uint16_t p_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND) const;
|
virtual void draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HAlign p_align = HALIGN_LEFT, real_t p_width = -1, int p_size = DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0), uint16_t p_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND) const;
|
||||||
virtual void draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HAlign p_align = HALIGN_LEFT, real_t p_width = -1, int p_max_lines = -1, int p_size = -1, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0), uint16_t p_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND) const;
|
virtual void draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HAlign p_align = HALIGN_LEFT, real_t p_width = -1, int p_max_lines = -1, int p_size = DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0), uint16_t p_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND) const;
|
||||||
|
|
||||||
// Helper functions.
|
// Helper functions.
|
||||||
virtual bool has_char(char32_t p_char) const;
|
virtual bool has_char(char32_t p_char) const;
|
||||||
virtual String get_supported_chars() const;
|
virtual String get_supported_chars() const;
|
||||||
|
|
||||||
// Drawing char.
|
// Drawing char.
|
||||||
virtual Size2 get_char_size(char32_t p_char, char32_t p_next = 0, int p_size = -1) const;
|
virtual Size2 get_char_size(char32_t p_char, char32_t p_next = 0, int p_size = DEFAULT_FONT_SIZE) const;
|
||||||
virtual real_t draw_char(RID p_canvas_item, const Point2 &p_pos, char32_t p_char, char32_t p_next = 0, int p_size = -1, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0)) const;
|
virtual real_t draw_char(RID p_canvas_item, const Point2 &p_pos, char32_t p_char, char32_t p_next = 0, int p_size = DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0)) const;
|
||||||
|
|
||||||
Vector<RID> get_rids() const;
|
Vector<RID> get_rids() const;
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||||
const StringName *key2 = nullptr;
|
const StringName *key2 = nullptr;
|
||||||
|
|
||||||
while ((key2 = font_size_map[*key].next(key2))) {
|
while ((key2 = font_size_map[*key].next(key2))) {
|
||||||
list.push_back(PropertyInfo(Variant::INT, String() + *key + "/font_sizes/" + *key2));
|
list.push_back(PropertyInfo(Variant::INT, String() + *key + "/font_sizes/" + *key2, PROPERTY_HINT_RANGE, "0,256,1,or_greater"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1655,7 +1655,7 @@ void Theme::_bind_methods() {
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "default_base_scale", PROPERTY_HINT_RANGE, "0.0,2.0,0.01,or_greater"), "set_default_base_scale", "get_default_base_scale");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "default_base_scale", PROPERTY_HINT_RANGE, "0.0,2.0,0.01,or_greater"), "set_default_base_scale", "get_default_base_scale");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "default_font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), "set_default_font", "get_default_font");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "default_font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), "set_default_font", "get_default_font");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "default_font_size"), "set_default_font_size", "get_default_font_size");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "default_font_size", PROPERTY_HINT_RANGE, "0,256,1,or_greater"), "set_default_font_size", "get_default_font_size");
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(DATA_TYPE_COLOR);
|
BIND_ENUM_CONSTANT(DATA_TYPE_COLOR);
|
||||||
BIND_ENUM_CONSTANT(DATA_TYPE_CONSTANT);
|
BIND_ENUM_CONSTANT(DATA_TYPE_CONSTANT);
|
||||||
|
|
Loading…
Reference in New Issue