NSGlyphInfo Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.2 and later.
Companion guide
Declared in
NSGlyphInfo.h

Overview

An NSGlyphInfo object represents a glyph attribute value (NSGlyphInfoAttributeName) in an attributed string (NSAttributedString). 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 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).

Adopted Protocols

NSCoding

Tasks

Creating an NSGlyphInfo Object

Getting Information About an NSGlyphInfo Object

Class Methods

glyphInfoWithCharacterIdentifier:collection:baseString:

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

+ (NSGlyphInfo *)glyphInfoWithCharacterIdentifier:(NSUInteger)cid collection:(NSCharacterCollection)characterCollection baseString:(NSString *)theString
Parameters
cid

A character identifier.

characterCollection

A string constant representing a character collection. Possible values for characterCollection are described in “Constants.”

theString

The part of the attributed string the returned instance is intended to override.

Return Value

The created NSGlyphInfo object or nil if the object couldn't be created.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSGlyphInfo.h

glyphInfoWithGlyph:forFont:baseString:

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

+ (NSGlyphInfo *)glyphInfoWithGlyph:(NSGlyph)glyph forFont:(NSFont *)font baseString:(NSString *)theString
Parameters
glyph

The identifier of the glyph.

font

The font object to be associated with the returned NSGlyphInfo object,

theString

The part of the attributed string the returned instance is intended to override.

Return Value

The created NSGlyphInfo object or nil if the object couldn't be created.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSGlyphInfo.h

glyphInfoWithGlyphName:forFont:baseString:

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

+ (NSGlyphInfo *)glyphInfoWithGlyphName:(NSString *)glyphName forFont:(NSFont *)font baseString:(NSString *)theString
Parameters
glyphName

The name of the glyph.

font

The font object to be associated with the returned NSGlyphInfo object,

theString

The part of the attributed string the returned instance is intended to override.

Return Value

The created NSGlyphInfo object or nil if the object couldn't be created.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSGlyphInfo.h

Instance Methods

characterCollection

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

- (NSCharacterCollection)characterCollection
Discussion

This method returns NSIdentityMappingCharacterCollection if the receiver was instantiated with either an NSGlyph identifier or a glyph name. It returns other possible values if the receiver was instantiated using glyphInfoWithCharacterIdentifier:collection:baseString:. These constants are described in NSCharacterCollection.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSGlyphInfo.h

characterIdentifier

Returns the receiver’s character identifier (CID).

- (NSUInteger)characterIdentifier
Discussion

If the receiver was instantiated with a method other than glyphInfoWithCharacterIdentifier:collection:baseString:, this method returns NULL.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSGlyphInfo.h

glyphName

Returns the receiver’s glyph name.

- (NSString *)glyphName
Discussion

If the receiver was instantiated with a method other than glyphInfoWithGlyphName:forFont:baseString:, this method returns nil.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSGlyphInfo.h

Constants

NSCharacterCollection

The following values specify the mapping of character identifiers to glyphs, and are returned by characterCollection.

typedef enum {
   NSIdentityMappingCharacterCollection = 0,
   NSAdobeCNS1CharacterCollection       = 1,
   NSAdobeGB1CharacterCollection        = 2,
   NSAdobeJapan1CharacterCollection     = 3,
   NSAdobeJapan2CharacterCollection     = 4,
   NSAdobeKorea1CharacterCollection     = 5,
} NSCharacterCollection;
Constants
NSIdentityMappingCharacterCollection

Indicates that the character identifier is equal to the glyph index.

Available in OS X v10.2 and later.

Declared in NSGlyphInfo.h.

NSAdobeCNS1CharacterCollection

Indicates the Adobe-CNS1 mapping.

Available in OS X v10.2 and later.

Declared in NSGlyphInfo.h.

NSAdobeGB1CharacterCollection

Indicates the Adobe-GB1 mapping.

Available in OS X v10.2 and later.

Declared in NSGlyphInfo.h.

NSAdobeJapan1CharacterCollection

Indicates the Adobe-Japan1 mapping.

Available in OS X v10.2 and later.

Declared in NSGlyphInfo.h.

NSAdobeJapan2CharacterCollection

Indicates the Adobe-Japan2 mapping.

Available in OS X v10.2 and later.

Declared in NSGlyphInfo.h.

NSAdobeKorea1CharacterCollection

Indicates the Adobe-Korea1 mapping.

Available in OS X v10.2 and later.

Declared in NSGlyphInfo.h.

Availability
  • Available in OS X v10.2 and later.
Declared In
NSGlyphInfo.h