FROM : Douglas Davidson
DATE : Mon Feb 18 19:55:46 2008
On Feb 17, 2008, at 5:03 PM, Daniel Jalkut wrote:
> I'm trying to figure out the most appropriate place to impose this
> kind of policy. I'm intrigued by NSTypesetter because it seems to be
> where the action of determining line fragment rectangles happens.
> Should I be subclassing NSTypesetter and somehow causing it to avoid
> seeking to fill a container with line fragments, if it won't succeed
> in filling an entire paragraph?
NSTypesetter would be the appropriate place for this sort of policy,
since it is responsible for actually laying out the lines of text.
Bear in mind, though, that the typesetter won't know that a paragraph
doesn't fit until it has laid out some of the lines and discovered
that it has run out of space before the end of the paragraph.
NSTypesetter gets called to layout a paragraph at once, and then
queries the text container for each individual line; probably what you
would need to do would be to subclass NSTypesetter and at some point
detect that condition, then set some flag indicating that the
paragraph should be moved to the next container, and restart layout
from the beginning of the paragraph. I'm not sure offhand exactly
where the right override points in NSTypesetter would be.
The suggestion of using tables/blocks is also a reasonable one, but
it's not a complete solution to the keep-together issue because the
editing behavior of table cells/blocks is somewhat different from that
of ordinary paragraphs. If you're dealing with non-editable text this
might be a good solution, but for freely editable text I would tend to
look at a typesetter-based solution.
Douglas Davidson
DATE : Mon Feb 18 19:55:46 2008
On Feb 17, 2008, at 5:03 PM, Daniel Jalkut wrote:
> I'm trying to figure out the most appropriate place to impose this
> kind of policy. I'm intrigued by NSTypesetter because it seems to be
> where the action of determining line fragment rectangles happens.
> Should I be subclassing NSTypesetter and somehow causing it to avoid
> seeking to fill a container with line fragments, if it won't succeed
> in filling an entire paragraph?
NSTypesetter would be the appropriate place for this sort of policy,
since it is responsible for actually laying out the lines of text.
Bear in mind, though, that the typesetter won't know that a paragraph
doesn't fit until it has laid out some of the lines and discovered
that it has run out of space before the end of the paragraph.
NSTypesetter gets called to layout a paragraph at once, and then
queries the text container for each individual line; probably what you
would need to do would be to subclass NSTypesetter and at some point
detect that condition, then set some flag indicating that the
paragraph should be moved to the next container, and restart layout
from the beginning of the paragraph. I'm not sure offhand exactly
where the right override points in NSTypesetter would be.
The suggestion of using tables/blocks is also a reasonable one, but
it's not a complete solution to the keep-together issue because the
editing behavior of table cells/blocks is somewhat different from that
of ordinary paragraphs. If you're dealing with non-editable text this
might be a good solution, but for freely editable text I would tend to
look at a typesetter-based solution.
Douglas Davidson
| Related mails | Author | Date |
|---|---|---|
| Daniel Jalkut | Feb 18, 02:03 | |
| Ben Lachman | Feb 18, 04:05 | |
| Daniel Jalkut | Feb 18, 06:08 | |
| Douglas Davidson | Feb 18, 19:55 | |
| Daniel Jalkut | Feb 18, 22:40 |






Cocoa mail archive

