Is there more space between the last 2 lines of the paragraph?

I draw text using CTFramesetter, I installed kCTParagraphStyleSpecifierParagraphSpacing, kCTParagraphStyleSpecifierLineSpacing, kCTParagraphStyleSpecifierParagraphSpacingBeforeall to 0.0.

As you can see in the image, the space between the last two lines of the paragraph is much larger than the others.

There are only 15 lines in this image, I inserted their ascent, descent, beginning, origin. In the next we see that the ascent and descent on the 5th and 10th lines are larger than the others. I could not find any qualifier to avoid this strange layout.

Any ideas?

1  ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 399.000000
2  ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 374.000000
3  ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 349.000000
4  ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 324.000000
5  ascent=25.722656, desecent=13.699219, leading=0.720000, origin.y: 294.000000
6  ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 258.000000
7  ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 233.000000
8  ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 208.000000
9  ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 183.000000
10 ascent=25.722656, descent=13.699219, leading=0.720000, origin.y: 153.000000
11 ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 117.000000
12 ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 92.000000
13 ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 67.000000
14 ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 42.000000
15 ascent=20.639999, descent=3.360000, leading=0.720000, origin.y: 17.000000 

enter image description here

+2
source share
2 answers

Damit, this is a mistake. DTCoreText works around this by changing the source origin of these affected lines.

. http://www.cocoanetics.com/2012/02/radar-coretext-line-spacing-bug/

0

NSMutableAttributeString , CTRunDelegate, \n 0. :

        CTRunDelegateCallbacks callbacks;
        callbacks.version = kCTRunDelegateVersion1;
        callbacks.getAscent = lineBreakCallback;
        callbacks.getDescent = lineBreakCallback;
        callbacks.getWidth = lineBreakCallback;

        CTFontRef fontRef = CTFontCreateWithName((CFStringRef)@"System", 1.0f, NULL);

        CTRunDelegateRef delegate = CTRunDelegateCreate(&callbacks, NULL); //3
        NSDictionary *attrDictionaryDelegate = [NSDictionary dictionaryWithObjectsAndKeys:
                                                //set the delegate
                                                (__bridge id)delegate, (NSString*)kCTRunDelegateAttributeName,
                                                (__bridge id)fontRef, kCTFontAttributeName,
                                                nil];
        stringLength++;
        [attString appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n" attributes:attrDictionaryDelegate]];

        CFRelease(delegate);
        CFRelease(fontRef);

static CGFloat lineBreakCallback( void* ref )
{
    return 0;
}

:

  • (, )
  • font 1. , , ( 16) , , , ( , , , , - ).
+1

All Articles