| 294 | return true; |
| 295 | } |
| 296 | int parse_glyph( char_info& info, unichar& enc ) |
| 297 | { |
| 298 | info.has_dw = false; |
| 299 | int e; |
| 300 | int res; |
| 301 | while ( 1 ) |
| 302 | { |
| 303 | res = find_keywords( ENCODING ); |
| 304 | if ( res != ENCODING ) |
| 305 | return 0; // no more glyphs |
| 306 | in_ >> e; |
| 307 | if ( in_.fail() ) |
| 308 | return -1; // parse_error |
| 309 | if ( e >= static_cast<int>(enc) ) |
| 310 | break; |
| 311 | } |
| 312 | int find = BBX | DWIDTH; |
| 313 | int stop = STARTCHAR | ENCODING | BITMAP | ENDCHAR | ENDFONT; |
| 314 | while ( 1 ) |
| 315 | { |
| 316 | res = find_keywords( find | stop ); |
| 317 | if ( res & BBX ) |
| 318 | { |
| 319 | in_ >> info.BBw >> info.BBh >> info.BBxoff0x >> info.BByoff0y; |
| 320 | if ( in_.fail() ) |
| 321 | return -1; // parse_error |
| 322 | find &= ~BBX; |
| 323 | continue; |
| 324 | } |
| 325 | if ( res & DWIDTH ) |
| 326 | { |
| 327 | in_ >> info.dwx0 >> info.dwy0; |
| 328 | if ( in_.fail() ) |
| 329 | return -1; // parse_error |
| 330 | find &= ~DWIDTH; |
| 331 | info.has_dw = true; |
| 332 | continue; |
| 333 | } |
| 334 | if ( res & NO_KEYWORD ) |
| 335 | return -1; // parse_error: unexpected EOF |
| 336 | break; |
| 337 | } |
| 338 | if ( res != BITMAP || ( find != NO_KEYWORD ) ) |
| 339 | return -1; // parse_error: required keyword missing or unexpeced keyword |
| 340 | unsigned h = info.BBh; |
| 341 | unsigned w = ( info.BBw + 7 ) / 8 * 2; |
| 342 | info.bitmap.set_size( h, w ); |
| 343 | for ( unsigned r = 0;r < h;r++ ) |
| 344 | { |
| 345 | trim(); |
| 346 | std::string str = ""; |
| 347 | extract_hex(str); |
| 348 | if(str.size() < w) |
| 349 | return -1; // parse_error |
| 350 | for ( unsigned c = 0;c < w;c++ ) |
| 351 | info.bitmap[r][c] = str[c]; |
| 352 | } |
| 353 | if ( in_.fail() ) |
no test coverage detected