Skip navigation.
 
mlRe: Where to enforce paragraph-cohesion policy in text system?
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

Related mailsAuthorDate
mlWhere to enforce paragraph-cohesion policy in text system? Daniel Jalkut Feb 18, 02:03
mlRe: Where to enforce paragraph-cohesion policy in text system? Ben Lachman Feb 18, 04:05
mlRe: Where to enforce paragraph-cohesion policy in text system? Daniel Jalkut Feb 18, 06:08
mlRe: Where to enforce paragraph-cohesion policy in text system? Douglas Davidson Feb 18, 19:55
mlRe: Where to enforce paragraph-cohesion policy in text system? Daniel Jalkut Feb 18, 22:40