An abstract class that performs various type layout tasks.
- macOS 10.0+
NSLayout uses concrete subclasses of
NSTypesetter to perform line layout, which includes word wrapping, hyphenation, and line breaking in either vertical or horizontal rectangles. By default, the text system uses the concrete subclass
NSTypesetter provides concrete subclasses with default implementation interfacing with the Cocoa text system. By subclassing
NSTypesetter, an application can override the
layout method to integrate a custom typesetting engine into the Cocoa text system. On the other hand, an application can subclass
NSATSTypesetter and override the glyph storage interface to integrate the concrete subclass into its own custom layout system.
NSTypesetter methods belong to three categories: glyph storage interface methods, layout phase interface methods, and core typesetter methods. The glyph storage interface methods map to
NSLayout methods. The typesetter itself calls these methods, and their default implementations call the Cocoa layout manager. An
NSTypesetter subclass can override these methods to call its own glyph storage facility, in which case it should override all of them. (This does not preclude the overridden method calling its superclass implementation if appropriate.)
The layout phase interface provides control points similar to delegate methods; if implemented, the system invokes these methods to notify an
NSTypesetter subclass of events in the layout process so it can intervene as needed.
The remainder of the
NSTypesetter methods are primitive, core typesetter methods. The core typesetter methods correlate with typesetting state attributes; the layout manager calls these methods to store its values before starting the layout process. If you subclass
NSTypesetter and override the glyph storage interface methods, you can call the core methods to control the typesetter directly.
Glyph Storage Interface
Override these methods to use
NSTypesetter’s built-in concrete subclass,
NSATSTypesetter, with a custom glyph storage and layout system other than the Cocoa layout manager and text container mechanism.
Layout Phase Interface
Override these methods to customize the text layout process, including modifying line fragments, controlling line breaking and hyphenation, and controlling the behavior of tabs and other control glyphs.