Re: NSAttributedString advice
Re: NSAttributedString advice
- Subject: Re: NSAttributedString advice
- From: Douglas Davidson <email@hidden>
- Date: Sun, 12 Dec 2004 12:26:58 -0800
On Dec 11, 2004, at 10:34 PM, Jonathan Jackel wrote:
On Dec 10, 2004, at 5:10 PM, Moray Taylor wrote:
Hi,
In my program I require an NSAttributedString that can not only
contain styles such as bold, italic etc.. , but contain 'named
styles' much like Quark Xpress or MS Word would have.
I assume I can use the addAttribute:withRange to set where my 'named
styles' are,
Absolutely -- except you probably want to use an NSTextStorage, which
is a subclass of NSMutableAttributedString.
but how would I make the NSAttributedString lookup what these styles
meant, and render itself accordingly? Is this possible, or do I need
to make my own attributedstring class?
Hopefully John Randolph will chime in on this one, but I suspect you
would need to subclass NSLayoutManager. I don't even want to guess
how.
Actually, for this an NSTextStorage subclass ought to work. The
primary thing that an NSTextStorage subclass has to do is to be able to
return the character and attributes at a given index. If you have an
alternate model for your attributes--for example, as a hierarchy of
named styles--then you could simply resolve those, when asked, into a
dictionary of computed attributes of the sort that the text system
expects--font, color, etc.--and return that as the attribute
dictionary. Editing could be a bit trickier, but there should be
sufficient hooks for you to handle that.
Douglas Davidson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden