So I just spent several hours beating my head against the wall because my CoreText project wasn't working properly. I found the issue, and it was odd. I'm hoping someone here can help me understand why the font characteristics of the same font of the same size are different between CTFontRef and UIFont.
To test, I used these four lines:
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));
And received this output:
UIFont: ascent:18.400391 descent:-4.599609 leading:24.000000
CTFontRef: ascent:15.400391 descent:4.599609 leading:0.000000
What???