diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-11-14 22:33:59 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-11-14 22:33:59 +0200 |
commit | e77b6427cbd485e49001d70f1e5d7850a5990930 (patch) | |
tree | 92825edd1c623c064b4d7572e41ed75d8678b99c /scene | |
parent | aa4c286808bbf4b16346de40307fcd5b29f19697 (diff) |
[Bitmap font] Always set valid fixed size, even if it's not set in the `fnt` file.
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/font.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 79ca87e9d6..84814d939b 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -1396,6 +1396,9 @@ Error FontFile::load_bitmap_font(const String &p_path) { case 1: /* info */ { ERR_FAIL_COND_V_MSG(block_size < 15, ERR_CANT_CREATE, RTR("Invalid BMFont info block size.")); base_size = f->get_16(); + if (base_size <= 0) { + base_size = 16; + } uint8_t flags = f->get_8(); if (flags & (1 << 3)) { st_flags.set_flag(TextServer::FONT_BOLD); @@ -1681,7 +1684,6 @@ Error FontFile::load_bitmap_font(const String &p_path) { if (type == "info") { if (keys.has("size")) { base_size = keys["size"].to_int(); - set_fixed_size(base_size); } if (keys.has("outline")) { outline = keys["outline"].to_int(); @@ -1730,6 +1732,7 @@ Error FontFile::load_bitmap_font(const String &p_path) { encoding = 2; } } + set_fixed_size(base_size); } else if (type == "common") { if (keys.has("lineHeight")) { height = keys["lineHeight"].to_int(); |