KCTParagraphStyleSpecifierParagraphSpacing not respected for CTFrame first line

We have an application that relies heavily on kCTParagraphStyleSpecifierParagraphSpacing to control paragraph spacing, which can vary in text. For performance editing, we implemented our main body of the main text as a set of CTFrames that are drawn / redrawn when necessary.

We found that if a paragraph uses a non-zero kCTParagraphStyleSpecifierParagraphSpacing as one of its CTParagraphStyleSettings attributes, this paragraph interval is ignored if this paragraph is the first element in a CTFrame, even if there is another paragraph in the text that precedes it in the text to the frame printer.

I believe this behavior makes sense if you are drawing a PDF document for printing, but given that we are trying to present our text as a single, scrollable and continuous block of text, this creates problems for us. Is there a way around this problem?

+3
source share
1 answer

If you can't change the behavior with CTParagraphStyleSetting, I think this is a mistake, or Apple thinks the behavior makes sense. In any case, in order to get the desired result, I think the best way is to use CTTypesetterand process lineSpacing and paragraphSpacing yourself. I think the implementation is CTFramerather difficult, as I just recently ran into another .

CTTypesetterSuggestClusterBreak CTTypesetterSuggestLineBreak char . , lineSpacing . (\n), paragraphSpacing .

CTTypesetter, , , , . , , .

.

+6

All Articles