diff options
author | David Snopek <dsnopek@gmail.com> | 2023-08-14 18:12:05 -0500 |
---|---|---|
committer | David Snopek <dsnopek@gmail.com> | 2023-08-14 18:12:05 -0500 |
commit | d585ca546bf8920ead41bf3d371bfc85fcfba8a1 (patch) | |
tree | 59b8941f16d1e51511818a923647bd4441e4dc5a /modules/text_server_adv/text_server_adv.cpp | |
parent | c495eb5102278a110c14bbffbf833ed436d1594d (diff) | |
download | redot-engine-d585ca546bf8920ead41bf3d371bfc85fcfba8a1.tar.gz |
Use `String::resize()` and `CharString` in text_server_adv again
Diffstat (limited to 'modules/text_server_adv/text_server_adv.cpp')
-rw-r--r-- | modules/text_server_adv/text_server_adv.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 043a33ab35..2a502d081e 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -2113,12 +2113,10 @@ Dictionary TextServerAdvanced::_font_get_ot_name_strings(const RID &p_font_rid) name = vformat("unknown_%d", names[i].name_id); } break; } + String text; unsigned int text_size = hb_ot_name_get_utf32(hb_face, names[i].name_id, names[i].language, nullptr, nullptr) + 1; - // @todo After godot-cpp#1141 is fixed, use text.resize() and write directly to text.wptr() instead of using a temporary buffer. - char32_t *buffer = memnew_arr(char32_t, text_size); - hb_ot_name_get_utf32(hb_face, names[i].name_id, names[i].language, &text_size, (uint32_t *)buffer); - String text(buffer); - memdelete_arr(buffer); + text.resize(text_size); + hb_ot_name_get_utf32(hb_face, names[i].name_id, names[i].language, &text_size, (uint32_t *)text.ptrw()); if (!text.is_empty()) { Dictionary &id_string = names_for_lang[String(hb_language_to_string(names[i].language))]; id_string[name] = text; |