Search code examples
cocoacore-text

core text CTFontGetBoundingRectsForGlyphs() is to slow


I am using CTFontGetBoundingRectsForGlyphs() to find single glyphs width. But it is too slow to call it multiple times per text line. And I ask you is there faster method to check glyph dimensions?


Solution

  • CTFontGetAdvancesForGlyphs() may be a faster way to find a single glyphs width.

    Alternatively, if you're using CTLine and CTRun, then CTRunGetAdvances() and CTRunGetAdvancesPtr() should give faster results as they're returning cached values.