| 223 | } |
| 224 | |
| 225 | std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char* pData, |
| 226 | uint32_t size, |
| 227 | std::string_view controlFile) |
| 228 | { |
| 229 | /* based on http://www.angelcode.com/products/bmfont/doc/file_format.html file format */ |
| 230 | |
| 231 | std::set<unsigned int>* validCharsString = new std::set<unsigned int>(); |
| 232 | |
| 233 | uint32_t remains = size; |
| 234 | |
| 235 | AXASSERT(pData[3] == 3, "Only version 3 is supported"); |
| 236 | |
| 237 | pData += 4; |
| 238 | remains -= 4; |
| 239 | |
| 240 | while (remains > 0) |
| 241 | { |
| 242 | unsigned char blockId = pData[0]; |
| 243 | pData += 1; |
| 244 | remains -= 1; |
| 245 | uint32_t blockSize = 0; |
| 246 | memcpy(&blockSize, pData, 4); |
| 247 | |
| 248 | pData += 4; |
| 249 | remains -= 4; |
| 250 | |
| 251 | if (blockId == 1) |
| 252 | { |
| 253 | /* |
| 254 | fontSize 2 int 0 |
| 255 | bitField 1 bits 2 bit 0: smooth, bit 1: unicode, bit 2: italic, bit 3: bold, bit 4: |
| 256 | fixedHeight, bits 5-7: reserved charSet 1 uint 3 stretchH 2 uint 4 aa 1 uint 6 |
| 257 | paddingUp 1 uint 7 |
| 258 | paddingRight 1 uint 8 |
| 259 | paddingDown 1 uint 9 |
| 260 | paddingLeft 1 uint 10 |
| 261 | spacingHoriz 1 uint 11 |
| 262 | spacingVert 1 uint 12 |
| 263 | outline 1 uint 13 added with version 2 |
| 264 | fontName n+1 string 14 null terminated string with length n |
| 265 | */ |
| 266 | |
| 267 | memcpy(&_fontSize, pData, 2); |
| 268 | _padding.top = (unsigned char)pData[7]; |
| 269 | _padding.right = (unsigned char)pData[8]; |
| 270 | _padding.bottom = (unsigned char)pData[9]; |
| 271 | _padding.left = (unsigned char)pData[10]; |
| 272 | } |
| 273 | else if (blockId == 2) |
| 274 | { |
| 275 | /* |
| 276 | lineHeight 2 uint 0 |
| 277 | base 2 uint 2 |
| 278 | scaleW 2 uint 4 |
| 279 | scaleH 2 uint 6 |
| 280 | pages 2 uint 8 |
| 281 | bitField 1 bits 10 bits 0-6: reserved, bit 7: packed |
| 282 | alphaChnl 1 uint 11 |
nothing calls this directly
no test coverage detected