| 296 | } |
| 297 | |
| 298 | void CFELayoutRun(CommodettoFontEngine bmf, const char *utf8, int32_t byteLength, CFERun run, int32_t runLength, int32_t width) |
| 299 | { |
| 300 | const char *utf8End = utf8 + byteLength; |
| 301 | #if MODDEF_CFE_KERN |
| 302 | unsigned int prevGlyphUnicode = 0; |
| 303 | #endif |
| 304 | |
| 305 | while (utf8 < utf8End) { |
| 306 | CFEGlyph glyph; |
| 307 | unsigned int unicode = PocoNextFromUTF8((uint8_t **)&utf8); |
| 308 | uint16_t glyphID = bmfUnicodeToGlyphID(bmf, unicode); //@@ subsitute here too |
| 309 | if (kInvalidGlyphID == glyphID) |
| 310 | continue; |
| 311 | |
| 312 | glyph = CFEGetGlyphFromGlyphID(bmf, glyphID, 0); |
| 313 | if (NULL == glyph) |
| 314 | continue; |
| 315 | |
| 316 | run->glyphID = glyphID; |
| 317 | run->advance = glyph->advance; |
| 318 | |
| 319 | #if MODDEF_CFE_KERN |
| 320 | if (0 != prevGlyphUnicode) |
| 321 | run[-1].advance += CFEGetKerningOffset(bmf, unicode, prevGlyphUnicode); |
| 322 | prevGlyphUnicode = unicode; |
| 323 | #endif |
| 324 | run++; |
| 325 | |
| 326 | runLength -= 1; |
| 327 | if (1 == runLength) |
| 328 | break; //@@ report run array overflow |
| 329 | } |
| 330 | |
| 331 | run->glyphID = kInvalidGlyphID; |
| 332 | } |
| 333 | |
| 334 | /* |
| 335 | utility functions |
nothing calls this directly
no test coverage detected