Text Handling Technologies in OS X
The Macintosh operating system has provided sophisticated text handling and typesetting capabilities from its beginning. In fact, these features sparked the desktop publishing revolution. Over the years, the text handling facilities of the platform have continued to evolve to become more advanced, more efficient, and easier to use. OS X provides modern text handling capabilities that are available to all applications through the classes of the Cocoa text system and the opaque types and functions of Core Text.
The text-handling component of any application presents one of the greatest challenges to software designers. Even the most basic text-handling system must be relatively sophisticated, allowing for text input, layout, display, editing, copying and pasting, and many other features. But developers and users expect even more than these basic features, expecting even simple editors to support multiple fonts, various paragraph styles, embedded images, spell checking, and other features.
The Cocoa text system provides all these basic and advanced text-handling features, and it also satisfies additional requirements from the ever-more-interconnected computing world: support for the character sets of all of the world’s living languages, powerful layout capabilities to handle various text directionality and nonrectangular text containers, and sophisticated typesetting capabilities such as control of kerning and ligatures. Cocoa’s object-oriented text system is designed to provide all these capabilities without requiring you to learn about or interact with more of the system than is necessary to meet the needs of your application.
Underlying the Cocoa text system is Core Text, which provides low-level, basic text layout and font-handling capabilities to higher-level engines such as AppKit, WebKit, and others. Core Text provides the implementation for many Cocoa text technologies. Application developers typically have no need to use Core Text directly. However, the Core Text API is accessible to developers who must use it directly, such as those writing applications with their own layout engine and those porting ATSUI- or QuickDraw-based codebases to the modern world.
To decide which OS X text technology is right for your application, apply the following guidelines:
If possible, use Cocoa text. The
NSTextView
class is the most advanced full-featured, flexible text view in OS X. For small amounts of text, useNSTextField
. For more information about text views, see Text System User Interface Layer Programming Guide.To display web content in your application, use WebKit. For more information about WebKit, see WebKit Objective-C Programming Guide.
If you have your own page layout engine, you can use Core Text to generate the glyphs and position them relative to each other. For more information about Core Text, see Core Text Programming Guide.
Copyright © 2014 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2014-02-11