| 336 | */ |
| 337 | |
| 338 | uint16_t bmfUnicodeToGlyphID(CommodettoFontEngine bmf, uint32_t c) |
| 339 | { |
| 340 | const uint8_t *chars = bmf->charTable; |
| 341 | int min, max; |
| 342 | |
| 343 | if (bmf->isContinuous) { |
| 344 | // one run of continuously numbered characters |
| 345 | uint32_t firstChar = c_read32(chars); |
| 346 | if (c < firstChar) |
| 347 | return kInvalidGlyphID; |
| 348 | |
| 349 | c -= firstChar; |
| 350 | if (c >= bmf->charCount) |
| 351 | return kInvalidGlyphID; |
| 352 | |
| 353 | return c; |
| 354 | } |
| 355 | |
| 356 | // ascending order, with gaps. binary search. |
| 357 | min = 0; |
| 358 | max = bmf->charCount; |
| 359 | do { |
| 360 | int mid = (min + max) >> 1; |
| 361 | const uint8_t *cc = (20 * mid) + chars; |
| 362 | uint32_t code = c_read32(cc); |
| 363 | if (code < c) |
| 364 | min = mid + 1; |
| 365 | else if (c < code) |
| 366 | max = mid - 1; |
| 367 | else |
| 368 | return mid; |
| 369 | } while (min <= max); |
| 370 | |
| 371 | return kInvalidGlyphID; |
| 372 | } |
| 373 | |
| 374 | static const char kLatin1Base[96][2] = { |
| 375 | " ", "", "c", "#", "", "Y", "", "", |
no outgoing calls
no test coverage detected