I work with fonts in UILabel (iOS7) and stumbled upon what I hope someone can explain: What is the relationship between the glyph, askender and descender?
From the documents I read, Ascender is part of the font above the baseline, Descender is the part below (returned as negative). Combined absolute values should be the maximum font height.

For example, Ascender of 255 and Descender -64 will give a total height of 319. However, the glyph height returns as 228.4
EDIT: here is the glyph code:
CTFontRef ctFont = CTFontCreateWithName((__bridge CFStringRef)(uiFont.fontName), uiFont.pointSize, NULL); UniChar ch = [msgLabel.text characterAtIndex:0]; CGGlyph glyph; if (CTFontGetGlyphsForCharacters (ctFont, &ch, &glyph, 1)) { CGRect bounds = CTFontGetBoundingRectsForGlyphs (ctFont, kCTFontOrientationDefault, &glyph, nil, 1); float glyphHeight = bounds.size.height; }
And here is the Ascender / Descender code:
float adHeight = myLabel.font.ascender-myLabel.font.descender;
So why did the Glyph height return from CTFontGetBoundingRectsForGlyphs not equal to Ascender plus Descender?
ios objective-c fonts iphone
wayneh Mar 25 '14 at 10:15 2014-03-25 22:15
source share