The CTTypesetter opaque type represents a typesetter, which performs line layout.


Line layout includes word wrapping, hyphenation, and line breaking in either vertical or horizontal rectangles. A typesetter object takes as input an attributed string and produces a line of typeset glyphs (composed into glyph runs) in a CTLine object. The typesetter performs character-to-glyph encoding, glyph ordering, and positional operations, such as kerning, tracking, and baseline adjustments. If multiline layout is needed, it is performed by a framesetter object, which calls into the typesetter to generate the typeset lines to fill the frame.

A framesetter encapsulates a typesetter and provides a reference to it as a convenience, but a caller may also choose to create a freestanding typesetter.


Creating a Typesetter

func CTTypesetterCreateWithAttributedString(CFAttributedString) -> CTTypesetter

Creates an immutable typesetter object using an attributed string.

func CTTypesetterCreateWithAttributedStringAndOptions(CFAttributedString, CFDictionary?) -> CTTypesetter?

Creates an immutable typesetter object using an attributed string and a dictionary of options.

Creating Lines

func CTTypesetterCreateLine(CTTypesetter, CFRange) -> CTLine

Creates an immutable line from the typesetter.

func CTTypesetterCreateLineWithOffset(CTTypesetter, CFRange, Double) -> CTLine

Creates an immutable line from the typesetter at a specified line offset.

Breaking Lines

func CTTypesetterSuggestLineBreak(CTTypesetter, CFIndex, Double) -> CFIndex

Suggests a contextual line breakpoint based on the width provided.

func CTTypesetterSuggestLineBreakWithOffset(CTTypesetter, CFIndex, Double, Double) -> CFIndex

Suggests a contextual line breakpoint based on the width provided and the specified offset.

func CTTypesetterSuggestClusterBreak(CTTypesetter, CFIndex, Double) -> CFIndex

Suggests a cluster line breakpoint based on the width provided.

func CTTypesetterSuggestClusterBreakWithOffset(CTTypesetter, CFIndex, Double, Double) -> CFIndex

Suggests a cluster line breakpoint based on the specified width and line offset.

Getting the Type Identifier

func CTTypesetterGetTypeID() -> CFTypeID

Returns the Core Foundation type identifier of the typesetter object.

Data Types

class CTTypesetter

A reference to a typesetter object.


Typesetter Options

These constants control aspects of the typesetter’s bidirectional text processing.

See Also

Opaque Types


The CTFont opaque type represents a Core Text font object. Font objects represent fonts to an application, providing access to characteristics of the font, such as point size, transform matrix, and other attributes. Fonts provide assistance in laying out glyphs relative to one another and are used to establish the current font when drawing in a graphics context.


The CTFontCollection opaque type represents a font collection, that is, a group of font descriptors taken together as a single object.


The CTFontDescriptor opaque type represents a font descriptor, that is, a dictionary of attributes (such as name, point size, and variation) that can completely specify a font.


The CTFrame opaque type represents a frame containing multiple lines of text. The frame object is the output resulting from the text-framing process performed by a framesetter object.


The CTFramesetter opaque type is used to generate text frames. That is, CTFramesetter is an object factory for CTFrame objects.


The CTGlyphInfo opaque type enables you to override a font's specified mapping from Unicode to the glyph ID.


The CTLine opaque type represents a line of text.


The CTParagraphStyle opaque type represents paragraph or ruler attributes in an attributed string.


The CTRun opaque type represents a glyph run, which is a set of consecutive glyphs sharing the same attributes and direction.


The CTRunDelegate opaque type represents a run delegate, which is assigned to a run (attribute range) to control typographic traits such glyph ascent, glyph descent, and glyph width.


The CTTextTab opaque type represents a tab in a paragraph style, storing an alignment type and location.