1

I have a string that I can paint in Core Text like so:

CGContextShowGlyphsAtPoint(context, 0, 0, glyphs, glyphCount);

Works great. Now I need to paint each of those glyphs individually, in the same spot as they would end up painted using that nice utility function above. And I'm not doing it in English, either...sometimes there is a glyph below a glyph below a glyph (diacritic).

Obviously I need something like this:

 CGPoint pt = CGPointMakeZero;
 for (int i = 0; i < glyphCount; i++) {
     CGContextShowGlyphsAtPoint(context, pt.x, pt.y, glyphs[i], 1);

     pt.x += <some quantity>
     pt.y += <some quantity>
 }

Unfortunately I haven't figured out what the "some quantities" are supposed to be yet...some combination of metrics fromCGContextGetAdvancesForGlyphs and/or CTFontGetVerticalTranslationsForGlyphs and/or CGContextGetGlyphBBoxes have been my first guesses, but I haven't got it to work yet.

Anyone have a solution/other ideas?

If you want a test string, try అక్త్రిన్.

(Background: I need to do the painting of glyphs one by one because of customizations to appearances to individual glyphs that I want to make in my app).

Merk
  • 1,441
  • 1
  • 15
  • 28

1 Answers1

1

Way late to the party here but this question/answer combo shows how layout is calculated line by line then glyph by glyph.

Core Text calculate letter frame in iOS

Community
  • 1
  • 1
Neil
  • 1,165
  • 1
  • 14
  • 24