Re: is this string styled?
Re: is this string styled?
- Subject: Re: is this string styled?
- From: Douglas Davidson <email@hidden>
- Date: Mon, 9 Jan 2006 11:01:35 -0800
On Jan 9, 2006, at 10:31 AM, Matt Neuburg wrote:
Either I can or I
can't learn whether an attributed string has the "default
attributes", so
that I can substitute a pure NSString for it.
The question as posed is perhaps not so clear-cut; it depends
somewhat on your purposes. For example, NSTextView has a mechanism
for supplying a default paragraph style on a per-textview basis, that
may be different from the global default paragraph style; TextEdit,
for example, uses this when supplying styling (e.g. tab stops) for
plain text. For another example, the text system will substitute
fonts as necessary (during the font fixing step) to replace fonts
that cannot render a given text with those that can. One might well
consider that text with the text view's default paragraph style and
with substituted fonts is still unstyled, even if it is not Helvetica
12 with [NSParagraphStyle defaultParagraphStyle].
Another issue is that styled text is often stored in a persistent
format such as RTF, which is largely but not entirely faithful to the
attributed string from which it comes. For example, RTF has a
limited granularity for color values and font sizes, and any finer
variation is lost. For some purposes, one might consider text as
effectively unstyled if it would produce the same RTF as unstyled text.
One possibility would be to extract the plain text from a given
attributed string, do whatever is necessary to get it into the same
form it would take if you were actually to place it in your
application as unstyled text, and see whether the resulting
attributed string matches the original one. Whether that is actually
feasible may be a performance issue; there is something of a space-
time tradeoff here.
There are other options for saving space, such as altering the format
used to store the text. Natural-language text can often benefit from
compression, and so can plain-text formats such as RTF, HTML, XML,
and so forth.
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