From cbafa32de123a9ac51a5a3e58d6f783e7efa05dc Mon Sep 17 00:00:00 2001 From: Chris Feger Date: Fri, 29 Aug 2025 10:41:50 -0400 Subject: [PATCH 1/2] Fix TGLP size output Turns out official software actually uses this field. Who knew? --- source/bcfnt.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/bcfnt.cpp b/source/bcfnt.cpp index b642e22..73a0653 100644 --- a/source/bcfnt.cpp +++ b/source/bcfnt.cpp @@ -606,6 +606,8 @@ bool BCFNT::serialize (const std::string &path) const std::uint32_t sheetOffset = (fileSize + MASK) & ~MASK; fileSize = sheetOffset + sheetImages.size () * SHEET_SIZE; + const std::uint32_t totalTglpSize = fileSize - tglpOffset; + // CWDH headers + data const std::uint32_t cwdhOffset = fileSize; fileSize += 0x10; // CWDH header @@ -676,7 +678,7 @@ bool BCFNT::serialize (const std::string &path) // TGLP header assert (std::distance (std::begin (output), it) == tglpOffset); it << "TGLP" // magic - << static_cast (0x20) // section size + << static_cast (totalTglpSize) // section size << static_cast (cellWidth) // cell width << static_cast (cellHeight) // cell height << static_cast (ascent) // cell baseline From 0689ab3d3937a98de268a3c9b5df4125e3c0df2a Mon Sep 17 00:00:00 2001 From: Chris Feger Date: Fri, 29 Aug 2025 15:04:18 -0400 Subject: [PATCH 2/2] Fix CWDH end off-by-one It's an end index, not a size. [a,b], not [a,b) --- source/bcfnt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/bcfnt.cpp b/source/bcfnt.cpp index 73a0653..e8e1a27 100644 --- a/source/bcfnt.cpp +++ b/source/bcfnt.cpp @@ -717,7 +717,7 @@ bool BCFNT::serialize (const std::string &path) it << "CWDH" // magic << static_cast (0x10 + ((3 * glyphs.size () + 3) & ~3)) // section size << static_cast (0) // start index - << static_cast (glyphs.size ()) // end index + << static_cast (glyphs.size () - 1) // end index << static_cast (0); // next CWDH offset for (const auto &info : glyphs)