What is the relationship between the Glyph Ascender font and Descender in iOS?

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.

From Apple's documentation

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; //Descender is always a negative value 

So why did the Glyph height return from CTFontGetBoundingRectsForGlyphs not equal to Ascender plus Descender?

+4
ios objective-c fonts iphone
Mar 25 '14 at 10:15
source share
1 answer

Each character (letter shape) in a font has a different size and shape, right? The symbol "A" is above the glyph for the symbol "a", the upper part of the symbol "t" is again different.

Font.ascender is the maximum value for all forms of letters (glyphs), and Font.descender is the minimum value.

Any particular font can easily have an extra high glyph, which means that the value of Font.ascender had nothing to do with the size of the line that did not contain this character.

+1
Mar 29 '14 at 18:07
source share



All Articles