Skip to content

Instantly share code, notes, and snippets.

Forked from zsiegel/gist:3939839
Created November 29, 2012 15:39
Show Gist options
  • Save uchuugaka/4169859 to your computer and use it in GitHub Desktop.
Save uchuugaka/4169859 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 ASCENDER PROPERTY %f", [UIFont systemFontOfSize:11].lineHeight);
NSLog(@"SYSTEM-FONT DESCENDER PROPERTY %f", [UIFont systemFontOfSize:11].lineHeight);
NSLog(@"SYSTEM-FONT LEADING 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 ASCENDER PROPERTY %f", [Theme fontForBodyOfSize:11].lineHeight);
NSLog(@"CUSTOM-FONT DESCENDER PROPERTY %f", [Theme fontForBodyOfSize:11].lineHeight);
NSLog(@"CUSTOM-FONT LEADING 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