Skip to content

Instantly share code, notes, and snippets.

@zsiegel
Last active October 11, 2015 23:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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(@"*****************************************************************");
NSLog(@"SYSTEM-FONT LINE HEIGHT PROPERTY %f", [UIFont systemFontOfSize:11].lineHeight);
NSLog(@"SYSTEM-FONT CALCULATED LINE HEIGHT %f", [self getLineHeightForFont:systemFont]); //Custom function
NSLog(@"*****************************************************************");
NSLog(@"CUSTOM-FONT LINE HEIGHT PROPERTY %f", [Theme fontForBodyOfSize:11].lineHeight);
NSLog(@"CUSTOM-FONT CALCULATED LINE HEIGHT %f", [self getLineHeightForFont:bodyCopyFont]); //Custom function
NSLog(@"*****************************************************************");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment