diff --git a/font2png.cc b/font2png.cc index aa12600..bfdafd2 100644 --- a/font2png.cc +++ b/font2png.cc @@ -24,6 +24,7 @@ struct Font { unsigned numChars; unsigned charHeight; unsigned maxCharWidth; + uint8_t bgColor; std::vector chars; }; @@ -31,8 +32,9 @@ struct FontHeader { // little endian uint32_t unknown1; // (always)? "1.\0\0" uint32_t entries; uint32_t charWidth; - uint32_t unknown3; // (always)? 0x000000ff -}; + uint8_t bgColor; + char unknown3[3]; +} __attribute__((__packed__)); Font parseFont(FILE* file, size_t length) { @@ -89,6 +91,7 @@ Font parseFont(FILE* file, size_t length) ret.numChars = header.entries; ret.charHeight = char_width; ret.maxCharWidth = 0; + ret.bgColor = header.bgColor; for (auto const& index : indices) { uint32_t len; if (fseeko(file, index, SEEK_SET) != 0) @@ -160,12 +163,12 @@ Image makeFontImage(Font const& font) unsigned charNo = c_y*charsPerLine+c_x; if (charNo > font.numChars) { for (unsigned x = 0;x < font.maxCharWidth;++x) - ret.data.push_back(0xff); + ret.data.push_back(font.bgColor); } else { for (unsigned x = 0;x < font.chars[charNo].width;++x) ret.data.push_back(font.chars[charNo].data[y*font.chars[charNo].width+x]); for (unsigned x = font.chars[charNo].width; x < font.maxCharWidth;++x) - ret.data.push_back(0xff); + ret.data.push_back(font.bgColor); } } }