Martin -- still thanks, but, I found a fourth method: NSLayoutManager -setTextContainer:forGlyphRange:
This is embarrassing because I've been pouring over all the text guidelines and class documentation for days now, and didn't see this until after I got your response and tried it. I stumbled on this by accident looking for something else in the NSLayoutManager documentation. So here is a fourth alternative, and seems to work quite well (one test so far). I can imagine circumstances when the \f would be more convenient, and some where the -setTextContainer:forGlyphRange: would be more convenient. Well, thanks again, John Velman On Mon, Dec 29, 2008 at 09:21:50AM -0800, John Velman wrote: > > Thanks, Martin. [snip] > > Thanks again, > > John V. > > > On Sun, Dec 28, 2008 at 11:23:32PM -0800, Martin Wierschin wrote: > > 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 (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/velman%40cox.net > > This email sent to vel...@cox.net _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com