2

我在我的 iOS 3.2 应用程序 (iPad) 中生成了一个相当复杂的 NSAttributedString,包括 CTParagraphStyleSetting 类型的格式化选项,尤其是 kCTParagraphStyleSpecifierMinimumLineHeight 和 kCTParagraphStyleSpecifierParagraphSpacing 的值。

当我尝试将此属性字符串绘制成非矩形 CGPath 时,Core Text 会绘制它但没有定义行距;也就是说,所有文本都挤在没有行距的段落中。不用说,它看起来不像 CGPath 是简单地使用对 CGPathAddRect() 的调用来定义的那么漂亮!

是否可以指定任何设置(针对我的 CTFramesetterRef 或与罪魁祸首 CGPath 关联的 CTFrameRef)以避免丢失所有行高信息?

谢谢!

4

2 回答 2

2

CoreText 编程指南指出只允许使用矩形 CGPath:

http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/CoreText_Programming/Overview/Overview.html#//apple_ref/doc/uid/TP40005533-CH3-SW1

于 2010-12-29T19:50:38.173 回答
1

从 iOS 4.2 开始,Core Text 接受非矩形路径。请参阅 CTFramesetterCreateFrame 的文档:

http://developer.apple.com/library/iOS/documentation/Carbon/Reference/CTFramesetterRef/Reference/reference.html#//apple_ref/c/func/CTFramesetterCreateFrame

有关示例,请参阅“在非矩形区域中显示文本”:

https://developer.apple.com/library/iOS/documentation/StringsTextFonts/Conceptual/CoreText_Programming/LayoutOperations/LayoutOperations.html#//apple_ref/doc/uid/TP40005533-CH12-SW9

于 2013-12-11T16:07:54.493 回答