[RTL] Use separate paragraph copy for the partially visible paragraphs.

This commit is contained in:
Pāvels Nadtočajevs 2025-09-09 10:35:16 +03:00
parent 019889d1da
commit 0d19e18b00
No known key found for this signature in database
GPG key ID: 8413210218EF35D2
19 changed files with 346 additions and 51 deletions

View file

@ -402,6 +402,7 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("create_shaped_text", "direction", "orientation"), &TextServer::create_shaped_text, DEFVAL(DIRECTION_AUTO), DEFVAL(ORIENTATION_HORIZONTAL));
ClassDB::bind_method(D_METHOD("shaped_text_clear", "rid"), &TextServer::shaped_text_clear);
ClassDB::bind_method(D_METHOD("shaped_text_duplicate", "rid"), &TextServer::shaped_text_duplicate);
ClassDB::bind_method(D_METHOD("shaped_text_set_direction", "shaped", "direction"), &TextServer::shaped_text_set_direction, DEFVAL(DIRECTION_AUTO));
ClassDB::bind_method(D_METHOD("shaped_text_get_direction", "shaped"), &TextServer::shaped_text_get_direction);
@ -430,6 +431,7 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("shaped_text_add_string", "shaped", "text", "fonts", "size", "opentype_features", "language", "meta"), &TextServer::shaped_text_add_string, DEFVAL(Dictionary()), DEFVAL(""), DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("shaped_text_add_object", "shaped", "key", "size", "inline_align", "length", "baseline"), &TextServer::shaped_text_add_object, DEFVAL(INLINE_ALIGNMENT_CENTER), DEFVAL(1), DEFVAL(0.0));
ClassDB::bind_method(D_METHOD("shaped_text_resize_object", "shaped", "key", "size", "inline_align", "baseline"), &TextServer::shaped_text_resize_object, DEFVAL(INLINE_ALIGNMENT_CENTER), DEFVAL(0.0));
ClassDB::bind_method(D_METHOD("shaped_text_has_object", "shaped", "key"), &TextServer::shaped_text_has_object);
ClassDB::bind_method(D_METHOD("shaped_get_text", "shaped"), &TextServer::shaped_get_text);
ClassDB::bind_method(D_METHOD("shaped_get_span_count", "shaped"), &TextServer::shaped_get_span_count);

View file

@ -463,6 +463,7 @@ public:
virtual RID create_shaped_text(Direction p_direction = DIRECTION_AUTO, Orientation p_orientation = ORIENTATION_HORIZONTAL) = 0;
virtual void shaped_text_clear(const RID &p_shaped) = 0;
virtual RID shaped_text_duplicate(const RID &p_shaped) = 0;
virtual void shaped_text_set_direction(const RID &p_shaped, Direction p_direction = DIRECTION_AUTO) = 0;
virtual Direction shaped_text_get_direction(const RID &p_shaped) const = 0;
@ -491,6 +492,7 @@ public:
virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) = 0;
virtual bool shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int64_t p_length = 1, double p_baseline = 0.0) = 0;
virtual bool shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, double p_baseline = 0.0) = 0;
virtual bool shaped_text_has_object(const RID &p_shaped, const Variant &p_key) const = 0;
virtual String shaped_get_text(const RID &p_shaped) const = 0;
virtual int64_t shaped_get_span_count(const RID &p_shaped) const = 0;

View file

@ -94,9 +94,11 @@ public:
virtual RID create_shaped_text(TextServer::Direction p_direction, TextServer::Orientation p_orientation) override { return RID(); }
virtual void shaped_text_clear(const RID &p_shaped) override {}
virtual RID shaped_text_duplicate(const RID &p_shaped) override { return RID(); }
virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features, const String &p_language, const Variant &p_meta) override { return false; }
virtual bool shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align, int64_t p_length, double p_baseline) override { return false; }
virtual bool shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align, double p_baseline) override { return false; }
virtual bool shaped_text_has_object(const RID &p_shaped, const Variant &p_key) const override { return false; }
virtual int64_t shaped_get_span_count(const RID &p_shaped) const override { return 0; }
virtual Variant shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const override { return Variant(); }
virtual Variant shaped_get_span_embedded_object(const RID &p_shaped, int64_t p_index) const override { return Variant(); }

View file

@ -252,6 +252,7 @@ void TextServerExtension::_bind_methods() {
GDVIRTUAL_BIND(_create_shaped_text, "direction", "orientation");
GDVIRTUAL_BIND(_shaped_text_clear, "shaped");
GDVIRTUAL_BIND(_shaped_text_duplicate, "shaped");
GDVIRTUAL_BIND(_shaped_text_set_direction, "shaped", "direction");
GDVIRTUAL_BIND(_shaped_text_get_direction, "shaped");
@ -280,6 +281,7 @@ void TextServerExtension::_bind_methods() {
GDVIRTUAL_BIND(_shaped_text_add_string, "shaped", "text", "fonts", "size", "opentype_features", "language", "meta");
GDVIRTUAL_BIND(_shaped_text_add_object, "shaped", "key", "size", "inline_align", "length", "baseline");
GDVIRTUAL_BIND(_shaped_text_resize_object, "shaped", "key", "size", "inline_align", "baseline");
GDVIRTUAL_BIND(_shaped_text_has_object, "shaped", "key");
GDVIRTUAL_BIND(_shaped_get_text, "shaped");
GDVIRTUAL_BIND(_shaped_get_span_count, "shaped");
@ -1148,6 +1150,12 @@ void TextServerExtension::shaped_text_clear(const RID &p_shaped) {
GDVIRTUAL_CALL(_shaped_text_clear, p_shaped);
}
RID TextServerExtension::shaped_text_duplicate(const RID &p_shaped) {
RID ret;
GDVIRTUAL_CALL(_shaped_text_duplicate, p_shaped, ret);
return ret;
}
void TextServerExtension::shaped_text_set_direction(const RID &p_shaped, TextServer::Direction p_direction) {
GDVIRTUAL_CALL(_shaped_text_set_direction, p_shaped, p_direction);
}
@ -1246,6 +1254,12 @@ bool TextServerExtension::shaped_text_resize_object(const RID &p_shaped, const V
return ret;
}
bool TextServerExtension::shaped_text_has_object(const RID &p_shaped, const Variant &p_key) const {
bool ret = false;
GDVIRTUAL_CALL(_shaped_text_has_object, p_shaped, p_key, ret);
return ret;
}
String TextServerExtension::shaped_get_text(const RID &p_shaped) const {
String ret;
GDVIRTUAL_CALL(_shaped_get_text, p_shaped, ret);

View file

@ -413,6 +413,9 @@ public:
virtual void shaped_text_clear(const RID &p_shaped) override;
GDVIRTUAL1_REQUIRED(_shaped_text_clear, RID);
virtual RID shaped_text_duplicate(const RID &p_shaped) override;
GDVIRTUAL1R_REQUIRED(RID, _shaped_text_duplicate, RID);
virtual void shaped_text_set_direction(const RID &p_shaped, Direction p_direction = DIRECTION_AUTO) override;
virtual Direction shaped_text_get_direction(const RID &p_shaped) const override;
virtual Direction shaped_text_get_inferred_direction(const RID &p_shaped) const override;
@ -456,9 +459,11 @@ public:
virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) override;
virtual bool shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int64_t p_length = 1, double p_baseline = 0.0) override;
virtual bool shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, double p_baseline = 0.0) override;
virtual bool shaped_text_has_object(const RID &p_shaped, const Variant &p_key) const override;
GDVIRTUAL7R_REQUIRED(bool, _shaped_text_add_string, RID, const String &, const TypedArray<RID> &, int64_t, const Dictionary &, const String &, const Variant &);
GDVIRTUAL6R_REQUIRED(bool, _shaped_text_add_object, RID, const Variant &, const Size2 &, InlineAlignment, int64_t, double);
GDVIRTUAL5R_REQUIRED(bool, _shaped_text_resize_object, RID, const Variant &, const Size2 &, InlineAlignment, double);
GDVIRTUAL2RC_REQUIRED(bool, _shaped_text_has_object, RID, const Variant &);
virtual String shaped_get_text(const RID &p_shaped) const override;
GDVIRTUAL1RC_REQUIRED(String, _shaped_get_text, RID);