[TextServer] Fix issues with character breaks, add more tests.

This commit is contained in:
bruvzg
2023-08-19 11:19:09 +03:00
parent b51ee8b029
commit 07d859de25
4 changed files with 97 additions and 10 deletions

View File

@@ -1474,9 +1474,11 @@ int64_t TextServer::shaped_text_closest_character_pos(const RID &p_shaped, int64
PackedInt32Array TextServer::string_get_character_breaks(const String &p_string, const String &p_language) const {
PackedInt32Array ret;
ret.resize(p_string.size());
for (int i = 0; i <= p_string.size(); i++) {
ret.write[i] = i;
if (!p_string.is_empty()) {
ret.resize(p_string.size() - 1);
for (int i = 0; i < p_string.size() - 1; i++) {
ret.write[i] = i + 1;
}
}
return ret;
}