Drawing text with NSLayoutManager
Drawing text with NSLayoutManager
- Subject: Drawing text with NSLayoutManager
- From: Eric Wang <email@hidden>
- Date: Fri, 27 Jun 2003 01:32:08 -0400
I'm currently using NSLayoutManager's -drawGlyphsForGlyphRange:atPoint:
method to draw text in a custom view. I want to draw the text in a column
like the following:
a
b
c
However, when I call -drawGlyphs... to draw each line, NSLayoutManager seems
to advance the horizontal drawing position so that I end up with something
like this:
a
b
c
Adding hard line breaks to the NSLayoutManager's text storage causes the
text to line up vertically, but I don't want to do this for a couple of
reasons:
One, I don't wish to the change underlying model of my application for the
purposes of presenting a view on the data.
Two, the vertical space between each line varies. I'm calculating the
position at which to draw the line each time I call -drawGlyphs... and
passing it as part of the ...atPoint: parameter. Adding hard line breaks
messes up this calculation by causing the lines to be spaced further apart
than they should be.
I also attempted to subclass NSTypeSetter, but the documentation is scarce
on that and I wasn't able to get it working. It seems like a bit of a kludge
for something that should be relatively simple.
I'm thinking that perhaps I should be working at a lower level with the
Quartz (CGContextShowGlyphsAtPoint() looks promising) and/or ATSUI text
drawing APIs.
Any thoughts on this are appreciated.
Eric Wang
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.