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

This commit is contained in:
bruvzg 2022-12-04 23:03:54 +02:00
parent 6a99678bc6
commit efa6b01c97
No known key found for this signature in database
GPG Key ID: 7960FCF39844EC38
2 changed files with 101 additions and 92 deletions

View File

@ -664,6 +664,12 @@ void MeshInstance::_notification(int p_what) {
_resolve_skeleton_path(); _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 (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (skin_ref.is_valid() && mesh.is_valid() && _is_software_skinning_enabled()) { if (skin_ref.is_valid() && mesh.is_valid() && _is_software_skinning_enabled()) {
ERR_FAIL_COND(!skin_ref->get_skeleton_node()); ERR_FAIL_COND(!skin_ref->get_skeleton_node());

View File

@ -1987,7 +1987,7 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
if ((c & 0xfffffc00) == 0xdc00) { // skip trail surrogate. if ((c & 0xfffffc00) == 0xdc00) { // skip trail surrogate.
continue; continue;
} }
if (utf32_char >= 0x20) {
_generate_glyph_mesh_data(utf32_char, font, c, n); _generate_glyph_mesh_data(utf32_char, font, c, n);
GlyphMeshData &gl_data = cache[utf32_char]; GlyphMeshData &gl_data = cache[utf32_char];
@ -2005,6 +2005,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); 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.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); 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; offset_pre.x += font->get_char_size(c, n).x * pixel_size;
} }
@ -2041,6 +2042,7 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
if ((c & 0xfffffc00) == 0xdc00) { // skip trail surrogate. if ((c & 0xfffffc00) == 0xdc00) { // skip trail surrogate.
continue; continue;
} }
if (utf32_char >= 0x20) {
_generate_glyph_mesh_data(utf32_char, font, c, n); _generate_glyph_mesh_data(utf32_char, font, c, n);
GlyphMeshData &gl_data = cache[utf32_char]; GlyphMeshData &gl_data = cache[utf32_char];
@ -2135,6 +2137,7 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
} }
} }
} }
}
offset.x += font->get_char_size(c, n).x * pixel_size; offset.x += font->get_char_size(c, n).x * pixel_size;
} }