diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-11-14 23:25:28 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-11-14 23:25:28 +0100 |
commit | f7c487f676b9641f57fa5a3316669370a2ede7b3 (patch) | |
tree | 2c8d3abb120feaef29d9236a0c39c189f54d05ea | |
parent | f33e482551b2e39545242c0cd86bd6a3ab00116e (diff) | |
parent | e77b6427cbd485e49001d70f1e5d7850a5990930 (diff) |
Merge pull request #68664 from bruvzg/bmp_base_size
[Bitmap font] Always set valid fixed size, even if it's not set in the `fnt` file.
-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(); |