Class

NSATSTypesetter

NSATSTypesetter is a concrete subclass of NSTypesetter that places glyphs during the text layout process. The typesetter creates line fragment rectangles, positions glyphs within the line fragments, determines line breaks by word wrapping and hyphenation, and handles tab positioning.

Overview

NSATSTypesetter encapsulates the advanced typesetting capabilities of Core Text. NSATSTypesetter provides enhanced line and character spacing accuracy and supports more languages, including bidirectional languages, than the original, built-in typesetter class NSSimpleHorizontalTypesetter (which is deprecated in macOS 10.4 and later).

Subclassing

NSATSTypesetter introduced a set of interfaces in OS X version 10.3 that facilitated subclassing and made it possible to substitute a custom layout engine into the Cocoa text system. In OS X version 10.4, those interfaces moved to NSTypesetter, which you can subclass to the same effect. See the NSTypesetter reference documentation for relevant subclassing notes.

Symbols

Getting a typesetter

class func shared()

Returns a shared instance of NSATSTypesetter.

Managing the layout manager

var layoutManager: NSLayoutManager?

The layout manager for the text being typeset.

var usesFontLeading: Bool

A Boolean value controlling whether the typesetter uses the leading (or line gap) value specified in the font metric information.

var typesetterBehavior: NSTypesetterBehavior

The current typesetter behavior value.

var hyphenationFactor: Float

The threshold controlling when hyphenation is attempted

Managing the text container

var currentTextContainer: NSTextContainer?

The text container for the text being typeset.

var lineFragmentPadding: CGFloat

The amount (in points) by which text is inset within line fragment rectangles

Mapping screen and printer fonts

func substituteFont(for: NSFont)

Returns a screen font suitable for use in place of the specified original font, or simply returns the original font if a screen font can’t be used or isn’t available.

Managing text tabs

func textTab(forGlyphLocation: CGFloat, writingDirection: NSWritingDirection, maxLocation: CGFloat)

Returns the text tab next closest to a given glyph location, indexing in the specified direction but not beyond a given glyph location.

Bidirectional text processing

var bidiProcessingEnabled: Bool

A Boolean value controlling whether the typesetter performs bidirectional text processing.

Accessing paragraph typesetting information

var attributedString: NSAttributedString?

The text backing store on which this typesetter operates.

func setParagraphGlyphRange(NSRange, separatorGlyphRange: NSRange)

Sets the current glyph range being processed and the paragraph separator glyph range (the range of the paragraph separator character or characters).

var paragraphGlyphRange: NSRange

The current glyph range being processed

var paragraphSeparatorGlyphRange: NSRange

The current paragraph separator range, which is the full range that contains the current glyph range and that extends from one paragraph separator character to the next.

Paragraph layout

func layoutParagraph(at: UnsafeMutablePointer<NSPoint>)

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

Line and paragraph spacing

func lineSpacing(afterGlyphAt: Int, withProposedLineFragmentRect: NSRect)

Returns the line spacing in effect following the specified glyph.

func paragraphSpacing(afterGlyphAt: Int, withProposedLineFragmentRect: NSRect)

Returns the paragraph spacing, the number of points of space added following a paragraph, which is in effect after the specified glyph.

func paragraphSpacing(beforeGlyphAt: Int, withProposedLineFragmentRect: NSRect)

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

Glyph caching

func setHardInvalidation(Bool, forGlyphRange: NSRange)

Sets a Boolean value controlling whether to force the layout manager to invalidate the portion of the glyph cache in the given glyph range when invalidating layout.

Laying out glyphs

func boundingBox(forControlGlyphAt: Int, for: NSTextContainer, proposedLineFragment: NSRect, glyphPosition: NSPoint, characterIndex: Int)

Returns the bounding rectangle for the given control glyph, at the given glyph position and character index, in the given text container.

func hyphenCharacter(forGlyphAt: Int)

Returns the hyphen character to be inserted after the given glyph when hyphenation is enabled in the layout manager.

func hyphenationFactor(forGlyphAt: Int)

Returns the hyphenation factor in effect at the given glyph index.

func shouldBreakLine(byHyphenatingBeforeCharacterAt: Int)

The typesetter calls this method, if implemented by a subclass, before breaking a line by hyphenating before the character at the given character index, enabling the subclass to control line breaking.

func shouldBreakLine(byWordBeforeCharacterAt: Int)

The typesetter calls this method, if implemented by a subclass, before breaking a line by word wrapping before the character at the given character index, enabling the subclass to control line breaking.

Interfacing with glyph storage

func characterRange(forGlyphRange: NSRange, actualGlyphRange: NSRangePointer?)

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

func deleteGlyphs(in: NSRange)

Deletes the glyphs in the given glyph range from the glyph cache maintained by the layout manager.

func glyphRange(forCharacterRange: NSRange, actualCharacterRange: NSRangePointer?)

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

func insertGlyph(NSGlyph, atGlyphIndex: Int, characterIndex: Int)

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

func setAttachmentSize(NSSize, forGlyphRange: NSRange)

Sets the size the glyphs in the given glyph range (assumed to be attachments) will be asked to draw themselves.

func setBidiLevels(UnsafePointer<UInt8>!, forGlyphRange: NSRange)

Sets the direction of the glyphs in the given glyph range for bidirectional text to the given levels.

func setDrawsOutsideLineFragment(Bool, forGlyphRange: NSRange)

Sets a Boolean value controlling whether the glyphs in the given glyph range exceed the bounds of the line fragment in which they are laid out.

func setLineFragmentRect(NSRect, forGlyphRange: NSRange, usedRect: NSRect, baselineOffset: CGFloat)

Sets the line fragment rectangle where the glyphs in in the given glyph range are laid out to the given line fragment rectangle.

func setLocation(NSPoint, withAdvancements: UnsafePointer<CGFloat>!, forStartOfGlyphRange: NSRange)

Sets the location where the glyphs in the given glyph range are laid out to the specified location.

func setNotShownAttribute(Bool, forGlyphRange: NSRange)

Sets a Boolean value controlling whether the glyphs in the given glyph rangeare not shown.

func substituteGlyphs(in: NSRange, withGlyphs: UnsafeMutablePointer<NSGlyph>!)

Replaces the glyphs in the given glyph range with the given glyphs.

Relationships

Inherits From

Conforms To