Re: Normalize an NSAttributedString
Re: Normalize an NSAttributedString
- Subject: Re: Normalize an NSAttributedString
- From: Alastair Houghton <email@hidden>
- Date: Tue, 25 Aug 2009 20:46:04 +0100
On 25 Aug 2009, at 18:02, Ross Carter wrote:
I'd love to do this:
Archiving:
1. Normalize the source attributed string.
2. Archive its string content and its attribute information.
Unarchiving:
3. Create a new string from the archived data and normalize it.
4. Created a new attributed string from that string and the archived
attributes.
Hi Ross,
I see the problem :-)
What you *could* do is iterate over the ranges in the attributed
string, retrieve the substring associated with each range, normalise
*that* string, then store the attributes and the length of the
normalised string.
Then to recreate your attributed string, you read (string, attributes)
pairs from your storage, re-normalise your string if you like, and
then append the string to your new attributed string with the
specified attributes.
Note that there is an issue with this approach, which is that
attribute runs that start in the middle of a grapheme cluster might
result in odd behaviour wrt normalisation. However, it generally
doesn't make sense to have such an attribute run (it's the equivalent
of asking for e.g. a bold "o" with an italic umlaut, which makes no
sense), it's just something that you might want to be aware of.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden