CoreText Line Spacing Bug

Number:rdar://10810114 Date Originated:02/05/2012
Status:Duplicate/9931615 Resolved:
Product:iPhone SDK Product Version:5.0
Classification:UI Bug Reproducible:Always

CoreText inserts too much space before any line that ends with a \n. This extra space depends on the font and font size. On large print this causes visual noise by not being uniform.

Steps to Reproduce:

Create a CTFrame from a CTFrameSetter with a string that is long enough to wrap and that contains paragraph breaks. Use a non-UI font, like for example AriaMT.

Expected Results:

Line origins should be spaced by exactly the same distance for identical text and identical attributes.

Actual Results:

Each line that ends with a paragraph break is shifted down. With the system UI font, size 54 baselines are spaced exactly 64 pixels apart. With ArialMT, size 54, baseline spacing differs between 62 and 65.


This has been a bug since before iOS 4.3.


This does not occur with all fonts, Using a system font the spacing is precisely correct. I have attached a project to demonstrate the issue. See TextView.m.

It appears that the text metrics for an (invisible) paragraph glyph are miscalculated. Since the glyph is not visible you'd expect neither and ascender nor descender value. But instead the descender is too large. If you walk through the entire line and get the maximum ascenders and descenders the value is correct if you omit the \n in this calculation.

In short: A trailing \n messes up the font metrics for the entire CTLine.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!