Re: Printing a range of text in a particular container --
Re: Printing a range of text in a particular container --
- Subject: Re: Printing a range of text in a particular container --
- From: Martin Wierschin <email@hidden>
- Date: Sun, 28 Dec 2008 23:23:32 -0800
Hi John,
If I have a particular range of glyphs that I want to put in,
say,textContainer1, and a different (as it happens, contiguous)
range I
want to put in textContainer2, is there a way to do it?
I've tried
[layoutManager drawGlyphsForGlyphRange: glyphRangeStringOne
atPoint:startPoint];
In general you don't really tell the text layout system what glyphs
you want in which container. You'll note the documentation for the
drawing method states:
"Draws the glyphs in the given glyph range, which must lie
completely within a single text container."
Under normal operation you simply give NSLayoutManager the full text
and a series of connected containers/views and it figure the rest out
for you. If you really must have one chunk of text displayed in one
area and a second chunk in another you have these options:
1. Use a separate NSTextStorage and NSLayoutManager pair for each
text chunk.
2. Separate the chunks of text in your NSTextStorage by a break
character (NSFormFeedCharacter).
There's also an unsavory third option where you size your
NSTextContainers so the text happens to break into the second
container at exactly the right point. I really wouldn't recommend
this approach.
One other thought: if you're really not using NSTextView and are
doing all the drawing manually via NSLayoutManager, you might also be
able to use a single infinitely tall NSTextContainer. That way
NSLayoutManager will always be able to draw the glyph range you
request. Just make sure your chunks of text are separated by a
newline character so the second block's horizontal offset is flush
with the rest of the text.
~Martin
_______________________________________________
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