Hi Gerd,

I have seen something vaguely similar that may or may not be related: I implemented drop caps by having a NSTextContainer subclass counting lines and modifying the lineFragmentRect (see below). After migrating to Leopard that would occasionally fail
...
- (NSRect)lineFragmentRectForProposedRect:(NSRect)proposedRect sweepDirection:(NSLineSweepDirection)sweepDirection movementDirection:(NSLineMovementDirection)movementDirection remainingRect:(NSRect *)remainingRect {
        
        if(proposedRect.origin.y==0)
        {
                // reset at the beginning of the container
                currentLinesToOffset=numOffsetLines;
        }
        
NSRect r=[super lineFragmentRectForProposedRect:proposedRect sweepDirection:sweepDirection movementDirection:movementDirection remainingRect:remainingRect];
        
        if(numOffsetLines)
        {
                numOffsetLines--;
                r.origin.x+=leftOffset;
                r.size.width-=leftOffset;
        }
        
        return r;
}

In your case I would worry about the call sequence when line fragments are calculated. There's no guarantee that each fragment will only be swept out once and in an order sorted by vertical position. Especially if you have noncontiguous layout enabled. I think it would be much safer to have your implementation of lineFragmentRectForProposedRect:etc: do some simple geometric tests, eg:

@implementation RATETextContainer

- (id) initWithContainerSize:(NSSize)size dropCapRect:(NSRect)dropRect
{       
        if(self=[super initWithContainerSize:size]) {
                dropCapRect = dropRect;
        }
        return self;
}

- (NSRect)lineFragmentRectForProposedRect:(NSRect)proposedRect sweepDirection:(NSLineSweepDirection)sweepDirection movementDirection: (NSLineMovementDirection)movementDirection remainingRect:(NSRect *) remainingRect
{
NSRect lineRect = [super lineFragmentRectForProposedRect:proposedRect sweepDirection:sweepDirection movementDirection:movementDirection remainingRect:remainingRect];
        
        if( NSIntersectsRect(lineRect, dropCapRect) ) {
                lineRect.size.width = NSMaxX(lineRect) - NSMaxX(dropCapRect);
                lineRect.origin.x = NSMaxX(dropCapRect);
        }
        
        return lineRect;
}

- (BOOL)isSimpleRectangularTextContainer
{       
     return NO;
}

@end

That would make your code behave consistently, regardless of the way in which the typesetter decides to sweep out line fragments.

Unfortunately I think my problem is different- but perhaps our code too made some bad assumptions that was unexpectedly affected by Leopard typesetter changes.

~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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to