示例#1
0
    PathText() {
        SkPaint defaultPaint;
        auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(defaultPaint);
        SkPath glyphPaths[52];
        for (int i = 0; i < 52; ++i) {
            // I and l are rects on OS X ...
            char c = "aQCDEFGH7JKLMNOPBRZTUVWXYSAbcdefghijk1mnopqrstuvwxyz"[i];
            SkPackedGlyphID id(cache->unicharToGlyph(c));
            sk_ignore_unused_variable(cache->getScalerContext()->getPath(id, &glyphPaths[i]));
        }

        for (int i = 0; i < kNumPaths; ++i) {
            const SkPath& p = glyphPaths[i % 52];
            fGlyphs[i].init(fRand, p);
        }
    }
示例#2
0
static void do_font_stuff(SkPaint* paint) {
    for (SkScalar i = 8; i < 64; i++) {
        paint->setTextSize(i);
        auto cache = SkGlyphCache::FindOrCreateStrikeExclusive(
                *paint, nullptr, SkScalerContextFlags::kNone, nullptr);
        uint16_t glyphs['z'];
        for (int c = ' '; c < 'z'; c++) {
            glyphs[c] = cache->unicharToGlyph(c);
        }
        for (int lookups = 0; lookups < 10; lookups++) {
            for (int c = ' '; c < 'z'; c++) {
                const SkGlyph& g = cache->getGlyphIDMetrics(glyphs[c]);
                cache->findImage(g);
            }
        }

    }
}