Skip to content

Instantly share code, notes, and snippets.

Last active October 11, 2015 23:58
Show Gist options
  • Save zsiegel/3939839 to your computer and use it in GitHub Desktop.
Save zsiegel/3939839 to your computer and use it in GitHub Desktop.
Core Text - Line height property inspection
/* Setup our fonts - One system font from Apple and a custom font */
CTFontRef bodyCopyFont = CTFontCreateWithName((__bridge CFStringRef) [Theme fontForBodyOfSize:11].fontName, [Theme fontForBodyOfSize:11].lineHeight, NULL);
CTFontRef systemFont = CTFontCreateWithName((__bridge CFStringRef) [UIFont systemFontOfSize:11].fontName, [UIFont systemFontOfSize:11].lineHeight, NULL);
/* Lets inspect the properties */
NSLog(@"SYSTEM-FONT LINE HEIGHT PROPERTY %f", [UIFont systemFontOfSize:11].lineHeight);
NSLog(@"SYSTEM-FONT CALCULATED LINE HEIGHT %f", [self getLineHeightForFont:systemFont]); //Custom function
NSLog(@"CUSTOM-FONT LINE HEIGHT PROPERTY %f", [Theme fontForBodyOfSize:11].lineHeight);
NSLog(@"CUSTOM-FONT CALCULATED LINE HEIGHT %f", [self getLineHeightForFont:bodyCopyFont]); //Custom function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment