Drawing an NSAttributedString into a non-rectangular CGPath?
I generate a rather complex NSAttributedString in my iOS 3.2 application (iPad), including formatting options of type CTParagraphStyleSetting, in particular with values for kCTParagraphStyleSpecifierMinimumLineHeight and kCTParagraphStyleSpecifierParagraphSpacing.
When I try to draw this attributed string into a non-rectangular CGPath, Core Text draws it but without the line spacing defined; that is, all text appears crammed in paragraphs without line spacing. Needless to say, it does not look as pretty as if the CGPath was simply defined using a single call to CGPathAddRect()!
Is there any setting I can specify (to my CTFrameset开发者_Python百科terRef or to the CTFrameRef associated to the culprit CGPath) to avoid losing all line height information?
Thanks!
The CoreText programming guide indicates that only a rectangular CGPath is allowed:
http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/CoreText_Programming/Overview/Overview.html#//apple_ref/doc/uid/TP40005533-CH3-SW1
As of iOS 4.2, Core Text accepts non-rectangular paths. See the docs for CTFramesetterCreateFrame:
http://developer.apple.com/library/iOS/documentation/Carbon/Reference/CTFramesetterRef/Reference/reference.html#//apple_ref/c/func/CTFramesetterCreateFrame
For a sample, see "Displaying Text in a Nonrectangular Region":
https://developer.apple.com/library/iOS/documentation/StringsTextFonts/Conceptual/CoreText_Programming/LayoutOperations/LayoutOperations.html#//apple_ref/doc/uid/TP40005533-CH12-SW9
精彩评论