Use BitField hint for the TextServer enums. Add missing parts for BitField support to the GDextension API.
This commit is contained in:
parent
e5a1640cf0
commit
cbe3a2dcb7
@ -625,6 +625,7 @@ void register_global_constants() {
|
||||
BIND_CORE_ENUM_CONSTANT(PROPERTY_USAGE_GROUP);
|
||||
BIND_CORE_ENUM_CONSTANT(PROPERTY_USAGE_CATEGORY);
|
||||
BIND_CORE_ENUM_CONSTANT(PROPERTY_USAGE_SUBGROUP);
|
||||
BIND_CORE_ENUM_CONSTANT(PROPERTY_USAGE_CLASS_IS_BITFIELD);
|
||||
BIND_CORE_ENUM_CONSTANT(PROPERTY_USAGE_NO_INSTANCE_STATE);
|
||||
BIND_CORE_ENUM_CONSTANT(PROPERTY_USAGE_RESTART_IF_CHANGED);
|
||||
BIND_CORE_ENUM_CONSTANT(PROPERTY_USAGE_SCRIPT_VARIABLE);
|
||||
|
@ -46,9 +46,12 @@ static String get_type_name(const PropertyInfo &p_info) {
|
||||
return p_info.hint_string + "*";
|
||||
}
|
||||
}
|
||||
if (p_info.type == Variant::INT && (p_info.usage & (PROPERTY_USAGE_CLASS_IS_ENUM | PROPERTY_USAGE_CLASS_IS_BITFIELD))) {
|
||||
if (p_info.type == Variant::INT && (p_info.usage & (PROPERTY_USAGE_CLASS_IS_ENUM))) {
|
||||
return String("enum::") + String(p_info.class_name);
|
||||
}
|
||||
if (p_info.type == Variant::INT && (p_info.usage & (PROPERTY_USAGE_CLASS_IS_BITFIELD))) {
|
||||
return String("bitfield::") + String(p_info.class_name);
|
||||
}
|
||||
if (p_info.class_name != StringName()) {
|
||||
return p_info.class_name;
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ typedef struct {
|
||||
|
||||
void (*classdb_register_extension_class)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs);
|
||||
void (*classdb_register_extension_class_method)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info);
|
||||
void (*classdb_register_extension_class_integer_constant)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, GDNativeInt p_constant_value);
|
||||
void (*classdb_register_extension_class_integer_constant)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, GDNativeInt p_constant_value, bool p_is_bitfield);
|
||||
void (*classdb_register_extension_class_property)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativePropertyInfo *p_info, const char *p_setter, const char *p_getter);
|
||||
void (*classdb_register_extension_class_property_group)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_group_name, const char *p_prefix);
|
||||
void (*classdb_register_extension_class_property_subgroup)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_subgroup_name, const char *p_prefix);
|
||||
|
@ -182,7 +182,7 @@ void NativeExtension::_register_extension_class_method(const GDNativeExtensionCl
|
||||
|
||||
ClassDB::bind_method_custom(class_name, method);
|
||||
}
|
||||
void NativeExtension::_register_extension_class_integer_constant(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, GDNativeInt p_constant_value) {
|
||||
void NativeExtension::_register_extension_class_integer_constant(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, GDNativeInt p_constant_value, bool p_is_bitfield) {
|
||||
NativeExtension *self = static_cast<NativeExtension *>(p_library);
|
||||
|
||||
StringName class_name = p_class_name;
|
||||
@ -190,7 +190,7 @@ void NativeExtension::_register_extension_class_integer_constant(const GDNativeE
|
||||
|
||||
//Extension *extension = &self->extension_classes[class_name];
|
||||
|
||||
ClassDB::bind_integer_constant(class_name, p_enum_name, p_constant_name, p_constant_value);
|
||||
ClassDB::bind_integer_constant(class_name, p_enum_name, p_constant_name, p_constant_value, p_is_bitfield);
|
||||
}
|
||||
|
||||
void NativeExtension::_register_extension_class_property(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativePropertyInfo *p_info, const char *p_setter, const char *p_getter) {
|
||||
|
@ -49,7 +49,7 @@ class NativeExtension : public Resource {
|
||||
|
||||
static void _register_extension_class(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs);
|
||||
static void _register_extension_class_method(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info);
|
||||
static void _register_extension_class_integer_constant(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, GDNativeInt p_constant_value);
|
||||
static void _register_extension_class_integer_constant(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, GDNativeInt p_constant_value, bool p_is_bitfield);
|
||||
static void _register_extension_class_property(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativePropertyInfo *p_info, const char *p_setter, const char *p_getter);
|
||||
static void _register_extension_class_property_group(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_group_name, const char *p_prefix);
|
||||
static void _register_extension_class_property_subgroup(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_subgroup_name, const char *p_prefix);
|
||||
|
@ -289,6 +289,7 @@ public:
|
||||
_FORCE_INLINE_ void clear_flag(T p_flag) { return value &= ~p_flag; }
|
||||
_FORCE_INLINE_ BitField(uint32_t p_value) { value = p_value; }
|
||||
_FORCE_INLINE_ operator uint32_t() const { return value; }
|
||||
_FORCE_INLINE_ operator Variant() const { return value; }
|
||||
};
|
||||
|
||||
#define TEMPL_MAKE_BITFIELD_TYPE_INFO(m_enum, m_impl) \
|
||||
|
@ -2652,6 +2652,8 @@
|
||||
<constant name="PROPERTY_USAGE_SUBGROUP" value="256" enum="PropertyUsageFlags">
|
||||
Used to group properties together in the editor in a subgroup (under a group). See [EditorInspector].
|
||||
</constant>
|
||||
<constant name="PROPERTY_USAGE_CLASS_IS_BITFIELD" value="512" enum="PropertyUsageFlags">
|
||||
</constant>
|
||||
<constant name="PROPERTY_USAGE_NO_INSTANCE_STATE" value="1024" enum="PropertyUsageFlags">
|
||||
The property does not save its state in [PackedScene].
|
||||
</constant>
|
||||
|
@ -169,9 +169,10 @@
|
||||
<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="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" />
|
||||
<argument index="8" name="brk_flags" type="int" enum="TextServer.LineBreakFlag" default="3" />
|
||||
<argument index="9" name="jst_flags" type="int" enum="TextServer.JustificationFlag" default="3" />
|
||||
<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 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>
|
||||
@ -187,9 +188,10 @@
|
||||
<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" />
|
||||
<argument index="9" name="brk_flags" type="int" enum="TextServer.LineBreakFlag" default="3" />
|
||||
<argument index="10" name="jst_flags" type="int" enum="TextServer.JustificationFlag" default="3" />
|
||||
<argument index="11" name="direction" type="int" enum="TextServer.Direction" default="0" />
|
||||
<argument index="12" 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>
|
||||
@ -279,7 +281,7 @@
|
||||
<argument index="4" name="width" type="float" default="-1" />
|
||||
<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="flags" type="int" default="3" />
|
||||
<argument index="7" name="jst_flags" type="int" enum="TextServer.JustificationFlag" 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>
|
||||
@ -316,7 +318,7 @@
|
||||
<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="8" name="jst_flags" type="int" enum="TextServer.JustificationFlag" 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>
|
||||
|
@ -44,9 +44,10 @@
|
||||
<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="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" />
|
||||
<argument index="8" name="brk_flags" type="int" enum="TextServer.LineBreakFlag" default="3" />
|
||||
<argument index="9" name="jst_flags" type="int" enum="TextServer.JustificationFlag" default="3" />
|
||||
<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 using rules specified by [code]flags[/code] and draws it into a canvas item using the font, at a given position, with [code]modulate[/code] color, optionally clipping the width and aligning horizontally. [code]position[/code] specifies the baseline of the first line, not the top. To draw from the top, [i]ascent[/i] must be added to the Y axis.
|
||||
See also [method CanvasItem.draw_multiline_string].
|
||||
@ -63,9 +64,10 @@
|
||||
<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" />
|
||||
<argument index="9" name="brk_flags" type="int" enum="TextServer.LineBreakFlag" default="3" />
|
||||
<argument index="10" name="jst_flags" type="int" enum="TextServer.JustificationFlag" default="3" />
|
||||
<argument index="11" name="direction" type="int" enum="TextServer.Direction" default="0" />
|
||||
<argument index="12" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
|
||||
<description>
|
||||
Breaks [code]text[/code] to the lines using rules specified by [code]flags[/code] and draws text outline into a canvas item using the font, at a given position, with [code]modulate[/code] color and [code]size[/code] outline size, optionally clipping the width and aligning horizontally. [code]position[/code] specifies the baseline of the first line, not the top. To draw from the top, [i]ascent[/i] must be added to the Y axis.
|
||||
See also [method CanvasItem.draw_multiline_string_outline].
|
||||
@ -80,7 +82,7 @@
|
||||
<argument index="4" name="width" type="float" default="-1" />
|
||||
<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="flags" type="int" default="3" />
|
||||
<argument index="7" name="jst_flags" type="int" enum="TextServer.JustificationFlag" 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>
|
||||
@ -98,7 +100,7 @@
|
||||
<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="8" name="jst_flags" type="int" enum="TextServer.JustificationFlag" 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>
|
||||
@ -160,7 +162,7 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_font_style" qualifiers="const">
|
||||
<return type="int" />
|
||||
<return type="int" enum="TextServer.FontStyle" />
|
||||
<description>
|
||||
Returns font style flags, see [enum TextServer.FontStyle].
|
||||
</description>
|
||||
@ -186,9 +188,10 @@
|
||||
<argument index="2" name="width" type="float" default="-1" />
|
||||
<argument index="3" name="font_size" type="int" default="16" />
|
||||
<argument index="4" name="max_lines" type="int" default="-1" />
|
||||
<argument index="5" name="flags" type="int" default="96" />
|
||||
<argument index="6" name="direction" type="int" enum="TextServer.Direction" default="0" />
|
||||
<argument index="7" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
|
||||
<argument index="5" name="brk_flags" type="int" enum="TextServer.LineBreakFlag" default="3" />
|
||||
<argument index="6" name="jst_flags" type="int" enum="TextServer.JustificationFlag" default="3" />
|
||||
<argument index="7" name="direction" type="int" enum="TextServer.Direction" default="0" />
|
||||
<argument index="8" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
|
||||
<description>
|
||||
Returns the size of a bounding box of a string broken into the lines, taking kerning and advance into account.
|
||||
See also [method draw_multiline_string].
|
||||
@ -219,7 +222,7 @@
|
||||
<argument index="1" name="alignment" type="int" enum="HorizontalAlignment" default="0" />
|
||||
<argument index="2" name="width" type="float" default="-1" />
|
||||
<argument index="3" name="font_size" type="int" default="16" />
|
||||
<argument index="4" name="flags" type="int" default="3" />
|
||||
<argument index="4" name="jst_flags" type="int" enum="TextServer.JustificationFlag" default="3" />
|
||||
<argument index="5" name="direction" type="int" enum="TextServer.Direction" default="0" />
|
||||
<argument index="6" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
|
||||
<description>
|
||||
|
@ -558,7 +558,7 @@
|
||||
<member name="font_name" type="String" setter="set_font_name" getter="get_font_name" default="""">
|
||||
Font family name.
|
||||
</member>
|
||||
<member name="font_style" type="int" setter="set_font_style" getter="get_font_style" default="0">
|
||||
<member name="font_style" type="int" setter="set_font_style" getter="get_font_style" enum="TextServer.FontStyle" default="0">
|
||||
Font style flags, see [enum TextServer.FontStyle].
|
||||
</member>
|
||||
<member name="force_autohinter" type="bool" setter="set_force_autohinter" getter="is_force_autohinter" default="false">
|
||||
|
@ -148,8 +148,8 @@
|
||||
<member name="direction" type="int" setter="set_direction" getter="get_direction" enum="TextServer.Direction" default="0">
|
||||
Text writing direction.
|
||||
</member>
|
||||
<member name="flags" type="int" setter="set_flags" getter="get_flags" default="3">
|
||||
Line Alignment rules. For more info see [TextServer].
|
||||
<member name="flags" type="int" setter="set_flags" getter="get_flags" enum="TextServer.JustificationFlag" default="3">
|
||||
Line alignment rules. For more info see [TextServer].
|
||||
</member>
|
||||
<member name="orientation" type="int" setter="set_orientation" getter="get_orientation" enum="TextServer.Orientation" default="0">
|
||||
Text orientation.
|
||||
|
@ -263,14 +263,17 @@
|
||||
<member name="alignment" type="int" setter="set_alignment" getter="get_alignment" enum="HorizontalAlignment" default="0">
|
||||
Paragraph horizontal alignment.
|
||||
</member>
|
||||
<member name="break_flags" type="int" setter="set_break_flags" getter="get_break_flags" enum="TextServer.LineBreakFlag" default="3">
|
||||
Line breaking rules. For more info see [TextServer].
|
||||
</member>
|
||||
<member name="custom_punctuation" type="String" setter="set_custom_punctuation" getter="get_custom_punctuation" default="""">
|
||||
Custom punctuation character list, used for word breaking. If set to empty string, server defaults are used.
|
||||
</member>
|
||||
<member name="direction" type="int" setter="set_direction" getter="get_direction" enum="TextServer.Direction" default="0">
|
||||
Text writing direction.
|
||||
</member>
|
||||
<member name="flags" type="int" setter="set_flags" getter="get_flags" default="99">
|
||||
Line breaking and alignment rules. For more info see [TextServer].
|
||||
<member name="justification_flags" type="int" setter="set_justification_flags" getter="get_justification_flags" enum="TextServer.JustificationFlag" default="3">
|
||||
Line alignment rules. For more info see [TextServer].
|
||||
</member>
|
||||
<member name="max_lines_visible" type="int" setter="set_max_lines_visible" getter="get_max_lines_visible" default="-1">
|
||||
Limits the lines of text shown.
|
||||
|
@ -356,7 +356,7 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_style" qualifiers="const">
|
||||
<return type="int" />
|
||||
<return type="int" enum="TextServer.FontStyle" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<description>
|
||||
Returns font style flags, see [enum FontStyle].
|
||||
@ -786,7 +786,7 @@
|
||||
<method name="font_set_style">
|
||||
<return type="void" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<argument index="1" name="style" type="int" />
|
||||
<argument index="1" name="style" type="int" enum="TextServer.FontStyle" />
|
||||
<description>
|
||||
Sets the font style flags, see [enum FontStyle].
|
||||
</description>
|
||||
@ -1077,7 +1077,7 @@
|
||||
<return type="float" />
|
||||
<argument index="0" name="shaped" type="RID" />
|
||||
<argument index="1" name="width" type="float" />
|
||||
<argument index="2" name="jst_flags" type="int" default="3" />
|
||||
<argument index="2" name="jst_flags" type="int" enum="TextServer.JustificationFlag" default="3" />
|
||||
<description>
|
||||
Adjusts text with to fit to specified width, returns new text width.
|
||||
</description>
|
||||
@ -1184,7 +1184,7 @@
|
||||
<argument index="0" name="shaped" type="RID" />
|
||||
<argument index="1" name="width" type="float" />
|
||||
<argument index="2" name="start" type="int" default="0" />
|
||||
<argument index="3" name="break_flags" type="int" default="96" />
|
||||
<argument index="3" name="break_flags" type="int" enum="TextServer.LineBreakFlag" default="3" />
|
||||
<description>
|
||||
Breaks text to the lines and returns character ranges for each line.
|
||||
</description>
|
||||
@ -1195,7 +1195,7 @@
|
||||
<argument index="1" name="width" type="PackedFloat32Array" />
|
||||
<argument index="2" name="start" type="int" default="0" />
|
||||
<argument index="3" name="once" type="bool" default="true" />
|
||||
<argument index="4" name="break_flags" type="int" default="96" />
|
||||
<argument index="4" name="break_flags" type="int" enum="TextServer.LineBreakFlag" default="3" />
|
||||
<description>
|
||||
Breaks text to the lines and columns. Returns character ranges for each segment.
|
||||
</description>
|
||||
@ -1306,7 +1306,7 @@
|
||||
<method name="shaped_text_get_word_breaks" qualifiers="const">
|
||||
<return type="PackedInt32Array" />
|
||||
<argument index="0" name="shaped" type="RID" />
|
||||
<argument index="1" name="grapheme_flags" type="int" default="264" />
|
||||
<argument index="1" name="grapheme_flags" type="int" enum="TextServer.GraphemeFlag" default="264" />
|
||||
<description>
|
||||
Breaks text into words and returns array of character ranges. Use [code]grapheme_flags[/code] to set what characters are used for breaking (see [enum GraphemeFlag]).
|
||||
</description>
|
||||
@ -1346,7 +1346,7 @@
|
||||
<return type="void" />
|
||||
<argument index="0" name="shaped" type="RID" />
|
||||
<argument index="1" name="width" type="float" default="0" />
|
||||
<argument index="2" name="overrun_trim_flags" type="int" default="0" />
|
||||
<argument index="2" name="overrun_trim_flags" type="int" enum="TextServer.TextOverrunFlag" default="0" />
|
||||
<description>
|
||||
Trims text if it exceeds the given width.
|
||||
</description>
|
||||
@ -1522,22 +1522,22 @@
|
||||
Left to right text is written vertically from top to bottom.
|
||||
Right to left text is written vertically from bottom to top.
|
||||
</constant>
|
||||
<constant name="JUSTIFICATION_NONE" value="0" enum="JustificationFlag">
|
||||
<constant name="JUSTIFICATION_NONE" value="0" enum="JustificationFlag" is_bitfield="true">
|
||||
Do not justify text.
|
||||
</constant>
|
||||
<constant name="JUSTIFICATION_KASHIDA" value="1" enum="JustificationFlag">
|
||||
<constant name="JUSTIFICATION_KASHIDA" value="1" enum="JustificationFlag" is_bitfield="true">
|
||||
Justify text by adding and removing kashidas.
|
||||
</constant>
|
||||
<constant name="JUSTIFICATION_WORD_BOUND" value="2" enum="JustificationFlag">
|
||||
<constant name="JUSTIFICATION_WORD_BOUND" value="2" enum="JustificationFlag" is_bitfield="true">
|
||||
Justify text by changing width of the spaces between the words.
|
||||
</constant>
|
||||
<constant name="JUSTIFICATION_TRIM_EDGE_SPACES" value="4" enum="JustificationFlag">
|
||||
<constant name="JUSTIFICATION_TRIM_EDGE_SPACES" value="4" enum="JustificationFlag" is_bitfield="true">
|
||||
Remove trailing and leading spaces from the justified text.
|
||||
</constant>
|
||||
<constant name="JUSTIFICATION_AFTER_LAST_TAB" value="8" enum="JustificationFlag">
|
||||
<constant name="JUSTIFICATION_AFTER_LAST_TAB" value="8" enum="JustificationFlag" is_bitfield="true">
|
||||
Only apply justification to the part of the text after the last tab.
|
||||
</constant>
|
||||
<constant name="JUSTIFICATION_CONSTRAIN_ELLIPSIS" value="16" enum="JustificationFlag">
|
||||
<constant name="JUSTIFICATION_CONSTRAIN_ELLIPSIS" value="16" enum="JustificationFlag" is_bitfield="true">
|
||||
Apply justification to the trimmed line with ellipsis.
|
||||
</constant>
|
||||
<constant name="AUTOWRAP_OFF" value="0" enum="AutowrapMode">
|
||||
@ -1552,20 +1552,19 @@
|
||||
<constant name="AUTOWRAP_WORD_SMART" value="3" enum="AutowrapMode">
|
||||
Behaves similarly to [constant AUTOWRAP_WORD], but force-breaks a word if that single word does not fit in one line.
|
||||
</constant>
|
||||
<constant name="BREAK_NONE" value="0" enum="LineBreakFlag">
|
||||
<constant name="BREAK_NONE" value="0" enum="LineBreakFlag" is_bitfield="true">
|
||||
Do not break the line.
|
||||
</constant>
|
||||
<constant name="BREAK_MANDATORY" value="32" enum="LineBreakFlag">
|
||||
<constant name="BREAK_MANDATORY" value="1" enum="LineBreakFlag" is_bitfield="true">
|
||||
Break the line at the line mandatory break characters (e.g. [code]"\n"[/code]).
|
||||
</constant>
|
||||
<constant name="BREAK_WORD_BOUND" value="64" enum="LineBreakFlag">
|
||||
<constant name="BREAK_WORD_BOUND" value="2" enum="LineBreakFlag" is_bitfield="true">
|
||||
Break the line between the words.
|
||||
</constant>
|
||||
<constant name="BREAK_GRAPHEME_BOUND" value="128" enum="LineBreakFlag">
|
||||
<constant name="BREAK_GRAPHEME_BOUND" value="4" enum="LineBreakFlag" is_bitfield="true">
|
||||
Break the line between any unconnected graphemes.
|
||||
</constant>
|
||||
<constant name="BREAK_WORD_BOUND_ADAPTIVE" value="320" enum="LineBreakFlag">
|
||||
Break the line between the words, or any unconnected graphemes if line is too short to fit the whole word.
|
||||
<constant name="BREAK_ADAPTIVE" value="8" enum="LineBreakFlag" is_bitfield="true">
|
||||
</constant>
|
||||
<constant name="VC_CHARS_BEFORE_SHAPING" value="0" enum="VisibleCharactersBehavior">
|
||||
Trims text before the shaping. e.g, increasing [member Label.visible_characters] or [member RichTextLabel.visible_characters] value is visually identical to typing the text.
|
||||
@ -1597,54 +1596,54 @@
|
||||
<constant name="OVERRUN_TRIM_WORD_ELLIPSIS" value="4" enum="OverrunBehavior">
|
||||
Trims the text per word and adds an ellipsis to indicate that parts are hidden.
|
||||
</constant>
|
||||
<constant name="OVERRUN_NO_TRIM" value="0" enum="TextOverrunFlag">
|
||||
<constant name="OVERRUN_NO_TRIM" value="0" enum="TextOverrunFlag" is_bitfield="true">
|
||||
No trimming is performed.
|
||||
</constant>
|
||||
<constant name="OVERRUN_TRIM" value="1" enum="TextOverrunFlag">
|
||||
<constant name="OVERRUN_TRIM" value="1" enum="TextOverrunFlag" is_bitfield="true">
|
||||
Trims the text when it exceeds the given width.
|
||||
</constant>
|
||||
<constant name="OVERRUN_TRIM_WORD_ONLY" value="2" enum="TextOverrunFlag">
|
||||
<constant name="OVERRUN_TRIM_WORD_ONLY" value="2" enum="TextOverrunFlag" is_bitfield="true">
|
||||
Trims the text per word instead of per grapheme.
|
||||
</constant>
|
||||
<constant name="OVERRUN_ADD_ELLIPSIS" value="4" enum="TextOverrunFlag">
|
||||
<constant name="OVERRUN_ADD_ELLIPSIS" value="4" enum="TextOverrunFlag" is_bitfield="true">
|
||||
Determines whether an ellipsis should be added at the end of the text.
|
||||
</constant>
|
||||
<constant name="OVERRUN_ENFORCE_ELLIPSIS" value="8" enum="TextOverrunFlag">
|
||||
<constant name="OVERRUN_ENFORCE_ELLIPSIS" value="8" enum="TextOverrunFlag" is_bitfield="true">
|
||||
Determines whether the ellipsis at the end of the text is enforced and may not be hidden.
|
||||
</constant>
|
||||
<constant name="OVERRUN_JUSTIFICATION_AWARE" value="16" enum="TextOverrunFlag">
|
||||
<constant name="OVERRUN_JUSTIFICATION_AWARE" value="16" enum="TextOverrunFlag" is_bitfield="true">
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_VALID" value="1" enum="GraphemeFlag">
|
||||
<constant name="GRAPHEME_IS_VALID" value="1" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is supported by the font, and can be drawn.
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_RTL" value="2" enum="GraphemeFlag">
|
||||
<constant name="GRAPHEME_IS_RTL" value="2" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is part of right-to-left or bottom-to-top run.
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_VIRTUAL" value="4" enum="GraphemeFlag">
|
||||
<constant name="GRAPHEME_IS_VIRTUAL" value="4" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is not part of source text, it was added by justification process.
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_SPACE" value="8" enum="GraphemeFlag">
|
||||
<constant name="GRAPHEME_IS_SPACE" value="8" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is whitespace.
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_BREAK_HARD" value="16" enum="GraphemeFlag">
|
||||
<constant name="GRAPHEME_IS_BREAK_HARD" value="16" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is mandatory break point (e.g. [code]"\n"[/code]).
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_BREAK_SOFT" value="32" enum="GraphemeFlag">
|
||||
<constant name="GRAPHEME_IS_BREAK_SOFT" value="32" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is optional break point (e.g. space).
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_TAB" value="64" enum="GraphemeFlag">
|
||||
<constant name="GRAPHEME_IS_TAB" value="64" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is the tabulation character.
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_ELONGATION" value="128" enum="GraphemeFlag">
|
||||
<constant name="GRAPHEME_IS_ELONGATION" value="128" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is kashida.
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_PUNCTUATION" value="256" enum="GraphemeFlag">
|
||||
<constant name="GRAPHEME_IS_PUNCTUATION" value="256" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is punctuation character.
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_UNDERSCORE" value="512" enum="GraphemeFlag">
|
||||
<constant name="GRAPHEME_IS_UNDERSCORE" value="512" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is underscore character.
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_CONNECTED" value="1024" enum="GraphemeFlag">
|
||||
<constant name="GRAPHEME_IS_CONNECTED" value="1024" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is connected to the previous grapheme. Breaking line before this grapheme is not safe.
|
||||
</constant>
|
||||
<constant name="HINTING_NONE" value="0" enum="Hinting">
|
||||
@ -1737,13 +1736,15 @@
|
||||
<constant name="SPACING_BOTTOM" value="3" enum="SpacingType">
|
||||
Spacing at the bottom of the line.
|
||||
</constant>
|
||||
<constant name="FONT_BOLD" value="1" enum="FontStyle">
|
||||
<constant name="SPACING_MAX" value="4" enum="SpacingType">
|
||||
</constant>
|
||||
<constant name="FONT_BOLD" value="1" enum="FontStyle" is_bitfield="true">
|
||||
Font is bold.
|
||||
</constant>
|
||||
<constant name="FONT_ITALIC" value="2" enum="FontStyle">
|
||||
<constant name="FONT_ITALIC" value="2" enum="FontStyle" is_bitfield="true">
|
||||
Font is italic or oblique.
|
||||
</constant>
|
||||
<constant name="FONT_FIXED_WIDTH" value="4" enum="FontStyle">
|
||||
<constant name="FONT_FIXED_WIDTH" value="4" enum="FontStyle" is_bitfield="true">
|
||||
Font have fixed-width characters.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_DEFAULT" value="0" enum="StructuredTextParser">
|
||||
|
@ -346,7 +346,7 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_style" qualifiers="virtual const">
|
||||
<return type="int" />
|
||||
<return type="int" enum="TextServer.FontStyle" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<description>
|
||||
Returns font style flags, see [enum TextServer.FontStyle].
|
||||
@ -782,7 +782,7 @@
|
||||
<method name="font_set_style" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<argument index="1" name="style" type="int" />
|
||||
<argument index="1" name="style" type="int" enum="TextServer.FontStyle" />
|
||||
<description>
|
||||
Sets the font style flags, see [enum TextServer.FontStyle].
|
||||
</description>
|
||||
@ -1074,7 +1074,7 @@
|
||||
<return type="float" />
|
||||
<argument index="0" name="shaped" type="RID" />
|
||||
<argument index="1" name="width" type="float" />
|
||||
<argument index="2" name="jst_flags" type="int" />
|
||||
<argument index="2" name="jst_flags" type="int" enum="TextServer.JustificationFlag" />
|
||||
<description>
|
||||
Adjusts text with to fit to specified width, returns new text width.
|
||||
</description>
|
||||
@ -1183,7 +1183,7 @@
|
||||
<argument index="0" name="shaped" type="RID" />
|
||||
<argument index="1" name="width" type="float" />
|
||||
<argument index="2" name="start" type="int" />
|
||||
<argument index="3" name="break_flags" type="int" />
|
||||
<argument index="3" name="break_flags" type="int" enum="TextServer.LineBreakFlag" />
|
||||
<description>
|
||||
Breaks text to the lines and returns character ranges for each line.
|
||||
[b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used.
|
||||
@ -1195,7 +1195,7 @@
|
||||
<argument index="1" name="width" type="PackedFloat32Array" />
|
||||
<argument index="2" name="start" type="int" />
|
||||
<argument index="3" name="once" type="bool" />
|
||||
<argument index="4" name="break_flags" type="int" />
|
||||
<argument index="4" name="break_flags" type="int" enum="TextServer.LineBreakFlag" />
|
||||
<description>
|
||||
Breaks text to the lines and columns. Returns character ranges for each segment.
|
||||
[b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used.
|
||||
@ -1308,7 +1308,7 @@
|
||||
<method name="shaped_text_get_word_breaks" qualifiers="virtual const">
|
||||
<return type="PackedInt32Array" />
|
||||
<argument index="0" name="shaped" type="RID" />
|
||||
<argument index="1" name="grapheme_flags" type="int" />
|
||||
<argument index="1" name="grapheme_flags" type="int" enum="TextServer.GraphemeFlag" />
|
||||
<description>
|
||||
Breaks text into words and returns array of character ranges.
|
||||
[b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used.
|
||||
@ -1352,7 +1352,7 @@
|
||||
<return type="void" />
|
||||
<argument index="0" name="shaped" type="RID" />
|
||||
<argument index="1" name="width" type="float" />
|
||||
<argument index="2" name="trim_flags" type="int" />
|
||||
<argument index="2" name="trim_flags" type="int" enum="TextServer.TextOverrunFlag" />
|
||||
<description>
|
||||
Trims text if it exceeds the given width.
|
||||
</description>
|
||||
|
@ -1372,13 +1372,13 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontAdvanced *p_f
|
||||
}
|
||||
p_font_data->style_flags = 0;
|
||||
if (fd->face->style_flags & FT_STYLE_FLAG_BOLD) {
|
||||
p_font_data->style_flags |= FONT_BOLD;
|
||||
p_font_data->style_flags.set_flag(FONT_BOLD);
|
||||
}
|
||||
if (fd->face->style_flags & FT_STYLE_FLAG_ITALIC) {
|
||||
p_font_data->style_flags |= FONT_ITALIC;
|
||||
p_font_data->style_flags.set_flag(FONT_ITALIC);
|
||||
}
|
||||
if (fd->face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) {
|
||||
p_font_data->style_flags |= FONT_FIXED_WIDTH;
|
||||
p_font_data->style_flags.set_flag(FONT_FIXED_WIDTH);
|
||||
}
|
||||
|
||||
hb_face_t *hb_face = hb_font_get_face(fd->hb_handle);
|
||||
@ -1629,11 +1629,12 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontAdvanced *p_f
|
||||
|
||||
hb_ot_name_id_t lbl_id;
|
||||
if (hb_ot_layout_feature_get_name_ids(hb_face, HB_OT_TAG_GSUB, i, &lbl_id, nullptr, nullptr, nullptr, nullptr)) {
|
||||
String lbl;
|
||||
PackedInt32Array lbl;
|
||||
unsigned int text_size = hb_ot_name_get_utf32(hb_face, lbl_id, hb_language_from_string(TranslationServer::get_singleton()->get_tool_locale().ascii().get_data(), -1), nullptr, nullptr) + 1;
|
||||
lbl.resize(text_size);
|
||||
memset((uint32_t *)lbl.ptrw(), 0, sizeof(uint32_t) * text_size);
|
||||
hb_ot_name_get_utf32(hb_face, lbl_id, hb_language_from_string(TranslationServer::get_singleton()->get_tool_locale().ascii().get_data(), -1), &text_size, (uint32_t *)lbl.ptrw());
|
||||
ftr["label"] = lbl;
|
||||
ftr["label"] = String((const char32_t *)lbl.ptr());
|
||||
}
|
||||
ftr["type"] = _get_tag_type(feature_tags[i]);
|
||||
ftr["hidden"] = _get_tag_hidden(feature_tags[i]);
|
||||
@ -1651,11 +1652,12 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontAdvanced *p_f
|
||||
|
||||
hb_ot_name_id_t lbl_id;
|
||||
if (hb_ot_layout_feature_get_name_ids(hb_face, HB_OT_TAG_GPOS, i, &lbl_id, nullptr, nullptr, nullptr, nullptr)) {
|
||||
String lbl;
|
||||
PackedInt32Array lbl;
|
||||
unsigned int text_size = hb_ot_name_get_utf32(hb_face, lbl_id, hb_language_from_string(TranslationServer::get_singleton()->get_tool_locale().ascii().get_data(), -1), nullptr, nullptr) + 1;
|
||||
lbl.resize(text_size);
|
||||
memset((uint32_t *)lbl.ptrw(), 0, sizeof(uint32_t) * text_size);
|
||||
hb_ot_name_get_utf32(hb_face, lbl_id, hb_language_from_string(TranslationServer::get_singleton()->get_tool_locale().ascii().get_data(), -1), &text_size, (uint32_t *)lbl.ptrw());
|
||||
ftr["label"] = lbl;
|
||||
ftr["label"] = String((const char32_t *)lbl.ptr());
|
||||
}
|
||||
ftr["type"] = _get_tag_type(feature_tags[i]);
|
||||
ftr["hidden"] = _get_tag_hidden(feature_tags[i]);
|
||||
@ -1842,7 +1844,7 @@ int64_t TextServerAdvanced::font_get_face_count(const RID &p_font_rid) const {
|
||||
return face_count;
|
||||
}
|
||||
|
||||
void TextServerAdvanced::font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) {
|
||||
void TextServerAdvanced::font_set_style(const RID &p_font_rid, BitField<FontStyle> p_style) {
|
||||
FontAdvanced *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND(!fd);
|
||||
|
||||
@ -1852,7 +1854,7 @@ void TextServerAdvanced::font_set_style(const RID &p_font_rid, int64_t /*FontSty
|
||||
fd->style_flags = p_style;
|
||||
}
|
||||
|
||||
int64_t /*FontStyle*/ TextServerAdvanced::font_get_style(const RID &p_font_rid) const {
|
||||
BitField<TextServer::FontStyle> TextServerAdvanced::font_get_style(const RID &p_font_rid) const {
|
||||
FontAdvanced *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND_V(!fd, 0);
|
||||
|
||||
@ -3992,7 +3994,7 @@ RID TextServerAdvanced::shaped_text_get_parent(const RID &p_shaped) const {
|
||||
return sd->parent;
|
||||
}
|
||||
|
||||
double TextServerAdvanced::shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags) {
|
||||
double TextServerAdvanced::shaped_text_fit_to_width(const RID &p_shaped, double p_width, BitField<TextServer::JustificationFlag> p_jst_flags) {
|
||||
ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_COND_V(!sd, 0.0);
|
||||
|
||||
@ -4008,7 +4010,7 @@ double TextServerAdvanced::shaped_text_fit_to_width(const RID &p_shaped, double
|
||||
int start_pos = 0;
|
||||
int end_pos = sd->glyphs.size() - 1;
|
||||
|
||||
if ((p_jst_flags & JUSTIFICATION_AFTER_LAST_TAB) == JUSTIFICATION_AFTER_LAST_TAB) {
|
||||
if (p_jst_flags.has_flag(JUSTIFICATION_AFTER_LAST_TAB)) {
|
||||
int start, end, delta;
|
||||
if (sd->para_direction == DIRECTION_LTR) {
|
||||
start = sd->glyphs.size() - 1;
|
||||
@ -4034,7 +4036,7 @@ double TextServerAdvanced::shaped_text_fit_to_width(const RID &p_shaped, double
|
||||
}
|
||||
|
||||
double justification_width;
|
||||
if ((p_jst_flags & JUSTIFICATION_CONSTRAIN_ELLIPSIS) == JUSTIFICATION_CONSTRAIN_ELLIPSIS) {
|
||||
if (p_jst_flags.has_flag(JUSTIFICATION_CONSTRAIN_ELLIPSIS)) {
|
||||
if (sd->overrun_trim_data.trim_pos >= 0) {
|
||||
if (sd->para_direction == DIRECTION_RTL) {
|
||||
start_pos = sd->overrun_trim_data.trim_pos;
|
||||
@ -4049,7 +4051,7 @@ double TextServerAdvanced::shaped_text_fit_to_width(const RID &p_shaped, double
|
||||
justification_width = sd->width;
|
||||
}
|
||||
|
||||
if ((p_jst_flags & JUSTIFICATION_TRIM_EDGE_SPACES) == JUSTIFICATION_TRIM_EDGE_SPACES) {
|
||||
if (p_jst_flags.has_flag(JUSTIFICATION_TRIM_EDGE_SPACES)) {
|
||||
// Trim spaces.
|
||||
while ((start_pos < end_pos) && ((sd->glyphs[start_pos].flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE || (sd->glyphs[start_pos].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD || (sd->glyphs[start_pos].flags & GRAPHEME_IS_BREAK_SOFT) == GRAPHEME_IS_BREAK_SOFT)) {
|
||||
justification_width -= sd->glyphs[start_pos].advance * sd->glyphs[start_pos].repeat;
|
||||
@ -4088,7 +4090,7 @@ double TextServerAdvanced::shaped_text_fit_to_width(const RID &p_shaped, double
|
||||
}
|
||||
}
|
||||
|
||||
if ((elongation_count > 0) && ((p_jst_flags & JUSTIFICATION_KASHIDA) == JUSTIFICATION_KASHIDA)) {
|
||||
if ((elongation_count > 0) && p_jst_flags.has_flag(JUSTIFICATION_KASHIDA)) {
|
||||
double delta_width_per_kashida = (p_width - justification_width) / elongation_count;
|
||||
for (int i = start_pos; i <= end_pos; i++) {
|
||||
Glyph &gl = sd->glyphs.write[i];
|
||||
@ -4109,7 +4111,7 @@ double TextServerAdvanced::shaped_text_fit_to_width(const RID &p_shaped, double
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((space_count > 0) && ((p_jst_flags & JUSTIFICATION_WORD_BOUND) == JUSTIFICATION_WORD_BOUND)) {
|
||||
if ((space_count > 0) && p_jst_flags.has_flag(JUSTIFICATION_WORD_BOUND)) {
|
||||
double delta_width_per_space = (p_width - justification_width) / space_count;
|
||||
double adv_remain = 0;
|
||||
for (int i = start_pos; i <= end_pos; i++) {
|
||||
@ -4142,7 +4144,7 @@ double TextServerAdvanced::shaped_text_fit_to_width(const RID &p_shaped, double
|
||||
sd->fit_width_minimum_reached = true;
|
||||
}
|
||||
|
||||
if ((p_jst_flags & JUSTIFICATION_CONSTRAIN_ELLIPSIS) != JUSTIFICATION_CONSTRAIN_ELLIPSIS) {
|
||||
if (!p_jst_flags.has_flag(JUSTIFICATION_CONSTRAIN_ELLIPSIS)) {
|
||||
sd->width = justification_width;
|
||||
}
|
||||
|
||||
@ -4205,7 +4207,7 @@ double TextServerAdvanced::shaped_text_tab_align(const RID &p_shaped, const Pack
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void TextServerAdvanced::shaped_text_overrun_trim_to_width(const RID &p_shaped_line, double p_width, int64_t p_trim_flags) {
|
||||
void TextServerAdvanced::shaped_text_overrun_trim_to_width(const RID &p_shaped_line, double p_width, BitField<TextServer::TextOverrunFlag> p_trim_flags) {
|
||||
ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped_line);
|
||||
ERR_FAIL_COND_MSG(!sd, "ShapedTextDataAdvanced invalid.");
|
||||
|
||||
@ -4217,14 +4219,14 @@ void TextServerAdvanced::shaped_text_overrun_trim_to_width(const RID &p_shaped_l
|
||||
sd->text_trimmed = false;
|
||||
sd->overrun_trim_data.ellipsis_glyph_buf.clear();
|
||||
|
||||
bool add_ellipsis = (p_trim_flags & OVERRUN_ADD_ELLIPSIS) == OVERRUN_ADD_ELLIPSIS;
|
||||
bool cut_per_word = (p_trim_flags & OVERRUN_TRIM_WORD_ONLY) == OVERRUN_TRIM_WORD_ONLY;
|
||||
bool enforce_ellipsis = (p_trim_flags & OVERRUN_ENFORCE_ELLIPSIS) == OVERRUN_ENFORCE_ELLIPSIS;
|
||||
bool justification_aware = (p_trim_flags & OVERRUN_JUSTIFICATION_AWARE) == OVERRUN_JUSTIFICATION_AWARE;
|
||||
bool add_ellipsis = p_trim_flags.has_flag(OVERRUN_ADD_ELLIPSIS);
|
||||
bool cut_per_word = p_trim_flags.has_flag(OVERRUN_TRIM_WORD_ONLY);
|
||||
bool enforce_ellipsis = p_trim_flags.has_flag(OVERRUN_ENFORCE_ELLIPSIS);
|
||||
bool justification_aware = p_trim_flags.has_flag(OVERRUN_JUSTIFICATION_AWARE);
|
||||
|
||||
Glyph *sd_glyphs = sd->glyphs.ptrw();
|
||||
|
||||
if ((p_trim_flags & OVERRUN_TRIM) == OVERRUN_NO_TRIM || sd_glyphs == nullptr || p_width <= 0 || !(sd->width > p_width || enforce_ellipsis)) {
|
||||
if (p_trim_flags.has_flag(OVERRUN_TRIM) || sd_glyphs == nullptr || p_width <= 0 || !(sd->width > p_width || enforce_ellipsis)) {
|
||||
sd->overrun_trim_data.trim_pos = -1;
|
||||
sd->overrun_trim_data.ellipsis_pos = -1;
|
||||
return;
|
||||
|
@ -232,7 +232,7 @@ class TextServerAdvanced : public TextServerExtension {
|
||||
double embolden = 0.0;
|
||||
Transform2D transform;
|
||||
|
||||
uint32_t style_flags = 0;
|
||||
BitField<TextServer::FontStyle> style_flags = 0;
|
||||
String font_name;
|
||||
String style_name;
|
||||
|
||||
@ -486,8 +486,8 @@ public:
|
||||
|
||||
virtual int64_t font_get_face_count(const RID &p_font_rid) const override;
|
||||
|
||||
virtual void font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) override;
|
||||
virtual int64_t /*FontStyle*/ font_get_style(const RID &p_font_rid) const override;
|
||||
virtual void font_set_style(const RID &p_font_rid, BitField<FontStyle> p_style) override;
|
||||
virtual BitField<FontStyle> font_get_style(const RID &p_font_rid) const override;
|
||||
|
||||
virtual void font_set_style_name(const RID &p_font_rid, const String &p_name) override;
|
||||
virtual String font_get_style_name(const RID &p_font_rid) const override;
|
||||
@ -664,7 +664,7 @@ public:
|
||||
virtual RID shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const override;
|
||||
virtual RID shaped_text_get_parent(const RID &p_shaped) const override;
|
||||
|
||||
virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override;
|
||||
virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, BitField<TextServer::JustificationFlag> p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override;
|
||||
virtual double shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) override;
|
||||
|
||||
virtual bool shaped_text_shape(const RID &p_shaped) override;
|
||||
@ -676,7 +676,7 @@ public:
|
||||
virtual const Glyph *shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const override;
|
||||
virtual int64_t shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const override;
|
||||
|
||||
virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, int64_t p_trim_flags) override;
|
||||
virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, BitField<TextServer::TextOverrunFlag> p_trim_flags) override;
|
||||
|
||||
virtual bool shaped_text_is_ready(const RID &p_shaped) const override;
|
||||
|
||||
|
@ -791,13 +791,13 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontFallback *p_f
|
||||
}
|
||||
p_font_data->style_flags = 0;
|
||||
if (fd->face->style_flags & FT_STYLE_FLAG_BOLD) {
|
||||
p_font_data->style_flags |= FONT_BOLD;
|
||||
p_font_data->style_flags.set_flag(FONT_BOLD);
|
||||
}
|
||||
if (fd->face->style_flags & FT_STYLE_FLAG_ITALIC) {
|
||||
p_font_data->style_flags |= FONT_ITALIC;
|
||||
p_font_data->style_flags.set_flag(FONT_ITALIC);
|
||||
}
|
||||
if (fd->face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) {
|
||||
p_font_data->style_flags |= FONT_FIXED_WIDTH;
|
||||
p_font_data->style_flags.set_flag(FONT_FIXED_WIDTH);
|
||||
}
|
||||
// Read OpenType variations.
|
||||
p_font_data->supported_varaitions.clear();
|
||||
@ -891,7 +891,7 @@ void TextServerFallback::font_set_data_ptr(const RID &p_font_rid, const uint8_t
|
||||
fd->data_size = p_data_size;
|
||||
}
|
||||
|
||||
void TextServerFallback::font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) {
|
||||
void TextServerFallback::font_set_style(const RID &p_font_rid, BitField<FontStyle> p_style) {
|
||||
FontFallback *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND(!fd);
|
||||
|
||||
@ -964,7 +964,7 @@ int64_t TextServerFallback::font_get_face_count(const RID &p_font_rid) const {
|
||||
return face_count;
|
||||
}
|
||||
|
||||
int64_t /*FontStyle*/ TextServerFallback::font_get_style(const RID &p_font_rid) const {
|
||||
BitField<TextServer::FontStyle> TextServerFallback::font_get_style(const RID &p_font_rid) const {
|
||||
FontFallback *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND_V(!fd, 0);
|
||||
|
||||
@ -2950,7 +2950,7 @@ RID TextServerFallback::shaped_text_get_parent(const RID &p_shaped) const {
|
||||
return sd->parent;
|
||||
}
|
||||
|
||||
double TextServerFallback::shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags) {
|
||||
double TextServerFallback::shaped_text_fit_to_width(const RID &p_shaped, double p_width, BitField<JustificationFlag> p_jst_flags) {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_COND_V(!sd, 0.0);
|
||||
|
||||
@ -2965,7 +2965,7 @@ double TextServerFallback::shaped_text_fit_to_width(const RID &p_shaped, double
|
||||
int start_pos = 0;
|
||||
int end_pos = sd->glyphs.size() - 1;
|
||||
|
||||
if ((p_jst_flags & JUSTIFICATION_AFTER_LAST_TAB) == JUSTIFICATION_AFTER_LAST_TAB) {
|
||||
if (p_jst_flags.has_flag(JUSTIFICATION_AFTER_LAST_TAB)) {
|
||||
int start, end, delta;
|
||||
if (sd->para_direction == DIRECTION_LTR) {
|
||||
start = sd->glyphs.size() - 1;
|
||||
@ -2991,7 +2991,7 @@ double TextServerFallback::shaped_text_fit_to_width(const RID &p_shaped, double
|
||||
}
|
||||
|
||||
double justification_width;
|
||||
if ((p_jst_flags & JUSTIFICATION_CONSTRAIN_ELLIPSIS) == JUSTIFICATION_CONSTRAIN_ELLIPSIS) {
|
||||
if (p_jst_flags.has_flag(JUSTIFICATION_CONSTRAIN_ELLIPSIS)) {
|
||||
if (sd->overrun_trim_data.trim_pos >= 0) {
|
||||
end_pos = sd->overrun_trim_data.trim_pos;
|
||||
justification_width = sd->width_trimmed;
|
||||
@ -3002,7 +3002,7 @@ double TextServerFallback::shaped_text_fit_to_width(const RID &p_shaped, double
|
||||
justification_width = sd->width;
|
||||
}
|
||||
|
||||
if ((p_jst_flags & JUSTIFICATION_TRIM_EDGE_SPACES) == JUSTIFICATION_TRIM_EDGE_SPACES) {
|
||||
if (p_jst_flags.has_flag(JUSTIFICATION_TRIM_EDGE_SPACES)) {
|
||||
// Trim spaces.
|
||||
while ((start_pos < end_pos) && ((sd->glyphs[start_pos].flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE || (sd->glyphs[start_pos].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD || (sd->glyphs[start_pos].flags & GRAPHEME_IS_BREAK_SOFT) == GRAPHEME_IS_BREAK_SOFT)) {
|
||||
justification_width -= sd->glyphs[start_pos].advance * sd->glyphs[start_pos].repeat;
|
||||
@ -3034,7 +3034,7 @@ double TextServerFallback::shaped_text_fit_to_width(const RID &p_shaped, double
|
||||
}
|
||||
}
|
||||
|
||||
if ((space_count > 0) && ((p_jst_flags & JUSTIFICATION_WORD_BOUND) == JUSTIFICATION_WORD_BOUND)) {
|
||||
if ((space_count > 0) && p_jst_flags.has_flag(JUSTIFICATION_WORD_BOUND)) {
|
||||
double delta_width_per_space = (p_width - justification_width) / space_count;
|
||||
for (int i = start_pos; i <= end_pos; i++) {
|
||||
Glyph &gl = sd->glyphs.write[i];
|
||||
@ -3052,7 +3052,7 @@ double TextServerFallback::shaped_text_fit_to_width(const RID &p_shaped, double
|
||||
sd->fit_width_minimum_reached = true;
|
||||
}
|
||||
|
||||
if ((p_jst_flags & JUSTIFICATION_CONSTRAIN_ELLIPSIS) != JUSTIFICATION_CONSTRAIN_ELLIPSIS) {
|
||||
if (!p_jst_flags.has_flag(JUSTIFICATION_CONSTRAIN_ELLIPSIS)) {
|
||||
sd->width = justification_width;
|
||||
}
|
||||
|
||||
@ -3187,7 +3187,7 @@ bool TextServerFallback::shaped_text_update_justification_ops(const RID &p_shape
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextServerFallback::shaped_text_overrun_trim_to_width(const RID &p_shaped_line, double p_width, int64_t p_trim_flags) {
|
||||
void TextServerFallback::shaped_text_overrun_trim_to_width(const RID &p_shaped_line, double p_width, BitField<TextServer::TextOverrunFlag> p_trim_flags) {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped_line);
|
||||
ERR_FAIL_COND_MSG(!sd, "ShapedTextDataFallback invalid.");
|
||||
|
||||
@ -3199,14 +3199,14 @@ void TextServerFallback::shaped_text_overrun_trim_to_width(const RID &p_shaped_l
|
||||
sd->text_trimmed = false;
|
||||
sd->overrun_trim_data.ellipsis_glyph_buf.clear();
|
||||
|
||||
bool add_ellipsis = (p_trim_flags & OVERRUN_ADD_ELLIPSIS) == OVERRUN_ADD_ELLIPSIS;
|
||||
bool cut_per_word = (p_trim_flags & OVERRUN_TRIM_WORD_ONLY) == OVERRUN_TRIM_WORD_ONLY;
|
||||
bool enforce_ellipsis = (p_trim_flags & OVERRUN_ENFORCE_ELLIPSIS) == OVERRUN_ENFORCE_ELLIPSIS;
|
||||
bool justification_aware = (p_trim_flags & OVERRUN_JUSTIFICATION_AWARE) == OVERRUN_JUSTIFICATION_AWARE;
|
||||
bool add_ellipsis = p_trim_flags.has_flag(OVERRUN_ADD_ELLIPSIS);
|
||||
bool cut_per_word = p_trim_flags.has_flag(OVERRUN_TRIM_WORD_ONLY);
|
||||
bool enforce_ellipsis = p_trim_flags.has_flag(OVERRUN_ENFORCE_ELLIPSIS);
|
||||
bool justification_aware = p_trim_flags.has_flag(OVERRUN_JUSTIFICATION_AWARE);
|
||||
|
||||
Glyph *sd_glyphs = sd->glyphs.ptrw();
|
||||
|
||||
if ((p_trim_flags & OVERRUN_TRIM) == OVERRUN_NO_TRIM || sd_glyphs == nullptr || p_width <= 0 || !(sd->width > p_width || enforce_ellipsis)) {
|
||||
if (p_trim_flags.has_flag(OVERRUN_TRIM) || sd_glyphs == nullptr || p_width <= 0 || !(sd->width > p_width || enforce_ellipsis)) {
|
||||
sd->overrun_trim_data.trim_pos = -1;
|
||||
sd->overrun_trim_data.ellipsis_pos = -1;
|
||||
return;
|
||||
|
@ -189,7 +189,7 @@ class TextServerFallback : public TextServerExtension {
|
||||
double embolden = 0.0;
|
||||
Transform2D transform;
|
||||
|
||||
uint32_t style_flags = 0;
|
||||
BitField<TextServer::FontStyle> style_flags = 0;
|
||||
String font_name;
|
||||
String style_name;
|
||||
|
||||
@ -368,8 +368,8 @@ public:
|
||||
|
||||
virtual int64_t font_get_face_count(const RID &p_font_rid) const override;
|
||||
|
||||
virtual void font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) override;
|
||||
virtual int64_t /*FontStyle*/ font_get_style(const RID &p_font_rid) const override;
|
||||
virtual void font_set_style(const RID &p_font_rid, BitField<FontStyle> p_style) override;
|
||||
virtual BitField<FontStyle> font_get_style(const RID &p_font_rid) const override;
|
||||
|
||||
virtual void font_set_style_name(const RID &p_font_rid, const String &p_name) override;
|
||||
virtual String font_get_style_name(const RID &p_font_rid) const override;
|
||||
@ -545,7 +545,7 @@ public:
|
||||
virtual RID shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const override;
|
||||
virtual RID shaped_text_get_parent(const RID &p_shaped) const override;
|
||||
|
||||
virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override;
|
||||
virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, BitField<TextServer::JustificationFlag> p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override;
|
||||
virtual double shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) override;
|
||||
|
||||
virtual bool shaped_text_shape(const RID &p_shaped) override;
|
||||
@ -557,7 +557,7 @@ public:
|
||||
virtual const Glyph *shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const override;
|
||||
virtual int64_t shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const override;
|
||||
|
||||
virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, int64_t p_trim_flags) override;
|
||||
virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, BitField<TextServer::TextOverrunFlag> p_trim_flags) override;
|
||||
|
||||
virtual bool shaped_text_is_ready(const RID &p_shaped) const override;
|
||||
|
||||
|
@ -452,10 +452,10 @@ void Label3D::_shape() {
|
||||
}
|
||||
lines_rid.clear();
|
||||
|
||||
uint16_t autowrap_flags = TextServer::BREAK_MANDATORY;
|
||||
BitField<TextServer::LineBreakFlag> autowrap_flags = TextServer::BREAK_MANDATORY;
|
||||
switch (autowrap_mode) {
|
||||
case TextServer::AUTOWRAP_WORD_SMART:
|
||||
autowrap_flags = TextServer::BREAK_WORD_BOUND_ADAPTIVE | TextServer::BREAK_MANDATORY;
|
||||
autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_ADAPTIVE | TextServer::BREAK_MANDATORY;
|
||||
break;
|
||||
case TextServer::AUTOWRAP_WORD:
|
||||
autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_MANDATORY;
|
||||
|
@ -526,7 +526,7 @@ void Button::_bind_methods() {
|
||||
|
||||
Button::Button(const String &p_text) {
|
||||
text_buf.instantiate();
|
||||
text_buf->set_flags(TextServer::BREAK_MANDATORY);
|
||||
text_buf->set_break_flags(TextServer::BREAK_MANDATORY);
|
||||
set_mouse_filter(MOUSE_FILTER_STOP);
|
||||
|
||||
set_text(p_text);
|
||||
|
@ -45,9 +45,9 @@ void ItemList::_shape(int p_idx) {
|
||||
}
|
||||
item.text_buf->add_string(item.text, get_theme_font(SNAME("font")), get_theme_font_size(SNAME("font_size")), item.language);
|
||||
if (icon_mode == ICON_MODE_TOP && max_text_lines > 0) {
|
||||
item.text_buf->set_flags(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::BREAK_GRAPHEME_BOUND);
|
||||
item.text_buf->set_break_flags(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::BREAK_GRAPHEME_BOUND);
|
||||
} else {
|
||||
item.text_buf->set_flags(TextServer::BREAK_NONE);
|
||||
item.text_buf->set_break_flags(TextServer::BREAK_NONE);
|
||||
}
|
||||
item.text_buf->set_text_overrun_behavior(text_overrun_behavior);
|
||||
item.text_buf->set_max_lines_visible(max_text_lines);
|
||||
@ -470,10 +470,10 @@ void ItemList::set_max_text_lines(int p_lines) {
|
||||
max_text_lines = p_lines;
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if (icon_mode == ICON_MODE_TOP && max_text_lines > 0) {
|
||||
items.write[i].text_buf->set_flags(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::BREAK_GRAPHEME_BOUND);
|
||||
items.write[i].text_buf->set_break_flags(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::BREAK_GRAPHEME_BOUND);
|
||||
items.write[i].text_buf->set_max_lines_visible(p_lines);
|
||||
} else {
|
||||
items.write[i].text_buf->set_flags(TextServer::BREAK_NONE);
|
||||
items.write[i].text_buf->set_break_flags(TextServer::BREAK_NONE);
|
||||
}
|
||||
}
|
||||
shape_changed = true;
|
||||
@ -511,9 +511,9 @@ void ItemList::set_icon_mode(IconMode p_mode) {
|
||||
icon_mode = p_mode;
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if (icon_mode == ICON_MODE_TOP && max_text_lines > 0) {
|
||||
items.write[i].text_buf->set_flags(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::BREAK_GRAPHEME_BOUND);
|
||||
items.write[i].text_buf->set_break_flags(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::BREAK_GRAPHEME_BOUND);
|
||||
} else {
|
||||
items.write[i].text_buf->set_flags(TextServer::BREAK_NONE);
|
||||
items.write[i].text_buf->set_break_flags(TextServer::BREAK_NONE);
|
||||
}
|
||||
}
|
||||
shape_changed = true;
|
||||
|
@ -121,10 +121,10 @@ void Label::_shape() {
|
||||
}
|
||||
lines_rid.clear();
|
||||
|
||||
uint16_t autowrap_flags = TextServer::BREAK_MANDATORY;
|
||||
BitField<TextServer::LineBreakFlag> autowrap_flags = TextServer::BREAK_MANDATORY;
|
||||
switch (autowrap_mode) {
|
||||
case TextServer::AUTOWRAP_WORD_SMART:
|
||||
autowrap_flags = TextServer::BREAK_WORD_BOUND_ADAPTIVE | TextServer::BREAK_MANDATORY;
|
||||
autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_ADAPTIVE | TextServer::BREAK_MANDATORY;
|
||||
break;
|
||||
case TextServer::AUTOWRAP_WORD:
|
||||
autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_MANDATORY;
|
||||
@ -158,23 +158,23 @@ void Label::_shape() {
|
||||
}
|
||||
|
||||
if (lines_dirty) {
|
||||
uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIM;
|
||||
BitField<TextServer::TextOverrunFlag> overrun_flags = TextServer::OVERRUN_NO_TRIM;
|
||||
switch (overrun_behavior) {
|
||||
case TextServer::OVERRUN_TRIM_WORD_ELLIPSIS:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY;
|
||||
overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM_WORD_ONLY);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_ADD_ELLIPSIS);
|
||||
break;
|
||||
case TextServer::OVERRUN_TRIM_ELLIPSIS:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_ADD_ELLIPSIS);
|
||||
break;
|
||||
case TextServer::OVERRUN_TRIM_WORD:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM_WORD_ONLY);
|
||||
break;
|
||||
case TextServer::OVERRUN_TRIM_CHAR:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
break;
|
||||
case TextServer::OVERRUN_NO_TRIMMING:
|
||||
break;
|
||||
@ -186,7 +186,7 @@ void Label::_shape() {
|
||||
int visible_lines = get_visible_line_count();
|
||||
bool lines_hidden = visible_lines > 0 && visible_lines < lines_rid.size();
|
||||
if (lines_hidden) {
|
||||
overrun_flags |= TextServer::OVERRUN_ENFORCE_ELLIPSIS;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_ENFORCE_ELLIPSIS);
|
||||
}
|
||||
if (horizontal_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
for (int i = 0; i < lines_rid.size(); i++) {
|
||||
@ -204,7 +204,7 @@ void Label::_shape() {
|
||||
for (int i = 0; i < lines_rid.size(); i++) {
|
||||
if (horizontal_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
TS->shaped_text_fit_to_width(lines_rid[i], width);
|
||||
overrun_flags |= TextServer::OVERRUN_JUSTIFICATION_AWARE;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_JUSTIFICATION_AWARE);
|
||||
TS->shaped_text_overrun_trim_to_width(lines_rid[i], width, overrun_flags);
|
||||
TS->shaped_text_fit_to_width(lines_rid[i], width, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_CONSTRAIN_ELLIPSIS);
|
||||
} else {
|
||||
|
@ -431,10 +431,10 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
|
||||
Line &l = p_frame->lines[p_line];
|
||||
MutexLock lock(l.text_buf->get_mutex());
|
||||
|
||||
uint16_t autowrap_flags = TextServer::BREAK_MANDATORY;
|
||||
BitField<TextServer::LineBreakFlag> autowrap_flags = TextServer::BREAK_MANDATORY;
|
||||
switch (autowrap_mode) {
|
||||
case TextServer::AUTOWRAP_WORD_SMART:
|
||||
autowrap_flags = TextServer::BREAK_WORD_BOUND_ADAPTIVE | TextServer::BREAK_MANDATORY;
|
||||
autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_ADAPTIVE | TextServer::BREAK_MANDATORY;
|
||||
break;
|
||||
case TextServer::AUTOWRAP_WORD:
|
||||
autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_MANDATORY;
|
||||
@ -448,7 +448,8 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
|
||||
|
||||
// Clear cache.
|
||||
l.text_buf->clear();
|
||||
l.text_buf->set_flags(autowrap_flags | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_TRIM_EDGE_SPACES);
|
||||
l.text_buf->set_break_flags(autowrap_flags);
|
||||
l.text_buf->set_justification_flags(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_TRIM_EDGE_SPACES);
|
||||
l.char_offset = *r_char_offset;
|
||||
l.char_count = 0;
|
||||
|
||||
|
@ -658,32 +658,32 @@ void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Tex
|
||||
RenderingServer::get_singleton()->canvas_item_add_multimesh(canvas_item, p_multimesh->get_rid(), texture_rid);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, const Color &p_modulate, uint16_t p_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
void CanvasItem::draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, const Color &p_modulate, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
ERR_FAIL_COND(p_font.is_null());
|
||||
|
||||
p_font->draw_string(canvas_item, p_pos, p_text, p_alignment, p_width, p_font_size, p_modulate, p_flags, p_direction, p_orientation);
|
||||
p_font->draw_string(canvas_item, p_pos, p_text, p_alignment, p_width, p_font_size, p_modulate, p_jst_flags, p_direction, p_orientation);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_multiline_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, const Color &p_modulate, uint16_t p_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
void CanvasItem::draw_multiline_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, const Color &p_modulate, BitField<TextServer::LineBreakFlag> p_brk_flags, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
ERR_FAIL_COND(p_font.is_null());
|
||||
|
||||
p_font->draw_multiline_string(canvas_item, p_pos, p_text, p_alignment, p_width, p_font_size, p_max_lines, p_modulate, p_flags, p_direction, p_orientation);
|
||||
p_font->draw_multiline_string(canvas_item, p_pos, p_text, p_alignment, p_width, p_font_size, p_max_lines, p_modulate, p_brk_flags, p_jst_flags, p_direction, p_orientation);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_string_outline(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_size, const Color &p_modulate, uint16_t p_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
void CanvasItem::draw_string_outline(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_size, const Color &p_modulate, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
ERR_FAIL_COND(p_font.is_null());
|
||||
|
||||
p_font->draw_string_outline(canvas_item, p_pos, p_text, p_alignment, p_width, p_font_size, p_size, p_modulate, p_flags, p_direction, p_orientation);
|
||||
p_font->draw_string_outline(canvas_item, p_pos, p_text, p_alignment, p_width, p_font_size, p_size, p_modulate, p_jst_flags, p_direction, p_orientation);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_multiline_string_outline(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, int p_size, const Color &p_modulate, uint16_t p_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
void CanvasItem::draw_multiline_string_outline(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, int p_size, const Color &p_modulate, BitField<TextServer::LineBreakFlag> p_brk_flags, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
ERR_FAIL_COND(p_font.is_null());
|
||||
|
||||
p_font->draw_multiline_string_outline(canvas_item, p_pos, p_text, p_alignment, p_width, p_font_size, p_max_lines, p_size, p_modulate, p_flags, p_direction, p_orientation);
|
||||
p_font->draw_multiline_string_outline(canvas_item, p_pos, p_text, p_alignment, p_width, p_font_size, p_max_lines, p_size, p_modulate, p_brk_flags, p_jst_flags, p_direction, p_orientation);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, int p_font_size, const Color &p_modulate) const {
|
||||
@ -924,10 +924,10 @@ 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_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_string", "font", "pos", "text", "alignment", "width", "font_size", "modulate", "flags", "direction", "orientation"), &CanvasItem::draw_string, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_multiline_string", "font", "pos", "text", "alignment", "width", "font_size", "max_lines", "modulate", "flags", "direction", "orientation"), &CanvasItem::draw_multiline_string, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(-1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_string_outline", "font", "pos", "text", "alignment", "width", "font_size", "size", "modulate", "flags", "direction", "orientation"), &CanvasItem::draw_string_outline, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_multiline_string_outline", "font", "pos", "text", "alignment", "width", "font_size", "max_lines", "size", "modulate", "flags", "direction", "orientation"), &CanvasItem::draw_multiline_string_outline, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(-1), DEFVAL(1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_string", "font", "pos", "text", "alignment", "width", "font_size", "modulate", "jst_flags", "direction", "orientation"), &CanvasItem::draw_string, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_multiline_string", "font", "pos", "text", "alignment", "width", "font_size", "max_lines", "modulate", "brk_flags", "jst_flags", "direction", "orientation"), &CanvasItem::draw_multiline_string, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(-1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_string_outline", "font", "pos", "text", "alignment", "width", "font_size", "size", "modulate", "jst_flags", "direction", "orientation"), &CanvasItem::draw_string_outline, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_multiline_string_outline", "font", "pos", "text", "alignment", "width", "font_size", "max_lines", "size", "modulate", "brk_flags", "jst_flags", "direction", "orientation"), &CanvasItem::draw_multiline_string_outline, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(-1), DEFVAL(1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_char", "font", "pos", "char", "font_size", "modulate"), &CanvasItem::draw_char, DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(Color(1.0, 1.0, 1.0)));
|
||||
ClassDB::bind_method(D_METHOD("draw_char_outline", "font", "pos", "char", "font_size", "size", "modulate"), &CanvasItem::draw_char_outline, DEFVAL(Font::DEFAULT_FONT_SIZE), DEFVAL(-1), DEFVAL(Color(1.0, 1.0, 1.0)));
|
||||
ClassDB::bind_method(D_METHOD("draw_mesh", "mesh", "texture", "transform", "modulate"), &CanvasItem::draw_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1, 1)));
|
||||
|
@ -235,11 +235,11 @@ 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_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, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1.0, 1.0, 1.0), uint16_t p_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
void draw_multiline_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_max_lines = -1, const Color &p_modulate = Color(1.0, 1.0, 1.0), uint16_t p_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
void draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
void draw_multiline_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_max_lines = -1, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::LineBreakFlag> p_brk_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND, BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
|
||||
void draw_string_outline(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_size = 1, int p_font_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1.0, 1.0, 1.0), uint16_t p_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
void draw_multiline_string_outline(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_max_lines = -1, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0), uint16_t p_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
void draw_string_outline(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_size = 1, int p_font_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
void draw_multiline_string_outline(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_max_lines = -1, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::LineBreakFlag> p_brk_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND, BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
|
||||
void draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, int p_font_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1.0, 1.0, 1.0)) const;
|
||||
void draw_char_outline(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0)) const;
|
||||
|
@ -69,14 +69,14 @@ void Font::_bind_methods() {
|
||||
// Drawing string.
|
||||
ClassDB::bind_method(D_METHOD("set_cache_capacity", "single_line", "multi_line"), &Font::set_cache_capacity);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_string_size", "text", "alignment", "width", "font_size", "flags", "direction", "orientation"), &Font::get_string_size, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("get_multiline_string_size", "text", "alignment", "width", "font_size", "max_lines", "flags", "direction", "orientation"), &Font::get_multiline_string_size, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(-1), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("get_string_size", "text", "alignment", "width", "font_size", "jst_flags", "direction", "orientation"), &Font::get_string_size, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("get_multiline_string_size", "text", "alignment", "width", "font_size", "max_lines", "brk_flags", "jst_flags", "direction", "orientation"), &Font::get_multiline_string_size, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(-1), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("draw_string", "canvas_item", "pos", "text", "alignment", "width", "font_size", "modulate", "flags", "direction", "orientation"), &Font::draw_string, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_multiline_string", "canvas_item", "pos", "text", "alignment", "width", "font_size", "max_lines", "modulate", "flags", "direction", "orientation"), &Font::draw_multiline_string, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(-1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_string", "canvas_item", "pos", "text", "alignment", "width", "font_size", "modulate", "jst_flags", "direction", "orientation"), &Font::draw_string, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_multiline_string", "canvas_item", "pos", "text", "alignment", "width", "font_size", "max_lines", "modulate", "brk_flags", "jst_flags", "direction", "orientation"), &Font::draw_multiline_string, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(-1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("draw_string_outline", "canvas_item", "pos", "text", "alignment", "width", "font_size", "size", "modulate", "flags", "direction", "orientation"), &Font::draw_string_outline, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_multiline_string_outline", "canvas_item", "pos", "text", "alignment", "width", "font_size", "max_lines", "size", "modulate", "flags", "direction", "orientation"), &Font::draw_multiline_string_outline, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(-1), DEFVAL(1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_string_outline", "canvas_item", "pos", "text", "alignment", "width", "font_size", "size", "modulate", "jst_flags", "direction", "orientation"), &Font::draw_string_outline, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
ClassDB::bind_method(D_METHOD("draw_multiline_string_outline", "canvas_item", "pos", "text", "alignment", "width", "font_size", "max_lines", "size", "modulate", "brk_flags", "jst_flags", "direction", "orientation"), &Font::draw_multiline_string_outline, DEFVAL(HORIZONTAL_ALIGNMENT_LEFT), DEFVAL(-1), DEFVAL(DEFAULT_FONT_SIZE), DEFVAL(-1), DEFVAL(1), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND), DEFVAL(TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND), DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(TextServer::ORIENTATION_HORIZONTAL));
|
||||
|
||||
// Drawing char.
|
||||
ClassDB::bind_method(D_METHOD("get_char_size", "char"), &Font::get_char_size);
|
||||
@ -239,7 +239,7 @@ String Font::get_font_style_name() const {
|
||||
return TS->font_get_style_name(_get_rid());
|
||||
}
|
||||
|
||||
uint32_t Font::get_font_style() const {
|
||||
BitField<TextServer::FontStyle> Font::get_font_style() const {
|
||||
return TS->font_get_style(_get_rid());
|
||||
}
|
||||
|
||||
@ -253,15 +253,15 @@ void Font::set_cache_capacity(int p_single_line, int p_multi_line) {
|
||||
cache_wrap.set_capacity(p_multi_line);
|
||||
}
|
||||
|
||||
Size2 Font::get_string_size(const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, uint16_t p_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
Size2 Font::get_string_size(const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
uint64_t hash = p_text.hash64();
|
||||
hash = hash_djb2_one_64(p_font_size, hash);
|
||||
if (p_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
hash = hash_djb2_one_64(hash_murmur3_one_float(p_width), hash);
|
||||
hash = hash_djb2_one_64(p_flags, hash);
|
||||
hash = hash_djb2_one_64(p_direction, hash);
|
||||
hash = hash_djb2_one_64(p_orientation, hash);
|
||||
hash = hash_djb2_one_64(p_jst_flags.operator uint32_t(), hash);
|
||||
}
|
||||
hash = hash_djb2_one_64(p_direction, hash);
|
||||
hash = hash_djb2_one_64(p_orientation, hash);
|
||||
|
||||
Ref<TextLine> buffer;
|
||||
if (cache.has(hash)) {
|
||||
@ -271,16 +271,22 @@ Size2 Font::get_string_size(const String &p_text, HorizontalAlignment p_alignmen
|
||||
buffer->set_direction(p_direction);
|
||||
buffer->set_orientation(p_orientation);
|
||||
buffer->add_string(p_text, Ref<Font>(this), p_font_size);
|
||||
if (p_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
buffer->set_horizontal_alignment(p_alignment);
|
||||
buffer->set_width(p_width);
|
||||
buffer->set_flags(p_jst_flags);
|
||||
}
|
||||
cache.insert(hash, buffer);
|
||||
}
|
||||
return buffer->get_size();
|
||||
}
|
||||
|
||||
Size2 Font::get_multiline_string_size(const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, uint16_t p_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
Size2 Font::get_multiline_string_size(const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, BitField<TextServer::LineBreakFlag> p_brk_flags, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
uint64_t hash = p_text.hash64();
|
||||
hash = hash_djb2_one_64(p_font_size, hash);
|
||||
hash = hash_djb2_one_64(hash_murmur3_one_float(p_width), hash);
|
||||
hash = hash_djb2_one_64(p_flags, hash);
|
||||
hash = hash_djb2_one_64(p_brk_flags.operator uint32_t(), hash);
|
||||
hash = hash_djb2_one_64(p_jst_flags.operator uint32_t(), hash);
|
||||
hash = hash_djb2_one_64(p_direction, hash);
|
||||
hash = hash_djb2_one_64(p_orientation, hash);
|
||||
|
||||
@ -293,7 +299,8 @@ Size2 Font::get_multiline_string_size(const String &p_text, HorizontalAlignment
|
||||
lines_buffer->set_orientation(p_orientation);
|
||||
lines_buffer->add_string(p_text, Ref<Font>(this), p_font_size);
|
||||
lines_buffer->set_width(p_width);
|
||||
lines_buffer->set_flags(p_flags);
|
||||
lines_buffer->set_break_flags(p_brk_flags);
|
||||
lines_buffer->set_justification_flags(p_jst_flags);
|
||||
cache_wrap.insert(hash, lines_buffer);
|
||||
}
|
||||
|
||||
@ -303,13 +310,15 @@ Size2 Font::get_multiline_string_size(const String &p_text, HorizontalAlignment
|
||||
return lines_buffer->get_size();
|
||||
}
|
||||
|
||||
void Font::draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, const Color &p_modulate, uint16_t p_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
void Font::draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, const Color &p_modulate, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
uint64_t hash = p_text.hash64();
|
||||
hash = hash_djb2_one_64(p_font_size, hash);
|
||||
if (p_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
hash = hash_djb2_one_64(hash_murmur3_one_float(p_width), hash);
|
||||
hash = hash_djb2_one_64(p_flags, hash);
|
||||
hash = hash_djb2_one_64(p_jst_flags.operator uint32_t(), hash);
|
||||
}
|
||||
hash = hash_djb2_one_64(p_direction, hash);
|
||||
hash = hash_djb2_one_64(p_orientation, hash);
|
||||
|
||||
Ref<TextLine> buffer;
|
||||
if (cache.has(hash)) {
|
||||
@ -331,16 +340,19 @@ void Font::draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_t
|
||||
|
||||
buffer->set_width(p_width);
|
||||
buffer->set_horizontal_alignment(p_alignment);
|
||||
buffer->set_flags(p_flags);
|
||||
if (p_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
buffer->set_flags(p_jst_flags);
|
||||
}
|
||||
|
||||
buffer->draw(p_canvas_item, ofs, p_modulate);
|
||||
}
|
||||
|
||||
void Font::draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, const Color &p_modulate, uint16_t p_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
void Font::draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, const Color &p_modulate, BitField<TextServer::LineBreakFlag> p_brk_flags, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
uint64_t hash = p_text.hash64();
|
||||
hash = hash_djb2_one_64(p_font_size, hash);
|
||||
hash = hash_djb2_one_64(hash_murmur3_one_float(p_width), hash);
|
||||
hash = hash_djb2_one_64(p_flags, hash);
|
||||
hash = hash_djb2_one_64(p_brk_flags.operator uint32_t(), hash);
|
||||
hash = hash_djb2_one_64(p_jst_flags.operator uint32_t(), hash);
|
||||
hash = hash_djb2_one_64(p_direction, hash);
|
||||
hash = hash_djb2_one_64(p_orientation, hash);
|
||||
|
||||
@ -353,7 +365,8 @@ void Font::draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const S
|
||||
lines_buffer->set_orientation(p_orientation);
|
||||
lines_buffer->add_string(p_text, Ref<Font>(this), p_font_size);
|
||||
lines_buffer->set_width(p_width);
|
||||
lines_buffer->set_flags(p_flags);
|
||||
lines_buffer->set_break_flags(p_brk_flags);
|
||||
lines_buffer->set_justification_flags(p_jst_flags);
|
||||
cache_wrap.insert(hash, lines_buffer);
|
||||
}
|
||||
|
||||
@ -370,13 +383,15 @@ void Font::draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const S
|
||||
lines_buffer->draw(p_canvas_item, ofs, p_modulate);
|
||||
}
|
||||
|
||||
void Font::draw_string_outline(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_size, const Color &p_modulate, uint16_t p_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
void Font::draw_string_outline(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_size, const Color &p_modulate, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
uint64_t hash = p_text.hash64();
|
||||
hash = hash_djb2_one_64(p_font_size, hash);
|
||||
if (p_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
hash = hash_djb2_one_64(hash_murmur3_one_float(p_width), hash);
|
||||
hash = hash_djb2_one_64(p_flags, hash);
|
||||
hash = hash_djb2_one_64(p_jst_flags.operator uint32_t(), hash);
|
||||
}
|
||||
hash = hash_djb2_one_64(p_direction, hash);
|
||||
hash = hash_djb2_one_64(p_orientation, hash);
|
||||
|
||||
Ref<TextLine> buffer;
|
||||
if (cache.has(hash)) {
|
||||
@ -398,16 +413,19 @@ void Font::draw_string_outline(RID p_canvas_item, const Point2 &p_pos, const Str
|
||||
|
||||
buffer->set_width(p_width);
|
||||
buffer->set_horizontal_alignment(p_alignment);
|
||||
buffer->set_flags(p_flags);
|
||||
if (p_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
buffer->set_flags(p_jst_flags);
|
||||
}
|
||||
|
||||
buffer->draw_outline(p_canvas_item, ofs, p_size, p_modulate);
|
||||
}
|
||||
|
||||
void Font::draw_multiline_string_outline(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, int p_size, const Color &p_modulate, uint16_t p_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
void Font::draw_multiline_string_outline(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment, float p_width, int p_font_size, int p_max_lines, int p_size, const Color &p_modulate, BitField<TextServer::LineBreakFlag> p_brk_flags, BitField<TextServer::JustificationFlag> p_jst_flags, TextServer::Direction p_direction, TextServer::Orientation p_orientation) const {
|
||||
uint64_t hash = p_text.hash64();
|
||||
hash = hash_djb2_one_64(p_font_size, hash);
|
||||
hash = hash_djb2_one_64(hash_murmur3_one_float(p_width), hash);
|
||||
hash = hash_djb2_one_64(p_flags, hash);
|
||||
hash = hash_djb2_one_64(p_brk_flags.operator uint32_t(), hash);
|
||||
hash = hash_djb2_one_64(p_jst_flags.operator uint32_t(), hash);
|
||||
hash = hash_djb2_one_64(p_direction, hash);
|
||||
hash = hash_djb2_one_64(p_orientation, hash);
|
||||
|
||||
@ -420,7 +438,8 @@ void Font::draw_multiline_string_outline(RID p_canvas_item, const Point2 &p_pos,
|
||||
lines_buffer->set_orientation(p_orientation);
|
||||
lines_buffer->add_string(p_text, Ref<Font>(this), p_font_size);
|
||||
lines_buffer->set_width(p_width);
|
||||
lines_buffer->set_flags(p_flags);
|
||||
lines_buffer->set_break_flags(p_brk_flags);
|
||||
lines_buffer->set_justification_flags(p_jst_flags);
|
||||
cache_wrap.insert(hash, lines_buffer);
|
||||
}
|
||||
|
||||
@ -980,7 +999,7 @@ void FontFile::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_antialiased", "is_antialiased");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "font_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_font_name", "get_font_name");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "style_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_font_style_name", "get_font_style_name");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "font_style", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_font_style", "get_font_style");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "font_style", PROPERTY_HINT_FLAGS, "Bold,Italic,Fixed Size", PROPERTY_USAGE_STORAGE), "set_font_style", "get_font_style");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One half of a pixel,One quarter of a pixel", PROPERTY_USAGE_STORAGE), "set_subpixel_positioning", "get_subpixel_positioning");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_multichannel_signed_distance_field", "is_multichannel_signed_distance_field");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_msdf_pixel_range", "get_msdf_pixel_range");
|
||||
@ -1332,7 +1351,7 @@ Error FontFile::load_bitmap_font(const String &p_path) {
|
||||
int height = 0;
|
||||
int ascent = 0;
|
||||
int outline = 0;
|
||||
uint32_t st_flags = 0;
|
||||
BitField<TextServer::FontStyle> st_flags = 0;
|
||||
String font_name;
|
||||
|
||||
bool packed = false;
|
||||
@ -1358,10 +1377,10 @@ Error FontFile::load_bitmap_font(const String &p_path) {
|
||||
uint8_t flags = f->get_8();
|
||||
ERR_FAIL_COND_V_MSG(flags & 0x02, ERR_CANT_CREATE, RTR("Non-unicode version of BMFont is not supported."));
|
||||
if (flags & (1 << 3)) {
|
||||
st_flags |= TextServer::FONT_BOLD;
|
||||
st_flags.set_flag(TextServer::FONT_BOLD);
|
||||
}
|
||||
if (flags & (1 << 2)) {
|
||||
st_flags |= TextServer::FONT_ITALIC;
|
||||
st_flags.set_flag(TextServer::FONT_ITALIC);
|
||||
}
|
||||
f->get_8(); // non-unicode charset, skip
|
||||
f->get_16(); // stretch_h, skip
|
||||
@ -1588,12 +1607,12 @@ Error FontFile::load_bitmap_font(const String &p_path) {
|
||||
}
|
||||
if (keys.has("bold")) {
|
||||
if (keys["bold"].to_int()) {
|
||||
st_flags |= TextServer::FONT_BOLD;
|
||||
st_flags.set_flag(TextServer::FONT_BOLD);
|
||||
}
|
||||
}
|
||||
if (keys.has("italic")) {
|
||||
if (keys["italic"].to_int()) {
|
||||
st_flags |= TextServer::FONT_ITALIC;
|
||||
st_flags.set_flag(TextServer::FONT_ITALIC);
|
||||
}
|
||||
}
|
||||
if (keys.has("face")) {
|
||||
@ -1840,7 +1859,7 @@ void FontFile::set_font_style_name(const String &p_name) {
|
||||
TS->font_set_style_name(cache[0], p_name);
|
||||
}
|
||||
|
||||
void FontFile::set_font_style(uint32_t p_style) {
|
||||
void FontFile::set_font_style(BitField<TextServer::FontStyle> p_style) {
|
||||
_ensure_rid(0);
|
||||
TS->font_set_style(cache[0], p_style);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
|
||||
virtual String get_font_name() const;
|
||||
virtual String get_font_style_name() const;
|
||||
virtual uint32_t get_font_style() const;
|
||||
virtual BitField<TextServer::FontStyle> get_font_style() const;
|
||||
|
||||
virtual int get_spacing(TextServer::SpacingType p_spacing) const { return 0; };
|
||||
virtual Dictionary get_opentype_features() const;
|
||||
@ -99,14 +99,14 @@ public:
|
||||
// Drawing string.
|
||||
virtual void set_cache_capacity(int p_single_line, int p_multi_line);
|
||||
|
||||
virtual Size2 get_string_size(const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, uint16_t p_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
virtual Size2 get_multiline_string_size(const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, int p_max_lines = -1, uint16_t p_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
virtual Size2 get_string_size(const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
virtual Size2 get_multiline_string_size(const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, int p_max_lines = -1, BitField<TextServer::LineBreakFlag> p_brk_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND, BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
|
||||
virtual void draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1.0, 1.0, 1.0), uint16_t p_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
virtual void draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, int p_max_lines = -1, const Color &p_modulate = Color(1.0, 1.0, 1.0), uint16_t p_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
virtual void draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
virtual void draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, int p_max_lines = -1, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::LineBreakFlag> p_brk_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND, BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
|
||||
virtual void draw_string_outline(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0), uint16_t p_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
virtual void draw_multiline_string_outline(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, int p_max_lines = -1, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0), uint16_t p_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
virtual void draw_string_outline(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
virtual void draw_multiline_string_outline(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = DEFAULT_FONT_SIZE, int p_max_lines = -1, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::LineBreakFlag> p_brk_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND, BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const;
|
||||
|
||||
// Drawing char.
|
||||
virtual Size2 get_char_size(char32_t p_char, int p_font_size = DEFAULT_FONT_SIZE) const;
|
||||
@ -190,7 +190,7 @@ public:
|
||||
// Common properties.
|
||||
virtual void set_font_name(const String &p_name);
|
||||
virtual void set_font_style_name(const String &p_name);
|
||||
virtual void set_font_style(uint32_t p_style);
|
||||
virtual void set_font_style(BitField<TextServer::FontStyle> p_style);
|
||||
|
||||
virtual void set_antialiased(bool p_antialiased);
|
||||
virtual bool is_antialiased() const;
|
||||
|
@ -74,7 +74,7 @@ void TextLine::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_flags", "flags"), &TextLine::set_flags);
|
||||
ClassDB::bind_method(D_METHOD("get_flags"), &TextLine::get_flags);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Kashida Justify,Word Justify,Trim Edge Spaces After Justify,Justify Only After Last Tab"), "set_flags", "get_flags");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Kashida Justification,Word Justication,Trim Edge Spaces After Justication,Justify Only After Last Tab,Constrain Ellipsis"), "set_flags", "get_flags");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_text_overrun_behavior", "overrun_behavior"), &TextLine::set_text_overrun_behavior);
|
||||
ClassDB::bind_method(D_METHOD("get_text_overrun_behavior"), &TextLine::get_text_overrun_behavior);
|
||||
@ -106,24 +106,24 @@ void TextLine::_shape() {
|
||||
TS->shaped_text_tab_align(rid, tab_stops);
|
||||
}
|
||||
|
||||
uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIM;
|
||||
BitField<TextServer::TextOverrunFlag> overrun_flags = TextServer::OVERRUN_NO_TRIM;
|
||||
if (overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) {
|
||||
switch (overrun_behavior) {
|
||||
case TextServer::OVERRUN_TRIM_WORD_ELLIPSIS:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY;
|
||||
overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM_WORD_ONLY);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_ADD_ELLIPSIS);
|
||||
break;
|
||||
case TextServer::OVERRUN_TRIM_ELLIPSIS:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_ADD_ELLIPSIS);
|
||||
break;
|
||||
case TextServer::OVERRUN_TRIM_WORD:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM_WORD_ONLY);
|
||||
break;
|
||||
case TextServer::OVERRUN_TRIM_CHAR:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
break;
|
||||
case TextServer::OVERRUN_NO_TRIMMING:
|
||||
break;
|
||||
@ -131,7 +131,7 @@ void TextLine::_shape() {
|
||||
|
||||
if (alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
TS->shaped_text_fit_to_width(rid, width, flags);
|
||||
overrun_flags |= TextServer::OVERRUN_JUSTIFICATION_AWARE;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_JUSTIFICATION_AWARE);
|
||||
TS->shaped_text_overrun_trim_to_width(rid, width, overrun_flags);
|
||||
} else {
|
||||
TS->shaped_text_overrun_trim_to_width(rid, width, overrun_flags);
|
||||
@ -241,14 +241,14 @@ void TextLine::tab_align(const Vector<float> &p_tab_stops) {
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
void TextLine::set_flags(uint16_t p_flags) {
|
||||
void TextLine::set_flags(BitField<TextServer::JustificationFlag> p_flags) {
|
||||
if (flags != p_flags) {
|
||||
flags = p_flags;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t TextLine::get_flags() const {
|
||||
BitField<TextServer::JustificationFlag> TextLine::get_flags() const {
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ private:
|
||||
bool dirty = true;
|
||||
|
||||
float width = -1.0;
|
||||
uint16_t flags = TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA;
|
||||
BitField<TextServer::JustificationFlag> flags = TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA;
|
||||
HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT;
|
||||
TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_TRIM_ELLIPSIS;
|
||||
|
||||
@ -84,8 +84,8 @@ public:
|
||||
|
||||
void tab_align(const Vector<float> &p_tab_stops);
|
||||
|
||||
void set_flags(uint16_t p_flags);
|
||||
uint16_t get_flags() const;
|
||||
void set_flags(BitField<TextServer::JustificationFlag> p_flags);
|
||||
BitField<TextServer::JustificationFlag> get_flags() const;
|
||||
|
||||
void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior);
|
||||
TextServer::OverrunBehavior get_text_overrun_behavior() const;
|
||||
|
@ -74,10 +74,15 @@ void TextParagraph::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("tab_align", "tab_stops"), &TextParagraph::tab_align);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_flags", "flags"), &TextParagraph::set_flags);
|
||||
ClassDB::bind_method(D_METHOD("get_flags"), &TextParagraph::get_flags);
|
||||
ClassDB::bind_method(D_METHOD("set_break_flags", "flags"), &TextParagraph::set_break_flags);
|
||||
ClassDB::bind_method(D_METHOD("get_break_flags"), &TextParagraph::get_break_flags);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Kashida Justify,Word Justify,Trim Edge Spaces After Justify,Justify Only After Last Tab,Break Mandatory,Break Words,Break Graphemes"), "set_flags", "get_flags");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "break_flags", PROPERTY_HINT_FLAGS, "Mandatory,Word Bouns,Grapheme Bound,Adaptive"), "set_break_flags", "get_break_flags");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_justification_flags", "flags"), &TextParagraph::set_justification_flags);
|
||||
ClassDB::bind_method(D_METHOD("get_justification_flags"), &TextParagraph::get_justification_flags);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "justification_flags", PROPERTY_HINT_FLAGS, "Kashida Justification,Word Justication,Trim Edge Spaces After Justication,Justify Only After Last Tab,Constrain Ellipsis"), "set_justification_flags", "get_justification_flags");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_text_overrun_behavior", "overrun_behavior"), &TextParagraph::set_text_overrun_behavior);
|
||||
ClassDB::bind_method(D_METHOD("get_text_overrun_behavior"), &TextParagraph::get_text_overrun_behavior);
|
||||
@ -154,7 +159,7 @@ void TextParagraph::_shape_lines() {
|
||||
|
||||
if (h_offset > 0) {
|
||||
// Dropcap, flow around.
|
||||
PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(rid, width - h_offset, 0, flags);
|
||||
PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(rid, width - h_offset, 0, brk_flags);
|
||||
for (int i = 0; i < line_breaks.size(); i = i + 2) {
|
||||
RID line = TS->shaped_text_substr(rid, line_breaks[i], line_breaks[i + 1] - line_breaks[i]);
|
||||
float h = (TS->shaped_text_get_orientation(line) == TextServer::ORIENTATION_HORIZONTAL) ? TS->shaped_text_get_size(line).y : TS->shaped_text_get_size(line).x;
|
||||
@ -172,7 +177,7 @@ void TextParagraph::_shape_lines() {
|
||||
}
|
||||
}
|
||||
// Use fixed for the rest of lines.
|
||||
PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(rid, width, start, flags);
|
||||
PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(rid, width, start, brk_flags);
|
||||
for (int i = 0; i < line_breaks.size(); i = i + 2) {
|
||||
RID line = TS->shaped_text_substr(rid, line_breaks[i], line_breaks[i + 1] - line_breaks[i]);
|
||||
if (!tab_stops.is_empty()) {
|
||||
@ -181,43 +186,43 @@ void TextParagraph::_shape_lines() {
|
||||
lines_rid.push_back(line);
|
||||
}
|
||||
|
||||
uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIM;
|
||||
BitField<TextServer::TextOverrunFlag> overrun_flags = TextServer::OVERRUN_NO_TRIM;
|
||||
if (overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) {
|
||||
switch (overrun_behavior) {
|
||||
case TextServer::OVERRUN_TRIM_WORD_ELLIPSIS:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY;
|
||||
overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM_WORD_ONLY);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_ADD_ELLIPSIS);
|
||||
break;
|
||||
case TextServer::OVERRUN_TRIM_ELLIPSIS:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_ADD_ELLIPSIS);
|
||||
break;
|
||||
case TextServer::OVERRUN_TRIM_WORD:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM_WORD_ONLY);
|
||||
break;
|
||||
case TextServer::OVERRUN_TRIM_CHAR:
|
||||
overrun_flags |= TextServer::OVERRUN_TRIM;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
|
||||
break;
|
||||
case TextServer::OVERRUN_NO_TRIMMING:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool autowrap_enabled = ((flags & TextServer::BREAK_WORD_BOUND) == TextServer::BREAK_WORD_BOUND) || ((flags & TextServer::BREAK_GRAPHEME_BOUND) == TextServer::BREAK_GRAPHEME_BOUND);
|
||||
bool autowrap_enabled = brk_flags.has_flag(TextServer::BREAK_WORD_BOUND) || brk_flags.has_flag(TextServer::BREAK_GRAPHEME_BOUND);
|
||||
|
||||
// Fill after min_size calculation.
|
||||
if (autowrap_enabled) {
|
||||
int visible_lines = (max_lines_visible >= 0) ? MIN(max_lines_visible, (int)lines_rid.size()) : (int)lines_rid.size();
|
||||
bool lines_hidden = visible_lines > 0 && visible_lines < (int)lines_rid.size();
|
||||
if (lines_hidden) {
|
||||
overrun_flags |= TextServer::OVERRUN_ENFORCE_ELLIPSIS;
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_ENFORCE_ELLIPSIS);
|
||||
}
|
||||
if (alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
for (int i = 0; i < (int)lines_rid.size(); i++) {
|
||||
if (i < visible_lines - 1 || (int)lines_rid.size() == 1) {
|
||||
TS->shaped_text_fit_to_width(lines_rid[i], width, flags);
|
||||
TS->shaped_text_fit_to_width(lines_rid[i], width, jst_flags);
|
||||
} else if (i == (visible_lines - 1)) {
|
||||
TS->shaped_text_overrun_trim_to_width(lines_rid[visible_lines - 1], width, overrun_flags);
|
||||
}
|
||||
@ -231,10 +236,10 @@ void TextParagraph::_shape_lines() {
|
||||
// Autowrap disabled.
|
||||
for (int i = 0; i < (int)lines_rid.size(); i++) {
|
||||
if (alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
TS->shaped_text_fit_to_width(lines_rid[i], width, flags);
|
||||
overrun_flags |= TextServer::OVERRUN_JUSTIFICATION_AWARE;
|
||||
TS->shaped_text_fit_to_width(lines_rid[i], width, jst_flags);
|
||||
overrun_flags.set_flag(TextServer::OVERRUN_JUSTIFICATION_AWARE);
|
||||
TS->shaped_text_overrun_trim_to_width(lines_rid[i], width, overrun_flags);
|
||||
TS->shaped_text_fit_to_width(lines_rid[i], width, flags | TextServer::JUSTIFICATION_CONSTRAIN_ELLIPSIS);
|
||||
TS->shaped_text_fit_to_width(lines_rid[i], width, jst_flags | TextServer::JUSTIFICATION_CONSTRAIN_ELLIPSIS);
|
||||
} else {
|
||||
TS->shaped_text_overrun_trim_to_width(lines_rid[i], width, overrun_flags);
|
||||
}
|
||||
@ -420,17 +425,30 @@ void TextParagraph::tab_align(const Vector<float> &p_tab_stops) {
|
||||
lines_dirty = true;
|
||||
}
|
||||
|
||||
void TextParagraph::set_flags(uint16_t p_flags) {
|
||||
void TextParagraph::set_justification_flags(BitField<TextServer::JustificationFlag> p_flags) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
if (flags != p_flags) {
|
||||
flags = p_flags;
|
||||
if (jst_flags != p_flags) {
|
||||
jst_flags = p_flags;
|
||||
lines_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t TextParagraph::get_flags() const {
|
||||
return flags;
|
||||
BitField<TextServer::JustificationFlag> TextParagraph::get_justification_flags() const {
|
||||
return jst_flags;
|
||||
}
|
||||
|
||||
void TextParagraph::set_break_flags(BitField<TextServer::LineBreakFlag> p_flags) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
if (brk_flags != p_flags) {
|
||||
brk_flags = p_flags;
|
||||
lines_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
BitField<TextServer::LineBreakFlag> TextParagraph::get_break_flags() const {
|
||||
return brk_flags;
|
||||
}
|
||||
|
||||
void TextParagraph::set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior) {
|
||||
|
@ -54,7 +54,8 @@ private:
|
||||
float width = -1.0;
|
||||
int max_lines_visible = -1;
|
||||
|
||||
uint16_t flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA;
|
||||
BitField<TextServer::LineBreakFlag> brk_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND;
|
||||
BitField<TextServer::JustificationFlag> jst_flags = TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA;
|
||||
TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_NO_TRIMMING;
|
||||
|
||||
HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT;
|
||||
@ -102,8 +103,11 @@ public:
|
||||
|
||||
void tab_align(const Vector<float> &p_tab_stops);
|
||||
|
||||
void set_flags(uint16_t p_flags);
|
||||
uint16_t get_flags() const;
|
||||
void set_justification_flags(BitField<TextServer::JustificationFlag> p_flags);
|
||||
BitField<TextServer::JustificationFlag> get_justification_flags() const;
|
||||
|
||||
void set_break_flags(BitField<TextServer::LineBreakFlag> p_flags);
|
||||
BitField<TextServer::LineBreakFlag> get_break_flags() const;
|
||||
|
||||
void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior);
|
||||
TextServer::OverrunBehavior get_text_overrun_behavior() const;
|
||||
|
@ -438,12 +438,12 @@ int64_t TextServerExtension::font_get_face_count(const RID &p_font_rid) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TextServerExtension::font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) {
|
||||
void TextServerExtension::font_set_style(const RID &p_font_rid, BitField<TextServer::FontStyle> p_style) {
|
||||
GDVIRTUAL_CALL(font_set_style, p_font_rid, p_style);
|
||||
}
|
||||
|
||||
int64_t /*FontStyle*/ TextServerExtension::font_get_style(const RID &p_font_rid) const {
|
||||
int64_t ret;
|
||||
BitField<TextServer::FontStyle> TextServerExtension::font_get_style(const RID &p_font_rid) const {
|
||||
BitField<TextServer::FontStyle> ret = 0;
|
||||
if (GDVIRTUAL_CALL(font_get_style, p_font_rid, ret)) {
|
||||
return ret;
|
||||
}
|
||||
@ -1192,7 +1192,7 @@ RID TextServerExtension::shaped_text_get_parent(const RID &p_shaped) const {
|
||||
return RID();
|
||||
}
|
||||
|
||||
double TextServerExtension::shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t p_jst_flags) {
|
||||
double TextServerExtension::shaped_text_fit_to_width(const RID &p_shaped, double p_width, BitField<TextServer::JustificationFlag> p_jst_flags) {
|
||||
double ret;
|
||||
if (GDVIRTUAL_CALL(shaped_text_fit_to_width, p_shaped, p_width, p_jst_flags, ret)) {
|
||||
return ret;
|
||||
@ -1272,7 +1272,7 @@ Vector2i TextServerExtension::shaped_text_get_range(const RID &p_shaped) const {
|
||||
return Vector2i();
|
||||
}
|
||||
|
||||
PackedInt32Array TextServerExtension::shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start, bool p_once, int64_t p_break_flags) const {
|
||||
PackedInt32Array TextServerExtension::shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start, bool p_once, BitField<TextServer::LineBreakFlag> p_break_flags) const {
|
||||
PackedInt32Array ret;
|
||||
if (GDVIRTUAL_CALL(shaped_text_get_line_breaks_adv, p_shaped, p_width, p_start, p_once, p_break_flags, ret)) {
|
||||
return ret;
|
||||
@ -1280,7 +1280,7 @@ PackedInt32Array TextServerExtension::shaped_text_get_line_breaks_adv(const RID
|
||||
return TextServer::shaped_text_get_line_breaks_adv(p_shaped, p_width, p_start, p_once, p_break_flags);
|
||||
}
|
||||
|
||||
PackedInt32Array TextServerExtension::shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start, int64_t p_break_flags) const {
|
||||
PackedInt32Array TextServerExtension::shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start, BitField<TextServer::LineBreakFlag> p_break_flags) const {
|
||||
PackedInt32Array ret;
|
||||
if (GDVIRTUAL_CALL(shaped_text_get_line_breaks, p_shaped, p_width, p_start, p_break_flags, ret)) {
|
||||
return ret;
|
||||
@ -1288,7 +1288,7 @@ PackedInt32Array TextServerExtension::shaped_text_get_line_breaks(const RID &p_s
|
||||
return TextServer::shaped_text_get_line_breaks(p_shaped, p_width, p_start, p_break_flags);
|
||||
}
|
||||
|
||||
PackedInt32Array TextServerExtension::shaped_text_get_word_breaks(const RID &p_shaped, int64_t p_grapheme_flags) const {
|
||||
PackedInt32Array TextServerExtension::shaped_text_get_word_breaks(const RID &p_shaped, BitField<TextServer::GraphemeFlag> p_grapheme_flags) const {
|
||||
PackedInt32Array ret;
|
||||
if (GDVIRTUAL_CALL(shaped_text_get_word_breaks, p_shaped, p_grapheme_flags, ret)) {
|
||||
return ret;
|
||||
@ -1328,7 +1328,7 @@ int64_t TextServerExtension::shaped_text_get_ellipsis_glyph_count(const RID &p_s
|
||||
return -1;
|
||||
}
|
||||
|
||||
void TextServerExtension::shaped_text_overrun_trim_to_width(const RID &p_shaped_line, double p_width, int64_t p_trim_flags) {
|
||||
void TextServerExtension::shaped_text_overrun_trim_to_width(const RID &p_shaped_line, double p_width, BitField<TextServer::TextOverrunFlag> p_trim_flags) {
|
||||
GDVIRTUAL_CALL(shaped_text_overrun_trim_to_width, p_shaped_line, p_width, p_trim_flags);
|
||||
}
|
||||
|
||||
|
@ -92,10 +92,10 @@ public:
|
||||
virtual int64_t font_get_face_count(const RID &p_font_rid) const override;
|
||||
GDVIRTUAL1RC(int64_t, font_get_face_count, RID);
|
||||
|
||||
virtual void font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) override;
|
||||
virtual int64_t /*FontStyle*/ font_get_style(const RID &p_font_rid) const override;
|
||||
GDVIRTUAL2(font_set_style, RID, int64_t);
|
||||
GDVIRTUAL1RC(int64_t, font_get_style, RID);
|
||||
virtual void font_set_style(const RID &p_font_rid, BitField<FontStyle> p_style) override;
|
||||
virtual BitField<FontStyle> font_get_style(const RID &p_font_rid) const override;
|
||||
GDVIRTUAL2(font_set_style, RID, BitField<FontStyle>);
|
||||
GDVIRTUAL1RC(BitField<FontStyle>, font_get_style, RID);
|
||||
|
||||
virtual void font_set_name(const RID &p_font_rid, const String &p_name) override;
|
||||
virtual String font_get_name(const RID &p_font_rid) const override;
|
||||
@ -396,9 +396,9 @@ public:
|
||||
GDVIRTUAL3RC(RID, shaped_text_substr, RID, int64_t, int64_t);
|
||||
GDVIRTUAL1RC(RID, shaped_text_get_parent, RID);
|
||||
|
||||
virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override;
|
||||
virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, BitField<TextServer::JustificationFlag> p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override;
|
||||
virtual double shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) override;
|
||||
GDVIRTUAL3R(double, shaped_text_fit_to_width, RID, double, int64_t);
|
||||
GDVIRTUAL3R(double, shaped_text_fit_to_width, RID, double, BitField<TextServer::JustificationFlag>);
|
||||
GDVIRTUAL2R(double, shaped_text_tab_align, RID, const PackedFloat32Array &);
|
||||
|
||||
virtual bool shaped_text_shape(const RID &p_shaped) override;
|
||||
@ -421,12 +421,12 @@ public:
|
||||
virtual Vector2i shaped_text_get_range(const RID &p_shaped) const override;
|
||||
GDVIRTUAL1RC(Vector2i, shaped_text_get_range, RID);
|
||||
|
||||
virtual PackedInt32Array shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start = 0, bool p_once = true, int64_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override;
|
||||
virtual PackedInt32Array shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start = 0, int64_t p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override;
|
||||
virtual PackedInt32Array shaped_text_get_word_breaks(const RID &p_shaped, int64_t p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const override;
|
||||
GDVIRTUAL5RC(PackedInt32Array, shaped_text_get_line_breaks_adv, RID, const PackedFloat32Array &, int64_t, bool, int64_t);
|
||||
GDVIRTUAL4RC(PackedInt32Array, shaped_text_get_line_breaks, RID, double, int64_t, int64_t);
|
||||
GDVIRTUAL2RC(PackedInt32Array, shaped_text_get_word_breaks, RID, int64_t);
|
||||
virtual PackedInt32Array shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start = 0, bool p_once = true, BitField<TextServer::LineBreakFlag> p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override;
|
||||
virtual PackedInt32Array shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start = 0, BitField<TextServer::LineBreakFlag> p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override;
|
||||
virtual PackedInt32Array shaped_text_get_word_breaks(const RID &p_shaped, BitField<TextServer::GraphemeFlag> p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const override;
|
||||
GDVIRTUAL5RC(PackedInt32Array, shaped_text_get_line_breaks_adv, RID, const PackedFloat32Array &, int64_t, bool, BitField<TextServer::LineBreakFlag>);
|
||||
GDVIRTUAL4RC(PackedInt32Array, shaped_text_get_line_breaks, RID, double, int64_t, BitField<TextServer::LineBreakFlag>);
|
||||
GDVIRTUAL2RC(PackedInt32Array, shaped_text_get_word_breaks, RID, BitField<TextServer::GraphemeFlag>);
|
||||
|
||||
virtual int64_t shaped_text_get_trim_pos(const RID &p_shaped) const override;
|
||||
virtual int64_t shaped_text_get_ellipsis_pos(const RID &p_shaped) const override;
|
||||
@ -437,8 +437,8 @@ public:
|
||||
GDVIRTUAL1RC(GDNativeConstPtr<const Glyph>, shaped_text_get_ellipsis_glyphs, RID);
|
||||
GDVIRTUAL1RC(int64_t, shaped_text_get_ellipsis_glyph_count, RID);
|
||||
|
||||
virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, int64_t p_trim_flags) override;
|
||||
GDVIRTUAL3(shaped_text_overrun_trim_to_width, RID, double, int64_t);
|
||||
virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, BitField<TextServer::TextOverrunFlag> p_trim_flags) override;
|
||||
GDVIRTUAL3(shaped_text_overrun_trim_to_width, RID, double, BitField<TextServer::TextOverrunFlag>);
|
||||
|
||||
virtual Array shaped_text_get_objects(const RID &p_shaped) const override;
|
||||
virtual Rect2 shaped_text_get_object_rect(const RID &p_shaped, const Variant &p_key) const override;
|
||||
|
@ -463,12 +463,12 @@ void TextServer::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(ORIENTATION_VERTICAL);
|
||||
|
||||
/* JustificationFlag */
|
||||
BIND_ENUM_CONSTANT(JUSTIFICATION_NONE);
|
||||
BIND_ENUM_CONSTANT(JUSTIFICATION_KASHIDA);
|
||||
BIND_ENUM_CONSTANT(JUSTIFICATION_WORD_BOUND);
|
||||
BIND_ENUM_CONSTANT(JUSTIFICATION_TRIM_EDGE_SPACES);
|
||||
BIND_ENUM_CONSTANT(JUSTIFICATION_AFTER_LAST_TAB);
|
||||
BIND_ENUM_CONSTANT(JUSTIFICATION_CONSTRAIN_ELLIPSIS);
|
||||
BIND_BITFIELD_FLAG(JUSTIFICATION_NONE);
|
||||
BIND_BITFIELD_FLAG(JUSTIFICATION_KASHIDA);
|
||||
BIND_BITFIELD_FLAG(JUSTIFICATION_WORD_BOUND);
|
||||
BIND_BITFIELD_FLAG(JUSTIFICATION_TRIM_EDGE_SPACES);
|
||||
BIND_BITFIELD_FLAG(JUSTIFICATION_AFTER_LAST_TAB);
|
||||
BIND_BITFIELD_FLAG(JUSTIFICATION_CONSTRAIN_ELLIPSIS);
|
||||
|
||||
/* AutowrapMode */
|
||||
BIND_ENUM_CONSTANT(AUTOWRAP_OFF);
|
||||
@ -477,11 +477,11 @@ void TextServer::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(AUTOWRAP_WORD_SMART);
|
||||
|
||||
/* LineBreakFlag */
|
||||
BIND_ENUM_CONSTANT(BREAK_NONE);
|
||||
BIND_ENUM_CONSTANT(BREAK_MANDATORY);
|
||||
BIND_ENUM_CONSTANT(BREAK_WORD_BOUND);
|
||||
BIND_ENUM_CONSTANT(BREAK_GRAPHEME_BOUND);
|
||||
BIND_ENUM_CONSTANT(BREAK_WORD_BOUND_ADAPTIVE);
|
||||
BIND_BITFIELD_FLAG(BREAK_NONE);
|
||||
BIND_BITFIELD_FLAG(BREAK_MANDATORY);
|
||||
BIND_BITFIELD_FLAG(BREAK_WORD_BOUND);
|
||||
BIND_BITFIELD_FLAG(BREAK_GRAPHEME_BOUND);
|
||||
BIND_BITFIELD_FLAG(BREAK_ADAPTIVE);
|
||||
|
||||
/* VisibleCharactersBehavior */
|
||||
BIND_ENUM_CONSTANT(VC_CHARS_BEFORE_SHAPING);
|
||||
@ -498,25 +498,25 @@ void TextServer::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD_ELLIPSIS);
|
||||
|
||||
/* TextOverrunFlag */
|
||||
BIND_ENUM_CONSTANT(OVERRUN_NO_TRIM);
|
||||
BIND_ENUM_CONSTANT(OVERRUN_TRIM);
|
||||
BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD_ONLY);
|
||||
BIND_ENUM_CONSTANT(OVERRUN_ADD_ELLIPSIS);
|
||||
BIND_ENUM_CONSTANT(OVERRUN_ENFORCE_ELLIPSIS);
|
||||
BIND_ENUM_CONSTANT(OVERRUN_JUSTIFICATION_AWARE);
|
||||
BIND_BITFIELD_FLAG(OVERRUN_NO_TRIM);
|
||||
BIND_BITFIELD_FLAG(OVERRUN_TRIM);
|
||||
BIND_BITFIELD_FLAG(OVERRUN_TRIM_WORD_ONLY);
|
||||
BIND_BITFIELD_FLAG(OVERRUN_ADD_ELLIPSIS);
|
||||
BIND_BITFIELD_FLAG(OVERRUN_ENFORCE_ELLIPSIS);
|
||||
BIND_BITFIELD_FLAG(OVERRUN_JUSTIFICATION_AWARE);
|
||||
|
||||
/* GraphemeFlag */
|
||||
BIND_ENUM_CONSTANT(GRAPHEME_IS_VALID);
|
||||
BIND_ENUM_CONSTANT(GRAPHEME_IS_RTL);
|
||||
BIND_ENUM_CONSTANT(GRAPHEME_IS_VIRTUAL);
|
||||
BIND_ENUM_CONSTANT(GRAPHEME_IS_SPACE);
|
||||
BIND_ENUM_CONSTANT(GRAPHEME_IS_BREAK_HARD);
|
||||
BIND_ENUM_CONSTANT(GRAPHEME_IS_BREAK_SOFT);
|
||||
BIND_ENUM_CONSTANT(GRAPHEME_IS_TAB);
|
||||
BIND_ENUM_CONSTANT(GRAPHEME_IS_ELONGATION);
|
||||
BIND_ENUM_CONSTANT(GRAPHEME_IS_PUNCTUATION);
|
||||
BIND_ENUM_CONSTANT(GRAPHEME_IS_UNDERSCORE);
|
||||
BIND_ENUM_CONSTANT(GRAPHEME_IS_CONNECTED);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_VALID);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_RTL);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_VIRTUAL);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_SPACE);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_BREAK_HARD);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_BREAK_SOFT);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_TAB);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_ELONGATION);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_PUNCTUATION);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_UNDERSCORE);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_CONNECTED);
|
||||
|
||||
/* Hinting */
|
||||
BIND_ENUM_CONSTANT(HINTING_NONE);
|
||||
@ -556,11 +556,12 @@ void TextServer::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(SPACING_SPACE);
|
||||
BIND_ENUM_CONSTANT(SPACING_TOP);
|
||||
BIND_ENUM_CONSTANT(SPACING_BOTTOM);
|
||||
BIND_ENUM_CONSTANT(SPACING_MAX);
|
||||
|
||||
/* Font Style */
|
||||
BIND_ENUM_CONSTANT(FONT_BOLD);
|
||||
BIND_ENUM_CONSTANT(FONT_ITALIC);
|
||||
BIND_ENUM_CONSTANT(FONT_FIXED_WIDTH);
|
||||
BIND_BITFIELD_FLAG(FONT_BOLD);
|
||||
BIND_BITFIELD_FLAG(FONT_ITALIC);
|
||||
BIND_BITFIELD_FLAG(FONT_FIXED_WIDTH);
|
||||
|
||||
/* Structured text parser */
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_DEFAULT);
|
||||
@ -650,7 +651,7 @@ void TextServer::draw_hex_code_box(const RID &p_canvas, int64_t p_size, const Ve
|
||||
}
|
||||
}
|
||||
|
||||
PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start, bool p_once, int64_t /*TextBreakFlag*/ p_break_flags) const {
|
||||
PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start, bool p_once, BitField<TextServer::LineBreakFlag> p_break_flags) const {
|
||||
PackedInt32Array lines;
|
||||
|
||||
ERR_FAIL_COND_V(p_width.is_empty(), lines);
|
||||
@ -687,7 +688,7 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(const RID &p_shaped
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ((p_break_flags & BREAK_MANDATORY) == BREAK_MANDATORY) {
|
||||
if (p_break_flags.has_flag(BREAK_MANDATORY)) {
|
||||
if ((l_gl[i].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD) {
|
||||
lines.push_back(line_start);
|
||||
lines.push_back(l_gl[i].end);
|
||||
@ -701,12 +702,12 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(const RID &p_shaped
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((p_break_flags & BREAK_WORD_BOUND) == BREAK_WORD_BOUND) {
|
||||
if (p_break_flags.has_flag(BREAK_WORD_BOUND)) {
|
||||
if ((l_gl[i].flags & GRAPHEME_IS_BREAK_SOFT) == GRAPHEME_IS_BREAK_SOFT) {
|
||||
last_safe_break = i;
|
||||
}
|
||||
}
|
||||
if ((p_break_flags & BREAK_GRAPHEME_BOUND) == BREAK_GRAPHEME_BOUND) {
|
||||
if (p_break_flags.has_flag(BREAK_GRAPHEME_BOUND)) {
|
||||
last_safe_break = i;
|
||||
}
|
||||
}
|
||||
@ -726,7 +727,7 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(const RID &p_shaped
|
||||
return lines;
|
||||
}
|
||||
|
||||
PackedInt32Array TextServer::shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start, int64_t /*TextBreakFlag*/ p_break_flags) const {
|
||||
PackedInt32Array TextServer::shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start, BitField<TextServer::LineBreakFlag> p_break_flags) const {
|
||||
PackedInt32Array lines;
|
||||
|
||||
const_cast<TextServer *>(this)->shaped_text_update_breaks(p_shaped);
|
||||
@ -755,7 +756,7 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks(const RID &p_shaped, do
|
||||
word_count = 0;
|
||||
continue;
|
||||
}
|
||||
if ((p_break_flags & BREAK_MANDATORY) == BREAK_MANDATORY) {
|
||||
if (p_break_flags.has_flag(BREAK_MANDATORY)) {
|
||||
if ((l_gl[i].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD) {
|
||||
lines.push_back(line_start);
|
||||
lines.push_back(l_gl[i].end);
|
||||
@ -765,16 +766,16 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks(const RID &p_shaped, do
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((p_break_flags & BREAK_WORD_BOUND) == BREAK_WORD_BOUND) {
|
||||
if (p_break_flags.has_flag(BREAK_WORD_BOUND)) {
|
||||
if ((l_gl[i].flags & GRAPHEME_IS_BREAK_SOFT) == GRAPHEME_IS_BREAK_SOFT) {
|
||||
last_safe_break = i;
|
||||
word_count++;
|
||||
}
|
||||
if (p_break_flags.has_flag(BREAK_ADAPTIVE) && word_count == 0) {
|
||||
last_safe_break = i;
|
||||
}
|
||||
}
|
||||
if (((p_break_flags & BREAK_WORD_BOUND_ADAPTIVE) == BREAK_WORD_BOUND_ADAPTIVE) && word_count == 0) {
|
||||
last_safe_break = i;
|
||||
}
|
||||
if ((p_break_flags & BREAK_GRAPHEME_BOUND) == BREAK_GRAPHEME_BOUND) {
|
||||
if (p_break_flags.has_flag(BREAK_GRAPHEME_BOUND)) {
|
||||
last_safe_break = i;
|
||||
}
|
||||
}
|
||||
@ -794,7 +795,7 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks(const RID &p_shaped, do
|
||||
return lines;
|
||||
}
|
||||
|
||||
PackedInt32Array TextServer::shaped_text_get_word_breaks(const RID &p_shaped, int64_t p_grapheme_flags) const {
|
||||
PackedInt32Array TextServer::shaped_text_get_word_breaks(const RID &p_shaped, BitField<TextServer::GraphemeFlag> p_grapheme_flags) const {
|
||||
PackedInt32Array words;
|
||||
|
||||
const_cast<TextServer *>(this)->shaped_text_update_justification_ops(p_shaped);
|
||||
|
@ -79,12 +79,12 @@ public:
|
||||
AUTOWRAP_WORD_SMART
|
||||
};
|
||||
|
||||
enum LineBreakFlag { // LineBreakFlag can be passed in the same value as the JustificationFlag, do not use the same values.
|
||||
enum LineBreakFlag {
|
||||
BREAK_NONE = 0,
|
||||
BREAK_MANDATORY = 1 << 5,
|
||||
BREAK_WORD_BOUND = 1 << 6,
|
||||
BREAK_GRAPHEME_BOUND = 1 << 7,
|
||||
BREAK_WORD_BOUND_ADAPTIVE = 1 << 6 | 1 << 8,
|
||||
BREAK_MANDATORY = 1 << 0,
|
||||
BREAK_WORD_BOUND = 1 << 1,
|
||||
BREAK_GRAPHEME_BOUND = 1 << 2,
|
||||
BREAK_ADAPTIVE = 1 << 3,
|
||||
};
|
||||
|
||||
enum OverrunBehavior {
|
||||
@ -218,8 +218,8 @@ public:
|
||||
|
||||
virtual int64_t font_get_face_count(const RID &p_font_rid) const = 0;
|
||||
|
||||
virtual void font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) = 0;
|
||||
virtual int64_t /*FontStyle*/ font_get_style(const RID &p_font_rid) const = 0;
|
||||
virtual void font_set_style(const RID &p_font_rid, BitField<FontStyle> p_style) = 0;
|
||||
virtual BitField<FontStyle> font_get_style(const RID &p_font_rid) const = 0;
|
||||
|
||||
virtual void font_set_name(const RID &p_font_rid, const String &p_name) = 0;
|
||||
virtual String font_get_name(const RID &p_font_rid) const = 0;
|
||||
@ -398,7 +398,7 @@ public:
|
||||
virtual RID shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const = 0; // Copy shaped substring (e.g. line break) without reshaping, but correctly reordered, preservers range.
|
||||
virtual RID shaped_text_get_parent(const RID &p_shaped) const = 0;
|
||||
|
||||
virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) = 0;
|
||||
virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, BitField<TextServer::JustificationFlag> p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) = 0;
|
||||
virtual double shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) = 0;
|
||||
|
||||
virtual bool shaped_text_shape(const RID &p_shaped) = 0;
|
||||
@ -415,9 +415,9 @@ public:
|
||||
|
||||
virtual Vector2i shaped_text_get_range(const RID &p_shaped) const = 0;
|
||||
|
||||
virtual PackedInt32Array shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start = 0, bool p_once = true, int64_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const;
|
||||
virtual PackedInt32Array shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start = 0, int64_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const;
|
||||
virtual PackedInt32Array shaped_text_get_word_breaks(const RID &p_shaped, int64_t p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const;
|
||||
virtual PackedInt32Array shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start = 0, bool p_once = true, BitField<TextServer::LineBreakFlag> p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const;
|
||||
virtual PackedInt32Array shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start = 0, BitField<TextServer::LineBreakFlag> p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const;
|
||||
virtual PackedInt32Array shaped_text_get_word_breaks(const RID &p_shaped, BitField<TextServer::GraphemeFlag> p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const;
|
||||
|
||||
virtual int64_t shaped_text_get_trim_pos(const RID &p_shaped) const = 0;
|
||||
virtual int64_t shaped_text_get_ellipsis_pos(const RID &p_shaped) const = 0;
|
||||
@ -425,7 +425,7 @@ public:
|
||||
Array _shaped_text_get_ellipsis_glyphs_wrapper(const RID &p_shaped) const;
|
||||
virtual int64_t shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const = 0;
|
||||
|
||||
virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, int64_t p_trim_flags) = 0;
|
||||
virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, BitField<TextServer::TextOverrunFlag> p_trim_flags) = 0;
|
||||
|
||||
virtual Array shaped_text_get_objects(const RID &p_shaped) const = 0;
|
||||
virtual Rect2 shaped_text_get_object_rect(const RID &p_shaped, const Variant &p_key) const = 0;
|
||||
@ -551,16 +551,16 @@ VARIANT_ENUM_CAST(TextServer::AutowrapMode);
|
||||
VARIANT_ENUM_CAST(TextServer::OverrunBehavior);
|
||||
VARIANT_ENUM_CAST(TextServer::Direction);
|
||||
VARIANT_ENUM_CAST(TextServer::Orientation);
|
||||
VARIANT_ENUM_CAST(TextServer::JustificationFlag);
|
||||
VARIANT_ENUM_CAST(TextServer::LineBreakFlag);
|
||||
VARIANT_ENUM_CAST(TextServer::TextOverrunFlag);
|
||||
VARIANT_ENUM_CAST(TextServer::GraphemeFlag);
|
||||
VARIANT_BITFIELD_CAST(TextServer::JustificationFlag);
|
||||
VARIANT_BITFIELD_CAST(TextServer::LineBreakFlag);
|
||||
VARIANT_BITFIELD_CAST(TextServer::TextOverrunFlag);
|
||||
VARIANT_BITFIELD_CAST(TextServer::GraphemeFlag);
|
||||
VARIANT_ENUM_CAST(TextServer::Hinting);
|
||||
VARIANT_ENUM_CAST(TextServer::SubpixelPositioning);
|
||||
VARIANT_ENUM_CAST(TextServer::Feature);
|
||||
VARIANT_ENUM_CAST(TextServer::ContourPointTag);
|
||||
VARIANT_ENUM_CAST(TextServer::SpacingType);
|
||||
VARIANT_ENUM_CAST(TextServer::FontStyle);
|
||||
VARIANT_BITFIELD_CAST(TextServer::FontStyle);
|
||||
VARIANT_ENUM_CAST(TextServer::StructuredTextParser);
|
||||
|
||||
GDVIRTUAL_NATIVE_PTR(Glyph);
|
||||
|
Loading…
Reference in New Issue
Block a user