CTFontRef和UIFont之间的差异

时间:2012-05-23 02:41:00

标签: objective-c ios uifont ctfontref

因为我的CoreText项目无法正常工作,所以我花了好几个小时撞墙。我发现了这个问题,这很奇怪。我希望有人在这里可以帮助我理解为什么CTFontRef和UIFont之间相同大小的相同字体的字体特征是不同的。

为了测试,我使用了这四行:

UIFont* tFont=[UIFont fontWithName:@"Helvetica" size:20];
CTFontRef fontRef=CTFontCreateWithName((CFStringRef)@"Helvetica", 20.0f, NULL);
NSLog(@"UIFont: ascent:%f descent:%f leading:%f",_font.ascender,_font.descender,_font.leading);
NSLog(@"CTFontRef: ascent:%f descent:%f leading:%f",CTFontGetAscent(fontRef),CTFontGetDescent(fontRef),CTFontGetLeading(fontRef));

并收到了这个输出:

UIFont: ascent:18.400391 descent:-4.599609 leading:24.000000
CTFontRef: ascent:15.400391 descent:4.599609 leading:0.000000

什么???

0 个答案:

没有答案