diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-05-24 11:58:54 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-05-24 11:58:54 +0300 |
commit | 826de9da489dc1d9bf10fcd2a203c52c874fd674 (patch) | |
tree | d1ad011a3d250e609e7ebd8063c4f99625e7e12e /scene | |
parent | 2998be4f998409ba14b5d6e1c184fe6767c87a3e (diff) |
[TextMesh] Fix incorrectly applied FILL alignment.
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/primitive_meshes.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 64982650e0..585405dd6f 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -2385,6 +2385,9 @@ void TextMesh::_create_mesh_array(Array &p_arr) const { dirty_text = false; dirty_font = false; + if (horizontal_alignment == HORIZONTAL_ALIGNMENT_FILL) { + TS->shaped_text_fit_to_width(text_rid, width, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA); + } } else if (dirty_font) { int spans = TS->shaped_get_span_count(text_rid); for (int i = 0; i < spans; i++) { @@ -2392,11 +2395,9 @@ void TextMesh::_create_mesh_array(Array &p_arr) const { } dirty_font = false; - } - if (horizontal_alignment == HORIZONTAL_ALIGNMENT_FILL) { - TS->shaped_text_fit_to_width(text_rid, width, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA); - } else { - TS->shaped_text_fit_to_width(text_rid, -1, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA); + if (horizontal_alignment == HORIZONTAL_ALIGNMENT_FILL) { + TS->shaped_text_fit_to_width(text_rid, width, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA); + } } Vector2 offset; @@ -2793,6 +2794,9 @@ TextMesh::~TextMesh() { void TextMesh::set_horizontal_alignment(HorizontalAlignment p_alignment) { ERR_FAIL_INDEX((int)p_alignment, 4); if (horizontal_alignment != p_alignment) { + if (horizontal_alignment == HORIZONTAL_ALIGNMENT_FILL || p_alignment == HORIZONTAL_ALIGNMENT_FILL) { + dirty_text = true; + } horizontal_alignment = p_alignment; _request_update(); } @@ -2900,6 +2904,9 @@ real_t TextMesh::get_depth() const { void TextMesh::set_width(real_t p_width) { if (width != p_width) { width = p_width; + if (horizontal_alignment == HORIZONTAL_ALIGNMENT_FILL) { + dirty_text = true; + } _request_update(); } } |