Class

NSTypesetter

An abstract class that performs various type layout tasks.

Declaration

@interface NSTypesetter : NSObject

Overview

NSLayoutManager 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 NSATSTypesetter.

Subclassing Notes

NSTypesetter provides concrete subclasses with default implementation interfacing with the Cocoa text system. By subclassing NSTypesetter, an application can override the layoutParagraphAtPoint: 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 NSLayoutManager 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

Topics

Getting a Typesetter

sharedSystemTypesetter

Returns a shared instance of a reentrant typesetter.

+ sharedSystemTypesetterForBehavior:

Returns a shared instance of a reentrant typesetter that implements typesetting with the specified behavior.

Getting Information About a Typesetter

defaultTypesetterBehavior

Returns the default typesetter behavior.

Getting Information About Glyphs

+ printingAdjustmentInLayoutManager:forNominallySpacedGlyphRange:packedGlyphs:count:

Returns the interglyph spacing in the specified range when sent to a printer.

- baselineOffsetInLayoutManager:glyphIndex:

Returns the distance from the bottom of the line fragment rectangle in which the glyph resides to the glyph baseline.

Managing the Layout Manager

layoutManager

Returns the layout manager for the text being typeset.

usesFontLeading

Returns whether the typesetter uses the leading (or line gap) value specified in the font metric information of the current font.

typesetterBehavior

Returns the current typesetter behavior.

hyphenationFactor

Returns the current hyphenation factor.

Managing Text Containers

currentTextContainer

Returns the text container for the text being typeset.

textContainers

Returns an array containing the text containers belonging to the current layout manager.

lineFragmentPadding

Returns the current line fragment padding, in points.

Mapping Screen and Printer Fonts

- substituteFontForFont:

Returns a screen font suitable for use in place of a given font.

Handling Control Characters

- textTabForGlyphLocation:writingDirection:maxLocation:

Returns the text tab next closest to a given glyph location within the given parameters.

- actionForControlCharacterAtIndex:

Returns the action associated with a control character.

Deprecated

Bidirectional Text Processing

bidiProcessingEnabled

Returns whether bidirectional text processing is enabled.

Accessing Paragraph Typesetting Information

currentParagraphStyle

Returns the paragraph style object for the text being typeset.

attributedString

Returns the text backing store, usually an instance of NSTextStorage.

- setParagraphGlyphRange:separatorGlyphRange:

Sets the current glyph range being processed.

paragraphGlyphRange

Returns the glyph range currently being processed.

paragraphSeparatorGlyphRange

Returns the current paragraph separator range.

paragraphCharacterRange

Returns the character range currently being processed.

paragraphSeparatorCharacterRange

Returns the current paragraph separator character range.

attributesForExtraLineFragment

Returns the attributes used to lay out the extra line fragment.

Paragraph Layout

- layoutParagraphAtPoint:

Lays out glyphs in the current glyph range until the next paragraph separator is reached.

- beginParagraph

Sets up layout parameters at the beginning of a paragraph.

- endParagraph

Sets up layout parameters at the end of a paragraph.

- beginLineWithGlyphAtIndex:

Sets up layout parameters at the beginning of a line during typesetting.

- endLineWithGlyphRange:

Sets up layout parameters at the end of a line during typesetting.

Character Layout

- layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments:

Lays out characters in the given character range for the specified layout manager.

Line and Paragraph Spacing

- lineSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:

Returns the line spacing in effect following the specified glyph.

- paragraphSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:

Returns the paragraph spacing that is in effect after the specified glyph.

- paragraphSpacingBeforeGlyphAtIndex:withProposedLineFragmentRect:

Returns the number of points of space—added before a paragraph—that is in effect before the specified glyph.

Glyph Caching

- setHardInvalidation:forGlyphRange:

Sets whether to force the layout manager to invalidate the specified portion of the glyph cache when invalidating layout.

Laying out Glyphs

- layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:nextGlyphIndex:

Lays out glyphs in the specified layout manager starting at a specified glyph.

- boundingBoxForControlGlyphAtIndex:forTextContainer:proposedLineFragment:glyphPosition:characterIndex:

Returns the bounding rectangle for the specified control glyph with the specified parameters.

- getLineFragmentRect:usedRect:forParagraphSeparatorGlyphRange:atProposedOrigin:

Calculates the line fragment rectangle and line fragment used rectangle for blank lines.

- getLineFragmentRect:usedRect:remainingRect:forStartingGlyphAtIndex:proposedRect:lineSpacing:paragraphSpacingBefore:paragraphSpacingAfter:

Calculates line fragment rectangle, line fragment used rectangle, and remaining rectangle for a line fragment.

- hyphenCharacterForGlyphAtIndex:

Returns the hyphen character to be inserted after the specified glyph.

- hyphenationFactorForGlyphAtIndex:

Returns the hyphenation factor in effect at a specified location.

- shouldBreakLineByHyphenatingBeforeCharacterAtIndex:

Returns whether the line being laid out should be broken by hyphenating at the specified character.

- shouldBreakLineByWordBeforeCharacterAtIndex:

Returns whether the line being laid out should be broken by a word break at the specified character.

- willSetLineFragmentRect:forGlyphRange:usedRect:baselineOffset:

Called by the typesetter just prior to storing the actual line fragment rectangle location in the layout manager.

Interfacing with Glyph Storage

- characterRangeForGlyphRange:actualGlyphRange:

Returns the range for the characters in the receiver’s text store that are mapped to the specified glyphs.

- deleteGlyphsInRange:

Deletes the specified glyphs from the glyph cache maintained by the layout manager.

Deprecated
- substituteGlyphsInRange:withGlyphs:

Replaces the specified glyphs with specified replacement glyphs.

Deprecated
- getGlyphsInRange:glyphs:characterIndexes:glyphInscriptions:elasticBits:bidiLevels:

Extracts the information needed to lay out the provided glyphs from the provided range.

Deprecated
- glyphRangeForCharacterRange:actualCharacterRange:

Returns the range for the glyphs mapped to the characters of the text store in the specified range.

- insertGlyph:atGlyphIndex:characterIndex:

Enables the typesetter to insert a new glyph into the stream.

Deprecated
- setAttachmentSize:forGlyphRange:

Sets the size the specified glyphs (assumed to be attachments) will be asked to draw themselves at.

- setBidiLevels:forGlyphRange:

Sets the direction of the specified glyphs for bidirectional text.

- setDrawsOutsideLineFragment:forGlyphRange:

Sets whether the specified glyphs exceed the bounds of the line fragment in which they are laid out.

- setLineFragmentRect:forGlyphRange:usedRect:baselineOffset:

Sets the line fragment rectangle where the specified glyphs are laid out.

- setLocation:withAdvancements:forStartOfGlyphRange:

Sets the location where the specified glyphs are laid out.

- setNotShownAttribute:forGlyphRange:

Sets whether the specified glyphs are not shown.

Constants

NSTypesetterControlCharacterAction

The following constants are possible values returned by the actionForControlCharacterAtIndex: method to determine the action associated with a control character.

Relationships

Inherits From

See Also

Layout

NSLayoutManager

An object that coordinates the layout and display of characters held in an NSTextStorage object.

NSLayoutManagerDelegate

A set of optional methods implemented by delegates of NSLayoutManager objects.

NSTextContainer

A region where text is laid out.

NSTextBlock

A block of text laid out in a subregion of the text container.

NSATSTypesetter

A concrete subclass of NSTypesetter that places glyphs during the text layout process.

NSTextLayoutOrientationProvider

A set of methods that define the orientation of text for an object.