美文网首页
07. RTF Files and Attributed Str

07. RTF Files and Attributed Str

作者: ngugg | 来源:发表于2018-10-29 17:14 被阅读4次

    Rich Text Format (RTF) is a text formatting language devised by Microsoft Corporation. You can represent character, paragraph, and document format attributes using plain text with interspersed RTF commands, groups, and escape sequences. RTF is widely used as a document interchange format to transfer documents with their formatting information across applications and computing platforms. Apple has extended RTF with custom commands, which are described in this chapter.

    • RTF格式(RTF)是Microsoft Corporation设计的文本格式化语言。 您可以使用带有散布的RTF命令,组和转义序列的纯文本来表示字符,段落和文档格式属性。 RTF广泛用作文档交换格式,用于跨应用程序和计算平台传输文档及其格式信息。 Apple已使用自定义命令扩展了RTF,本章将介绍这些命令。

    Reading and Writing RTF Data

    The Application Kit’s extensions for NSAttributedString add support for reading and writing a number of popular document formats, including RTF and RTFD, as described in Formatted Documents and Attributed Strings. Although NSAttributedString has convenience methods for reading and writing RTF and RTFD data in particular, those methods have no advantage over the general-purpose methods, and they lack the useful error:parameter.

    Apple’s RTF Extensions

    Apple has extended the RTF language to support text attributes and formatting constructs available in the Cocoa text system but not representable with standard RTF. The Apple extensions take the same form as standard RTF commands, groups, and escapes. RTF commands consist of a backslash followed by a string of alphabetic characters (case sensitive) followed by an optional integer parameter value which can be positive or negative. RTF groups begin with a left brace ({), followed by RTF sequences optionally including other groups, closed by a right brace (}). RTF escapes consist of a backslash followed by a special character, such as \{, which indicates a literal left brace instead of the beginning of a group.

    • Apple扩展了RTF语言以支持Cocoa文本系统中可用的文本属性和格式化结构,但不能用标准RTF表示。 Apple扩展采用与标准RTF命令,组和转义相同的形式。 RTF命令由反斜杠后跟一串字母字符(区分大小写)后跟可选的整数参数值组成,后者可以是正数或负数。 RTF组以左括号({)开头,然后是RTF序列,可选地包括其他组,由右括号(})关闭。 RTF转义包含一个反斜杠后跟一个特殊字符,例如\ {,表示一个文字左括号而不是一个组的开头。

    RTF includes the concept of a destination, which is a group containing an RTF command and text possibly to be inserted at a different location in a document, such as a footnote. The escape sequence \* indicates that RTF readers that don’t understand the command that follows should ignore the contents of the destination.

    • RTF包括目的地的概念,目的地是包含RTF命令和可能插入文档中不同位置的文本的组,例如脚注。 转义序列\ *表示不理解后面的命令的RTF读取器应忽略目标的内容。

    Dimensions in RTF are expressed in twips—one twip is one twentieth of a point.

    • RTF中的尺寸以缇表示 - 一个缇是一个点的二十分之一。

    Table 1 lists Apple’s RTF extensions for character attributes.


    image.png

    未完待续。。。

    相关文章

      网友评论

          本文标题:07. RTF Files and Attributed Str

          本文链接:https://www.haomeiwen.com/subject/ohxitqtx.html