Merge pull request #72225 from MinusKube/shaped_text_invalidated_bug

Mark dirty flags when shaped texts are invalidated
This commit is contained in:
Rémi Verschelde
2023-02-13 09:13:27 +01:00
5 changed files with 54 additions and 1 deletions

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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", "");

View File

@@ -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);

View File

@@ -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);