Introduction to Text Layout Programming Guide
Text Layout Programming Guide describes how the Cocoa text system lays out text. Text layout is the process of converting a string of text characters, font information, and page specifications into lines of glyphs placed at specific locations on a page, suitable for display and printing.
Who Should Read This Document
You should read this document if you need to understand how the text system layout mechanism works and how to work directly with an
NSLayoutManager object to accomplish the programming goals described in the articles.
To understand the information in this document, you should have read Cocoa Text Architecture Guide. You should also understand basic Cocoa programming conventions, such as delegation.
Organization of This Document
This programming topic contains the following articles:
“Typesetters” describes the responsibilities of the typesetter object, instantiated from a concrete subclass of
NSTypesetter, which generates the line fragments and glyph positions on behalf of the layout manager.
“Line Fragment Generation” explains how the typesetter and text container work together to create line fragment rectangles.
“Drawing Strings” explains how to use the layout manager, rather than
NSStringconvenience methods, to draw strings of text efficiently.
“Laying Out Text Along an Arbitrary Path” shows how to use the layout manager without a text view to lay out glyphs along a calculated path.
“Calculating Text Height” shows how to determine the height of a block of text laid out in a fixed-width area.
“Counting Lines of Text” explains how you can programmatically count the number of lines in a string of text, whether the lines are defined by hard line-break characters or laid out in a text container.
“Using Text Tables” explains how you can add text table support to your application in OS X version 10.4 and later.
For further reading, refer to the following documents:
Text System Storage Layer Overview discusses the facilities that the Cocoa text system uses to store the text and geometric shape information used for text layout.
Text Attribute Programming Topics describes the text-related attributes maintained by the Cocoa text system, which provide the distinguishing characteristics of rich text and other formatting information for paragraphs and documents.