Re: Laying out superscripted text
Re: Laying out superscripted text
- Subject: Re: Laying out superscripted text
- From: Graham Cox <email@hidden>
- Date: Thu, 28 May 2009 22:35:38 +1000
On 28/05/2009, at 5:19 PM, Graham Cox wrote:
I have code that lays out text on a path. It essentially boils down
to the technique given in the Text Layout Programming Guide example
code (Circle text) of setting up a transform before letting the
layout manager get on with its normal work, done by calling -
[NSLayoutManager drawGlyphsForGlyphRange:atPoint:]; where the point
is calculated from the -locationOfGlyphAtIndex: method (each glyph
has to be drawn individually for obvious reasons, so the glyph range
is always length 1)
[snip]
So that would be good to know if anyone can help. That still leaves
me mystified as to why the layout manager doesn't "just work" though.
OK, I made some progress on this. Turns out it does "just work", but
in my calculations I was inadvertently cancelling out the baseline
offset for each glyph. However, I'm not quite out of the woods yet, as
there is one final remaining problem I can't seem to find a simple
solution to.
I want to lay out my text so that its baseline lies on the path (I can
also offset it either side, but an offset of 0 means sitting on the
path). NSLayoutManager positions glyphs based on the origin of the
line fragment rectangle, which, because the context is flipped, is its
top left corner. Finding the baseline of any single glyph is trivial (-
locationOfGlyphAtIndex:) but I can't seem to find an easy way to
obtain the overall baseline of the entire line of text within the line
fragment rectangle. How do I do this?
I tried just using the glyph location of the first glyph on the line,
but it's not right if the first glyph is itself superscripted.
(Note: It sounds easy but doesn't seem to be - a line of text with a
variety of mixed attributes can have a whole variety of baselines, but
the layout manager seems to know how to work out where a single
consistent baseline should be - but it doesn't seem to be telling).
--Graham
_______________________________________________
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