A glyph attribute in an attributed string.


Glyphs are the graphic representations of characters, stored in a font, that the text system draws on a display or printed page. Before text can be laid out, the layout manager (NSLayoutManager) generates a stream of glyphs to be laid out, using character and font information specified by the attributed string and contained in the font file. NSGlyphInfo represents a glyph attribute value (glyphInfo) in an attributed string (NSAttributedString) and provides a means to override the standard glyph generation process and substitute a specified glyph over the attribute’s range.

Glyph attributes are integer values that the layout manager uses to denote special handling for particular glyphs during rendering. NSGlyphInfo enables you to override a font’s built-in mapping from a Unicode character code to a corresponding glyph ID. Overriding the mapping allows you to specify a variant glyph for a given character if the font contains multiple variations for that character or to specify a glyph that doesn’t have a standard mapping (such as some ligature glyphs).


Creating an NSGlyphInfo Object

init?(characterIdentifier: Int, collection: NSCharacterCollection, baseString: String)

Instantiates and returns an NSGlyphInfo object using a character identifier and a character collection.

init?(glyph: NSGlyph, for: NSFont, baseString: String)

Instantiates and returns an NSGlyphInfo object using a glyph index and a specified font.

init?(glyphName: String, for: NSFont, baseString: String)

Instantiates and returns an NSGlyphInfo object using a glyph name and a specified font.


Getting Information About an NSGlyphInfo Object

var characterIdentifier: Int

The receiver’s character identifier (CID).

var characterCollection: NSCharacterCollection

an NSCharacterCollection value specifying the glyph–to–character identifier mapping of the receiver.

var glyphName: String?

The receiver’s glyph name.



enum NSCharacterCollection

Values returned by characterCollection to specify the mapping of character identifiers to glyphs.


Inherits From

See Also


typealias NSGlyph

The type used to specify glyphs.

protocol NSGlyphStorage

A set of methods that a glyph storage object must implement to interact properly with NSGlyphGenerator.

class NSGlyphGenerator

An object that performs the initial, nominal glyph generation phase in the layout process.

Glyph Attributes

Attributes that are used only inside the glyph generation machinery, but must also be shared between components.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software