summaryrefslogtreecommitdiff
path: root/servers/text
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-01-10 17:24:03 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-01-13 08:53:28 +0200
commitbaec983d8ab1877768eab3cd122566f05b4bce26 (patch)
tree3332cb45540faea0fcfd7809f0c2387a1e94099a /servers/text
parent2f4d76f068b29783bde653406b51909b29a082a3 (diff)
[TextServer] Improvements for line breaking, "Fill" alignment, overrun, and interaction between these modes.
Fix "Fill" alignment processing wrong side of the text if overrun trim was applied. Improve "Fill" alignment to avoid adding excessive subsequent spaces or elongations. Add font detection to the overrun, to correctly add ellipsis (was using last glyph font, which doesn't necessary have dot character). Improve line breaking to avoid adding excessive subsequent soft break points for languages without word separator. Port missing overrun/justification code to the Fallback text server. Fix inferred text direction detection by controls. Add tests for "Fill" alignment and line breaking glyph flags.
Diffstat (limited to 'servers/text')
-rw-r--r--servers/text/text_server_extension.cpp9
-rw-r--r--servers/text/text_server_extension.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp
index a51b62e730..a2195d1ddf 100644
--- a/servers/text/text_server_extension.cpp
+++ b/servers/text/text_server_extension.cpp
@@ -194,6 +194,7 @@ void TextServerExtension::_bind_methods() {
GDVIRTUAL_BIND(_shaped_text_set_direction, "shaped", "direction");
GDVIRTUAL_BIND(_shaped_text_get_direction, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_get_inferred_direction, "shaped");
GDVIRTUAL_BIND(_shaped_text_set_bidi_override, "shaped", "override");
@@ -954,6 +955,14 @@ TextServer::Direction TextServerExtension::shaped_text_get_direction(RID p_shape
return TextServer::Direction::DIRECTION_AUTO;
}
+TextServer::Direction TextServerExtension::shaped_text_get_inferred_direction(RID p_shaped) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_inferred_direction, p_shaped, ret)) {
+ return (TextServer::Direction)ret;
+ }
+ return TextServer::Direction::DIRECTION_LTR;
+}
+
void TextServerExtension::shaped_text_set_orientation(RID p_shaped, TextServer::Orientation p_orientation) {
GDVIRTUAL_CALL(_shaped_text_set_orientation, p_shaped, p_orientation);
}
diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h
index 9b456c2dd7..77f2ced951 100644
--- a/servers/text/text_server_extension.h
+++ b/servers/text/text_server_extension.h
@@ -315,8 +315,10 @@ public:
virtual void shaped_text_set_direction(RID p_shaped, Direction p_direction = DIRECTION_AUTO) override;
virtual Direction shaped_text_get_direction(RID p_shaped) const override;
+ virtual Direction shaped_text_get_inferred_direction(RID p_shaped) const override;
GDVIRTUAL2(_shaped_text_set_direction, RID, Direction);
GDVIRTUAL1RC(/*Direction*/ int, _shaped_text_get_direction, RID);
+ GDVIRTUAL1RC(/*Direction*/ int, _shaped_text_get_inferred_direction, RID);
virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) override;
GDVIRTUAL2(_shaped_text_set_bidi_override, RID, const Array &);