Core Text - Calculating line heights

While working with Core Text the other day i was in a situation where i wanted to align where the text ended in multiple adjacent columns. After looking through the documentation i found a number of read-only properties on UIFont that would seem to aid in fixing my problem.

After about an hour I realized just how wrong I was. Take a look at the output below from the following code. Note we are using one system font from Apple on the iPad as well as a custom font I have added to my project.

2012-10-23 09:11:20.666 *****************************************************************
2012-10-23 09:11:20.666 SYSTEM-FONT LINE HEIGHT PROPERTY 14.000000
2012-10-23 09:11:20.667 SYSTEM-FONT CALCULATED LINE HEIGHT 14.000000
2012-10-23 09:11:20.667 *****************************************************************
2012-10-23 09:11:20.667 CUSTOM-FONT LINE HEIGHT PROPERTY 14.000000
2012-10-23 09:11:20.668 CUSTOM-FONT CALCULATED LINE HEIGHT 17.219999
2012-10-23 09:11:20.668 *****************************************************************

Hmmm something here is off. My biggest issue was that when using the lineheight property to actually align the text with my custom font it didnt work as planned. As usual after spending some more time in the Apple documentation i came across the Core Text Common Operations. And there i found the following method...

So apparently this is the real way you get the lineheight for a font. I rewrote the function above in my own code and that is the "Calculated Line Height" output you see above. Notice it is different from the read-only property on the UIFont object.

Im still scratching my head on this but at least the calculated line height is what i really wanted. Problem Solved.