[TextMesh, 3.x] Fix auto-translation and ignore control chars.

(cherry picked from commit efa6b01c97)
This commit is contained in:
bruvzg 2022-12-04 23:03:54 +02:00 committed by Haoyu Qiu
parent 056e99ad6e
commit 84eed3b988
2 changed files with 101 additions and 92 deletions

View file

@ -664,6 +664,12 @@ void MeshInstance::_notification(int p_what) {
_resolve_skeleton_path();
}
if (p_what == NOTIFICATION_TRANSLATION_CHANGED) {
if (mesh.is_valid()) {
mesh->notification(NOTIFICATION_TRANSLATION_CHANGED);
}
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (skin_ref.is_valid() && mesh.is_valid() && _is_software_skinning_enabled()) {
ERR_FAIL_COND(!skin_ref->get_skeleton_node());

View file

@ -1858,7 +1858,7 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
if ((c & 0xfffffc00) == 0xdc00) { // skip trail surrogate.
continue;
}
if (utf32_char >= 0x20) {
_generate_glyph_mesh_data(utf32_char, font, c, n);
GlyphMeshData &gl_data = cache[utf32_char];
@ -1876,6 +1876,7 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
min_p.y = MIN(gl_data.min_p.y + offset_pre.y, min_p.y);
max_p.x = MAX(gl_data.max_p.x + offset_pre.x, max_p.x);
max_p.y = MAX(gl_data.max_p.y + offset_pre.y, max_p.y);
}
offset_pre.x += font->get_char_size(c, n).x * pixel_size;
}
@ -1912,6 +1913,7 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
if ((c & 0xfffffc00) == 0xdc00) { // skip trail surrogate.
continue;
}
if (utf32_char >= 0x20) {
_generate_glyph_mesh_data(utf32_char, font, c, n);
GlyphMeshData &gl_data = cache[utf32_char];
@ -2006,6 +2008,7 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
}
}
}
}
offset.x += font->get_char_size(c, n).x * pixel_size;
}