marginnsattributedstringcore-text

Core Text and top margin of the first paragraph in NSAttributedString


Why is that kCTParagraphStyleSpecifierParagraphSpacingBefore never works for a first paragraph in Core Text? To accomplish top margin at the beginning of the text I must manually manipulate path (CGPath) when creating first CTFrameRef frame for framesetter in this line of code:

CTFrameRef frame = CTFramesetterCreateFrame(framesetter,range, path, NULL);

Is there the more streamlined way to specify top spacing from the first paragraph to the CTFrameRef path bounds when rendering epub like, multiple paged content?


Solution

  • The only way to do that is to manipulate CTFrame's CGPathRef path to lower down its upper bounds.