summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-02-15 22:19:53 +0100
committerGitHub <noreply@github.com>2021-02-15 22:19:53 +0100
commitf14008b600ff091a07d9dcb53780e9374f36d47f (patch)
tree7bb15f3e54434b5d448e2db0760f93057a85e6b2
parentf673a9efe067b014bca0d6931881cfbb7300baea (diff)
parent0fcbc1c6e366373c8cc6d7c20eae6d34f18c251e (diff)
Merge pull request #46069 from bruvzg/fix_font_crash_empty_data
Fix font `draw_*string` crash with empty data.
-rw-r--r--scene/resources/font.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index b4773adc6f..702f2ed1c8 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -828,6 +828,8 @@ Size2 Font::get_multiline_string_size(const String &p_text, float p_width, int p
}
void Font::draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HAlign p_align, float p_width, int p_size, const Color &p_modulate, int p_outline_size, const Color &p_outline_modulate, uint8_t p_flags) const {
+ ERR_FAIL_COND(data.is_empty());
+
uint64_t hash = p_text.hash64();
hash = hash_djb2_one_64(p_size, hash);
@@ -858,6 +860,8 @@ void Font::draw_string(RID p_canvas_item, const Point2 &p_pos, const String &p_t
}
void Font::draw_multiline_string(RID p_canvas_item, const Point2 &p_pos, const String &p_text, HAlign p_align, float p_width, int p_max_lines, int p_size, const Color &p_modulate, int p_outline_size, const Color &p_outline_modulate, uint8_t p_flags) const {
+ ERR_FAIL_COND(data.is_empty());
+
uint64_t hash = p_text.hash64();
hash = hash_djb2_one_64(p_size, hash);