Home

NSLayoutManager

NSLayoutManager is a class in Apple's Text Kit framework that coordinates the layout and rendering of text. It sits between NSTextStorage, which holds the underlying characters and attributes, and NSTextContainer, which defines the region where text is laid out. An NSLayoutManager can manage multiple NSTextContainers, allowing text to be laid out across several regions or views.

Its responsibilities include creating and mapping glyphs from characters, laying out lines, handling hyphenation and justification,

Interaction with the system is provided through the NSLayoutManagerDelegate protocol, which enables customization of layout behavior

Typical usage: a single layout manager can back a NSTextView or other views; multiple text containers can

History: NSLayoutManager was introduced with Text Kit in OS X 10.8 and iOS 7 and remains a

wrapping
and
truncation,
and
drawing
the
laid-out
glyphs
within
the
containers’
coordinate
system.
It
provides
conversions
between
character
ranges
and
glyph
ranges
and
a
drawing
API
to
render
glyphs
at
a
specified
point.
such
as
line
fragment
rectangles,
glyph
generation,
and
invalidation.
When
the
NSTextStorage
changes,
the
layout
manager
recalculates
the
layout
and
informs
its
text
containers
to
redraw.
share
the
same
layout
manager,
enabling
non-uniform
layouts.
The
component
is
central
to
rich
text
editing
and
complex
typography
beyond
simple
labels.
core
element
of
advanced
text
rendering
in
Apple
platforms.