diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-13 09:13:27 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-13 09:13:27 +0100 |
commit | a90bbc3544df328f1dad978d47d639c3b02e7c10 (patch) | |
tree | ecdea76c957b0b994161ea083d013c9823f1f185 | |
parent | 428bf1188debc9ad95ec2f192aba75b29839081b (diff) | |
parent | ba472bd29cf6aa8c616c4d4fbb18cd2b0825f3a2 (diff) |
Merge pull request #72225 from MinusKube/shaped_text_invalidated_bug
Mark dirty flags when shaped texts are invalidated
-rw-r--r-- | scene/3d/label_3d.cpp | 12 | ||||
-rw-r--r-- | scene/gui/label.cpp | 12 | ||||
-rw-r--r-- | scene/resources/primitive_meshes.cpp | 14 | ||||
-rw-r--r-- | scene/resources/text_line.cpp | 5 | ||||
-rw-r--r-- | scene/resources/text_paragraph.cpp | 12 |
5 files changed, 54 insertions, 1 deletions
diff --git a/scene/3d/label_3d.cpp b/scene/3d/label_3d.cpp index b39ca43d2e..5fc36abb76 100644 --- a/scene/3d/label_3d.cpp +++ b/scene/3d/label_3d.cpp @@ -442,6 +442,18 @@ void Label3D::_generate_glyph_surfaces(const Glyph &p_glyph, Vector2 &r_offset, } void Label3D::_shape() { + // When a shaped text is invalidated by an external source, we want to reshape it. + if (!TS->shaped_text_is_ready(text_rid)) { + dirty_text = true; + } + + for (const RID &line_rid : lines_rid) { + if (!TS->shaped_text_is_ready(line_rid)) { + dirty_lines = true; + break; + } + } + // Clear mesh. RS::get_singleton()->mesh_clear(mesh); aabb = AABB(); diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 47384a9551..829f4cc643 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -350,6 +350,18 @@ void Label::_notification(int p_what) { RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true); } + // When a shaped text is invalidated by an external source, we want to reshape it. + if (!TS->shaped_text_is_ready(text_rid)) { + dirty = true; + } + + for (const RID &line_rid : lines_rid) { + if (!TS->shaped_text_is_ready(line_rid)) { + lines_dirty = true; + break; + } + } + if (dirty || font_dirty || lines_dirty) { _shape(); if (lines_dirty) { diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index ef1f6459e9..8ed68626a8 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -2890,6 +2890,18 @@ void TextMesh::_create_mesh_array(Array &p_arr) const { dirty_cache = false; } + // When a shaped text is invalidated by an external source, we want to reshape it. + if (!TS->shaped_text_is_ready(text_rid)) { + dirty_text = true; + } + + for (const RID &line_rid : lines_rid) { + if (!TS->shaped_text_is_ready(line_rid)) { + dirty_lines = true; + break; + } + } + // Update text buffer. if (dirty_text) { TS->shaped_text_clear(text_rid); @@ -3328,7 +3340,7 @@ void TextMesh::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pixel_size", PROPERTY_HINT_RANGE, "0.0001,128,0.0001,suffix:m"), "set_pixel_size", "get_pixel_size"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "curve_step", PROPERTY_HINT_RANGE, "0.1,10,0.1,suffix:px"), "set_curve_step", "get_curve_step"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth", PROPERTY_HINT_RANGE, "0.0,100.0,0.001,or_greater,suffix:m"), "set_depth", "get_depth"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_NONE, "suffix:m"), "set_width", "get_width"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_NONE, "suffix:px"), "set_width", "get_width"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset", PROPERTY_HINT_NONE, "suffix:px"), "set_offset", "get_offset"); ADD_GROUP("BiDi", ""); diff --git a/scene/resources/text_line.cpp b/scene/resources/text_line.cpp index 93611ea2c4..38a865b170 100644 --- a/scene/resources/text_line.cpp +++ b/scene/resources/text_line.cpp @@ -101,6 +101,11 @@ void TextLine::_bind_methods() { } void TextLine::_shape() { + // When a shaped text is invalidated by an external source, we want to reshape it. + if (!TS->shaped_text_is_ready(rid)) { + dirty = true; + } + if (dirty) { if (!tab_stops.is_empty()) { TS->shaped_text_tab_align(rid, tab_stops); diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp index dfafc7d2bc..729063245c 100644 --- a/scene/resources/text_paragraph.cpp +++ b/scene/resources/text_paragraph.cpp @@ -134,6 +134,18 @@ void TextParagraph::_bind_methods() { } void TextParagraph::_shape_lines() { + // When a shaped text is invalidated by an external source, we want to reshape it. + if (!TS->shaped_text_is_ready(rid) || !TS->shaped_text_is_ready(dropcap_rid)) { + lines_dirty = true; + } + + for (const RID &line_rid : lines_rid) { + if (!TS->shaped_text_is_ready(line_rid)) { + lines_dirty = true; + break; + } + } + if (lines_dirty) { for (const RID &line_rid : lines_rid) { TS->free_rid(line_rid); |