Contents

setIntAttribute(_:value:forGlyphAt:)

Sets a custom attribute value for a given glyph.

Declaration

func setIntAttribute(_ attributeTag: Int, value val: Int, forGlyphAt glyphIndex: Int)

Parameters

  • attributeTag:

    The custom attribute.

  • val:

    The new attribute value.

  • glyphIndex:

    Index of the glyph whose attribute is set.

Discussion

Custom attributes are glyph attributes such as NSGlyphInscription or attributes defined by subclasses. Nonnegative tags are reserved by Apple; you can define your own attributes with negative tags and set values using this method.

This method is part of the NSGlyphStorage protocol, for use by the glyph generator to set attributes. It is not usually necessary for anyone but the glyph generator (and perhaps the typesetter) to call it. It is provided as a public method so subclasses can extend it to accept other glyph attributes. To add new glyph attributes to the text system you must do two things. First, you need to arrange for the glyph generator or typesetter to generate and interpret it. Second, you need to subclass NSLayoutManager to provide someplace to store the new attribute, overriding this method and intAttribute(_:forGlyphAt:) to recognize the new attribute tags and respond to them, while passing any other attributes to the superclass implementation. The NSLayoutManager implementation understands the glyph attributes which it is prepared to store, as enumerated in Glyph Attributes.

See Also

Methods