Re: ATSUI vs NSTextView?
Re: ATSUI vs NSTextView?
- Subject: Re: ATSUI vs NSTextView?
- From: Douglas Davidson <email@hidden>
- Date: Tue, 28 Aug 2001 09:35:10 -0700
On Tuesday, August 28, 2001, at 05:07 AM, David Masters wrote:
I'm writing a Cocoa application that will require fine control over
typography (kerning, tracking, possibly text on a curve) for relatively
small amounts of text, and so far the main alternatives seem to be
either to work with ATSUI directly, or utilise NSTextView and
associated classes.
Example source code for ATSUI seems to be scarce (apart from Apple's
TypeServicesForUnicode example) - does this imply that most people
prefer not to work directly with ATSUI? From reading the documentation,
it appears that NSTextView is extremely powerful, and calls ATSUI
anyway. So, if I go with NSTextView and related classes such as
NSAttributedString instead, are there any features or functionality
from ATSUI I'll be missing out on, or any performance penalties that I
might encounter?
I can't really make a recommendation as between the Cocoa text system
and ATSUI, but I can say that the Cocoa text system is extensive and
flexible, and you can probably get it to do almost anything you want to
do.
The Cocoa text system is made up of a number of pieces, of which
NSTextView is only the visible tip--the view in the
model-view-controller paradigm. The central class, the controller, is
NSLayoutManager, which coordinates all of the others--NSTextContainer,
NSTextStorage, NSTypesetter, and so on. By going directly to
NSLayoutManager it is possible to display a glyph, or a sequence of
glyphs, in a custom view, at any location you choose, if you need that
level of control.
On the other hand, if all you need is control over kerning and
baselines, you can easily get that in a standard NSTextView
configuration. Take a look at TextEdit, and try the various submenus in
the Font menu.
If your needs are somewhere in between, you can take a standard
NSTextView and manipulate its underlying NSLayoutManager. You also have
the option of supplying an entire custom NSTypesetter subclass to do all
your own layout.
There are some examples of text system usage in
/Developer/Examples/AppKit, and I believe we will be coming out with at
least one new one in the next release. If you have more specific
questions, you can probably find answers on this list.
Douglas Davidson