Re: SuperScript to baseline offset
Re: SuperScript to baseline offset
- Subject: Re: SuperScript to baseline offset
- From: "R. Scott Thompson" <email@hidden>
- Date: Fri, 3 Dec 2004 09:53:11 -0600
On Dec 2, 2004, at 7:23 PM, Douglas Davidson wrote:
On Dec 2, 2004, at 2:59 PM, Scott Thompson wrote:
If I bring in RTF text that contains superscript (or subscript)
information, the text attributes in that text range will contain the
NSSuperscriptAttributeName attribute but apparently not the
NSBaselineOffsetAttributeName.
At what point in the text layout process is
NSSuperscriptAttributeName "changed" into a baseline offset? If I
want to change the way that the SuperScript is represented (say by
substituting a smaller point size of the same font, or changing the
magnitude of the baseline shift) where would I insert my code?
The typesetter handles this while it lays out the text. While it is
possible to create a custom typesetter, it would not be
straightforward. I would suggest that you instead simply transform
the attributed string after you read it in from RTF, replacing the
superscript attribute with some combination of other attributes or
attribute changes. If you need to later write the text back out to
RTF, you may wish to perform the inverse transformation before doing
so; you could if you like place a custom attribute on the transformed
ranges to assist in this process.
I don't know if I want to undo the transformation when I go back to
RTF. The thing that's really annoying about the superscript attribute
is that it's kinda a "markup" attribute where I really want a
"presentation" attribute (I've been reading a lot about XML and CSS
lately). I'll experiment with NOT undoing the transformation so that
all that's left is the presentation attributes and see if that gives me
better fidelity moving text back and forth.
What you suggest sounds like the best approach for the moment. Since
it appears that the Typesetter is becoming increasingly more "open"
(particularly with NSATSTypesetter in 10.3) I'll add an enhancement
request to see if there's some way in the future for an application to
become more proactive in the process.
I know in the WWDC presentation this past year you mentioned that Tiger
will include drawing routines that allow you to position the text using
the baseline rather than the upper left corner of the text box. Is
there a way in 10.2/10.3, when I'm working with a text layout, to
determine what offset in the layout is the "baseline" for a given line
fragment (i.e. the line from which baseline offsets are calcuated)?
Scott
_______________________________________________
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