[TextServer] Add support for trimming edge spaces on line break.

This commit is contained in:
bruvzg 2022-08-30 11:56:17 +03:00
parent 1c037c89d4
commit 7aad14a4b6
No known key found for this signature in database
GPG key ID: 7960FCF39844EC38
9 changed files with 124 additions and 21 deletions

View file

@ -486,8 +486,9 @@ void Label3D::_shape() {
case TextServer::AUTOWRAP_OFF:
break;
}
PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(text_rid, width, 0, autowrap_flags);
autowrap_flags = autowrap_flags | TextServer::BREAK_TRIM_EDGE_SPACES;
PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(text_rid, width, 0, autowrap_flags);
float max_line_w = 0.0;
for (int i = 0; i < line_breaks.size(); i = i + 2) {
RID line = TS->shaped_text_substr(text_rid, line_breaks[i], line_breaks[i + 1] - line_breaks[i]);