Skip to content

Instantly share code, notes, and snippets.

@zsiegel
Created October 23, 2012 16:18
Show Gist options
  • Save zsiegel/3939819 to your computer and use it in GitHub Desktop.
Save zsiegel/3939819 to your computer and use it in GitHub Desktop.
Core Text - Calculating line height
CGFloat GetLineHeightForFont(CTFontRef iFont)
{
CGFloat lineHeight = 0.0;
check(iFont != NULL);
// Get the ascent from the font, already scaled for the font's size
lineHeight += CTFontGetAscent(iFont);
// Get the descent from the font, already scaled for the font's size
lineHeight += CTFontGetDescent(iFont);
// Get the leading from the font, already scaled for the font's size
lineHeight += CTFontGetLeading(iFont);
return lineHeight;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment