Skip to content

Instantly share code, notes, and snippets.

@qtxie
Forked from zsiegel/gist:3939819
Created August 30, 2016 08:58
Show Gist options
  • Save qtxie/a16717f74bc2f6c83b9ba922367cddc9 to your computer and use it in GitHub Desktop.
Save qtxie/a16717f74bc2f6c83b9ba922367cddc9 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