From 2e035272a8e9abdb5c2265877b24e51a0b0e834a Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Fri, 1 Oct 2021 09:19:46 +0300 Subject: [PATCH] [FontData] Fixes saving copy of the font source data, if it was created from built-in font. --- scene/resources/font.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 9b403a18f09..de561bb8520 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -502,6 +502,11 @@ void FontData::set_data(const PackedByteArray &p_data) { } PackedByteArray FontData::get_data() const { + if (unlikely((size_t)data.size() != data_size)) { + PackedByteArray *data_w = const_cast(&data); + data_w->resize(data_size); + memcpy(data_w->ptrw(), data_ptr, data_size); + } return data; }