Re: how to prevent baseline shift when using NSSuperscriptAttributeName on a NSTextView's NSAttributedString ?
Re: how to prevent baseline shift when using NSSuperscriptAttributeName on a NSTextView's NSAttributedString ?
- Subject: Re: how to prevent baseline shift when using NSSuperscriptAttributeName on a NSTextView's NSAttributedString ?
- From: Ross Carter <email@hidden>
- Date: Tue, 22 Jul 2008 12:43:53 -0400
The strange thing is that there only seem to be 3 baseline positions
supported by NSTextField; any positive value, 0, and any negative
value.
I assume you've seen this, from http://developer.apple.com/documentation/Cocoa/Conceptual/AttributedStrings/Articles/standardAttributes.html#/
/apple_ref/doc/uid/TP40004903
"The superscript attribute indicates an abstract level for both super-
and subscripts. The user of the attributed string can interpret this
as desired, adjusting the baseline by the same or a different amount
for each level, changing the font size, or both."
Are you perhaps setting a baseline attribute _and_ a superscript
attribute? It sounds like the Cocoa text system is adjusting the
baseline according to its notion of superscripts and ignoring your
baseline attribute value.
Personally, I don't think NSSuperscriptAttributeName is particularly
useful. I just adjust the baseline and font size: newFontSize =
oldFontSize * 0.75, baseline for superscript += 0.4 * oldFontSize,
baseline for subscript -= 0.3 * oldFontSize.
If the only thing you need to draw is a superscript 2, I like Andrew's
solution.
Ross
_______________________________________________
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