diff --git a/source/bcfnt.cpp b/source/bcfnt.cpp index b642e22..e8e1a27 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 @@ -715,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)