The identifiers listed in Table 1 are global NSString
constants containing the attribute names. The value class is the class of the value corresponding to that attribute.
- 表1中列出的标识符是包含属性名称的全局NSString常量。 值类是与该属性对应的值的类。

The natures of several attributes are not obvious from name alone:
-
The baseline offset attribute is a literal distance, in pixels, by which the characters should be shifted above the baseline (for positive offsets) or below (for negative offsets).
- 基线偏移属性是字面距离(以像素为单位),通过该距离,字符应移至基线以上(正偏移)或低于(对于负偏移)。
-
The kerning attribute indicates how much the following character should be shifted from its default offset as defined by the current character’s font; a positive kern indicates a shift farther along and a negative kern indicates a shift closer to the current character.
- 字距调整属性表示后续字符应从当前字符字体定义的默认偏移量中移出多少; 正kern表示更远的移位,而负kern表示更接近当前字符的移位。
-
The ligature attribute determines what kinds of ligatures should be used when displaying the string. A value of 0 indicates that only ligatures essential for proper rendering of text should be used, 1 indicates that standard ligatures should be used, and 2 indicates that all available ligatures should be used. Which ligatures are standard depends on the script and possibly the font. Arabic text, for example, requires ligatures for many character sequences, but has a rich set of additional ligatures that combine characters. English text has no essential ligatures, and typically has only two standard ligatures, those for “fi” and “fl”—all others being considered more advanced or fancy.
- ligature属性确定在显示字符串时应使用哪种连字。 值0表示仅应使用对于正确呈现文本必不可少的连字,1表示应使用标准连字,2表示应使用所有可用连字。 哪些连字是标准的取决于脚本和可能的字体。 例如,阿拉伯语文本需要许多字符序列的连字,但是有一组丰富的组合字符的附加连字。 英文文本没有必要的连字,通常只有两个标准连字,“fi”和“fl” - 所有其他被认为更高级或更花哨。
-
The link attribute specifies an arbitrary object that is passed to the
NSTextView
methodclickedOnLink:atIndex:
when the user clicks in the text range associated with theNSLinkAttributeName
attribute. The text view’s delegate object can implementtextView:clickedOnLink:atIndex:
ortextView:clickedOnLink:
to process the link object. Otherwise, the default implementation checks whether the link object is anNSURL
object and, if so, opens it in the URL’s default application.- link属性指定传递给NSTextView方法的任意对象clickedOnLink:atIndex:当用户单击与NSLinkAttributeName属性关联的文本范围时。 文本视图的委托对象可以实现textView:clickedOnLink:atIndex:或textView:clickedOnLink:来处理链接对象。 否则,默认实现检查链接对象是否为NSURL对象,如果是,则在URL的默认应用程序中打开它。
-
The superscript attribute indicates an abstract level for both super- and subscripts. The user of the attributed string can interpret this as desired, adjusting the baseline by the same or a different amount for each level, changing the font size, or both.
- 上标属性表示超级和下标的抽象级别。 属性字符串的用户可以根据需要对其进行解释,为每个级别调整基线相同或不同的数量,更改字体大小或两者。
-
The underline attribute has only two values defined,
NSNoUnderlineStyle
andNSSingleUnderlineStyle
, but these can be combined withNSUnderlineByWordMask
andNSUnderlineStrikethroughMask
to extend their behavior. By bitwise-ORing these values in different combinations, you can specify no underline, a single underline, a single strikethrough, both an underline and a strikethrough, and whether the line is drawn for whitespace or not.- underline属性只定义了两个值NSNoUnderlineStyle和NSSingleUnderlineStyle,但这些值可以与NSUnderlineByWordMask和NSUnderlineStrikethroughMask结合使用以扩展它们的行为。 通过以不同的组合对这些值进行按位或运算,您可以指定无下划线,单个下划线,单个删除线,下划线和删除线,以及是否为空白绘制线。
网友评论