The CoreText method CTFontGetAdvancesForGlyphs adds the advances for all glyphs of an array of such and returns the sum.
However, if the array consists only of 1 element:
var offset = CCTFontGetAdvancesForGlyphs(myFont, .default, &myGlyph, nil, 1)
is calling the method just performing a simple lookup like when I access a variable, or will it trigger some kind of calculation on each call?
I'm wondering whether I need to store the result in a constant when I need the width of some specific glyphs repeatedly.
Take a look at these lines, this may help to understand the use of the function:
You can now do the following:
Your string of characters will be displayed according to the positions x,y you set for each character. This set of functions is very useful for creating custom alignments, custom kerning etc.