Here's my code to read in the blocks:
InfoBlock info; CommonBlock common; std::string pageName; std::vector<std::string> pageNames; int numChars; CharsBlock charsBlock; std::vector<CharsBlock> chars; while ( !ss.eof() ) { BlockHeader bheader; ss.read (reinterpret_cast<char *>(&bheader), sizeof (bheader)); switch ( bheader.type ) { case BT_INFO: ReadInfoBlock (bheader.size, info, ss); break; case BT_COMMON: ss.read (reinterpret_cast<char *>(&common), bheader.size); break; case BT_PAGES: pageName.resize (bheader.size); for ( int i = 0; i < common.pages; i++ ) { ss.read (&pageName[0], bheader.size); pageNames.push_back (pageName); } break; case BT_CHARS: numChars = bheader.size / sizeof (CharsBlock); chars.resize (numChars); ss.read (reinterpret_cast<char *>(&chars[0]), bheader.size); break; default: ss.seekg (bheader.size, std::ios::cur); break; } }
Here's the struct I've created for CharsBlock:
struct CharsBlock{ unsigned int id; unsigned short x; unsigned short y; unsigned short width; unsigned short height; short xoffset; short yoffset; short xadvance; unsigned char page; unsigned char channel;};
(The struct has 1-byte alignment)
Here's a screenshot of the contents of the chars variable.
And yes, I am using a debug build! :P
Does anyone have any ideas what could be causing the problem?
EDIT: I should add that outputting a plain text format .fnt file, I can see that all the characters are exported correctly.