[SOLVED!] Re: Printing a range of text in a particular container --
[SOLVED!] Re: Printing a range of text in a particular container --
- Subject: [SOLVED!] Re: Printing a range of text in a particular container --
- From: John Velman <email@hidden>
- Date: Mon, 29 Dec 2008 09:21:50 -0800
Thanks, Martin. I hadn't found the fact that the form feed character (also
\f, inside q quoted string) would cause the break and move to the new
container. This works for my current testing (I'm just writing a test
program to explore the text system and what tricks I can do with it). If I
need something that isn't easy to handle this way, I'll go on to multiple
text storage (and text layout) instances.
I tried the "sizing the container to fit the text" briefly, and it's
obviously very problematic.
Considering the prevalence of sidebars and insets in printed material, I'm
surprised that there isn't some discussion of this issue somewhere (at
least I haven't found it...) Is the Apple Way to just use RTF or XML with
style sheet for this kind of embellishment?
(I Have been on my iMac for just over a year, previously Linux by
preference, windows by employer. Have been learning Cocoa --as time permits
-- for just over 6 months. ).
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 (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