🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
BMfont binary format
I have some problems reading the info block (using BMfont 1.8b) of the binary format. The rest of the file works great.
Perhaps I don't understand the layout, or is it out of sync with the documentation?
Anyway these are the values I get for example, excluding the string on the end and blocksize at the begin:
32, 194, 0, 100, 0, 4, 0, 0, 0, 1, 1
All are bytes, except the first and eight number, these are WORD.
I count 15 vars in the spec, some are missing here. I also expected stretchH, which should be the 8th number, to be 100.
This is this specified layout. One more question, what do these ':4' and ':1' mean?
#pragma pack(1)
struct infoBlock
{
int blockSize;
WORD fontSize;
BYTE reserved:4;
BYTE bold :1;
BYTE italic :1;
BYTE unicode :1;
BYTE smooth :1;
BYTE charSet;
WORD stretchH;
BYTE aa;
BYTE paddingUp;
BYTE paddingRight;
BYTE paddingDown;
BYTE paddingLeft;
BYTE spacingHoriz;
BYTE spacingVert;
char fontName[1];
};
I probably need to clarify the file format specs a bit in the manual.
The info block looks like this:
4 bytes : size of block
2 bytes : font size
1 byte : bitmask with flags for bold, italic, unicode, and smooth
1 byte : charset (not used if unicode)
2 bytes : horizontal stretch
1 byte : super sampling level (1 to 4)
4 bytes : padding, up, right, down, left
2 bytes : spacing, horizontal, vertical
n bytes : null terminated string with the name of the font
The :4 and :1 after some of the variables are C++ syntax for specifying how many bits the variable take up. These variables get packed into a single byte.
Regards,
Andreas
The info block looks like this:
4 bytes : size of block
2 bytes : font size
1 byte : bitmask with flags for bold, italic, unicode, and smooth
1 byte : charset (not used if unicode)
2 bytes : horizontal stretch
1 byte : super sampling level (1 to 4)
4 bytes : padding, up, right, down, left
2 bytes : spacing, horizontal, vertical
n bytes : null terminated string with the name of the font
The :4 and :1 after some of the variables are C++ syntax for specifying how many bits the variable take up. These variables get packed into a single byte.
Regards,
Andreas
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement