So far, we've only looked at how blocks of text are drawn. This is quite a low-level mechanism, and is affected by higher-level aspects of the text. We saw how the typesetter used fonts in text attributes for finding glyphs, but it also reads other attributes to determine some aspects of the shape of the textmost importantly, the paragraph style, stored in an NSParagraphStyle instance.
This class contains a lot of metadata about the paragraph. In particular, it describes whitespace in and around the paragraph. This object is responsible for describing the location of tab stops, which defines how the typesetter should interpret the tab character in input. The tab character means "advance the insertion point to the next tabulator," and the location of the tabulators must be defined for this system to work.
The paragraph style also defines the amount of empty space before and after the paragraph, as well as the indent level of the first line. More interestingly, since OS X 10.4, it has allowed adjustment of the hyphenation threshold. This means that it's possible to control how enthusiastic the typesetter will be to hyphenate words on a per-paragraph basis.
You can control a lot of aspects of layout simply by setting the paragraph style attribute in an attributed string, without touching any of the lower-level bits of the text system.
One things that you'll notice about this class is that it allows some slightly unusual-seeming line-wrapping options. These options include truncating in the middle or at the end, rather than wrappingsomething that you're unlikely to want to do when laying out a paragraph of text in a document. These options exist because the entire text system is used throughout Cocoa, anywhere text is rendered. Whether you're drawing the caption for a button or a menu item, you're using the same layout code as when you display a Rich Text document.