为什么UIFont的lineHeight比字体大?

Kud*_*oCC 2 fonts ios

我使用下面的代码来计算宽度有限的字符串行数.

NSString *text = @"abcdefgh";
UIFont *font = [UIFont systemFontOfSize:15.0];
CGFloat h = [text suggestHeightWithFont:font width:320.0];
NSInteger lines = (h > font.lineHeight) ? h/font.lineHeight+1 : h/font.lineHeight;
NSLog(@"height %f, %f, number lines:%ld", h, font.lineHeight, (unsigned long)lines);
Run Code Online (Sandbox Code Playgroud)

但我发现font.lineHeight(日志显示它是17.900391)大于设置为的字体大小15.0.

日志消息显示:

身高17.900391,17.900391,数字线:1

Dai*_*jan 7

lineHeight =一个字体的上升部分(上面一个字母的一部分)
                  +一个字体的下行部分(低于基线)
                  +一个字体的前导(垂直间距)

例如,对于字体大小10
A可能有ascender = 10,descender = 0
g可能有ascender = 5,descender = 4

lineHeight = 14 +领先... 14,5也许


请注意,此处的数字是随机的,仅用于更好地说明问题