iOS中字体Glyph Ascender和Descender之间的关系是什么?

我正在使用UILabel(iOS7)中的字体,并且遇到了一些我希望能够解释的东西:字体Glyph,Ascender和Descender之间的关系是什么?

从我读过的文档中,Ascender是基线上方字体的一部分,下面的部分是下面的部分(作为负面返回)。 组合的绝对值应该是字体的最大高度。

从苹果的文档

例如,255的上升和-64的下降将会给出319的总高度。然而,雕文高度返回为228.4

编辑:这是字形码:

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; } 

下面是Ascender / Descender代码:

 float adHeight = myLabel.font.ascender-myLabel.font.descender; //Descender is always a negative value 

那么为什么从CTFontGetBoundingRectsForGlyphs返回的字形高度不等于Ascender plus Descender?

字体中的每个字形(字母形状)都是不同的大小和形状,对吧? 字符“A”的字形比字符“a”的字形更高,“t”字形的顶部再次不同。

Font.ascender是所有字母形状(字形)的最大值,Font.descender是最小值。

任何特定的字体可以很容易地有一个额外的高字形,这意味着Font.ascender值与不包含该字符的string的尺寸没有关系。