CoreText: Height of newline when added to CTTextFrame is too small

Hi, I have constructed a custom TextView built on CoreText for the purpose of allowing a user to enter text into odd shapes. In creating the CTTextFrame, I've noticed that when a new line character is added and a new line is created, the height of the new line is much smaller then the other lines.

This is despite the fact that I'm adding the same font and size attributes to the newline character when I append it to the NSMutableAttributedString.

Here is the code that's producing this:

NSMutableAttributedString *textFramesetterText = [self.text mutableCopy];

//insert buffer area at the top and bottom of the rectangle

[textFramesetterText insertAttributedString:@" \n" atIndex:0];
[textFramesetterText appendAttributedString:@"\n "];

CTFramesetterRef textFramesetter = CTFramesetterCreateWithAttributedString((__bridge CFMutableAttributedStringRef)textFramesetterText);

//calculate the width and height based on the text

CGFloat width = [self textFrameHeightForWidth: MaxTextWidth maxTextHeight:self.maxTextHeight textFramesetter:textFramesetter textFrameSetterText:textFramesetterText];

CGFloat height = [self textFrameWidthForHeight: size.height maxTextWidth:MaxTextWidth textFramesetter:textFramesetter textFrameSetterText:textFramesetterText];

CTFrameRef textFrame =  [self newTextFrameForFrame:CGRectMake(0,0,width,height) textFramesetter:textFramesetter];

self.textFrame = textFrame;

CFRelease(textFrame);
CFRelease(textFramesetter);

I know this has been a issue with CTTextFrame for a long time and I'm wondering if there is any way to fix this. My workaround right now is to add a space after the newline character, but this can get messy. Any help would be appreciated. Thanks.

Anyone by chance ever experience this?

CoreText: Height of newline when added to CTTextFrame is too small
 
 
Q