I'm working with fonts in a UILabel (iOS7) and have come across something I'm hoping someone can explain: What is the relationship between a fonts' Glyph, Ascender, and Descender?
From the documents I've read the Ascender is the portion of a font above the baseline, the Descender is the portion below (returned as negative). The combined absolute values should be the max Height of the font.
For example an Ascender of 255 and a Descender of -64 would give a total height of 319. However the Glyph height is returned as 228.4
EDIT: Here's 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's the Ascender/Descender code:
float adHeight = myLabel.font.ascender-myLabel.font.descender; //Descender is always a negative value
So why does the Glyph height returned from CTFontGetBoundingRectsForGlyphs not equal the Ascender plus Descender?