SkUnichar SkScalerContext::glyphIDToChar(uint16_t glyphID) { SkScalerContext* ctx = this; unsigned rangeEnd = 0; do { unsigned rangeStart = rangeEnd; rangeEnd += ctx->getGlyphCount(); if (rangeStart <= glyphID && glyphID < rangeEnd) { return ctx->generateGlyphToChar(glyphID - rangeStart); } ctx = ctx->getNextContext(); } while (NULL != ctx); return 0; }
SkScalerContext* SkScalerContext::getGlyphContext(const SkGlyph& glyph) { unsigned glyphID = glyph.getGlyphID(); SkScalerContext* ctx = this; for (;;) { unsigned count = ctx->getGlyphCount(); if (glyphID < count) { break; } glyphID -= count; ctx = ctx->getNextContext(); if (NULL == ctx) { SkDebugf("--- no context for glyph %x\n", glyph.getGlyphID()); // just return the original context (this) return this; } } return ctx; }
unsigned SkRandomScalerContext::generateGlyphCount() { return fProxy->getGlyphCount(); }