Re: NSATSTypesetter garbled text when switching to next container
Re: NSATSTypesetter garbled text when switching to next container
- Subject: Re: NSATSTypesetter garbled text when switching to next container
- From: Aki Inoue <email@hidden>
- Date: Tue, 29 Aug 2006 15:30:15 -0700
Ross,
Aki, I hope you're reading this! At WWDC you said that I should talk
to you if I run into a bug using this approach. Is this the bug?
No, it's not 8-). You need to update the origin for all 3 rects, not
just lineFragmentRect.
Aki
To implement a custom text attribute specifying that a paragraph
should start on a new page, I implemented this override in
NSATSTypesetter:
- (void)getLineFragmentRect:(NSRectPointer)lineFragmentRect
usedRect:(NSRectPointer)lineFragmentUsedRect
remainingRect:(NSRectPointer)remainingRect
forStartingGlyphAtIndex:(unsigned)startingGlyphIndex
proposedRect:(NSRect)proposedRect
lineSpacing:(float)lineSpacing
paragraphSpacingBefore:(float)paragraphSpacingBefore
paragraphSpacingAfter:(float)paragraphSpacingAfter {
// Call super first:
[super getLineFragmentRect:(NSRectPointer)lineFragmentRect
usedRect:(NSRectPointer)lineFragmentUsedRect
remainingRect:(NSRectPointer)remainingRect
forStartingGlyphAtIndex:(unsigned)startingGlyphIndex
proposedRect:(NSRect)proposedRect
lineSpacing:(float)lineSpacing
paragraphSpacingBefore:(float)paragraphSpacingBefore
paragraphSpacingAfter:(float)paragraphSpacingAfter];
// the ivar startOnNewPage was set in beginParagraph:
if (startParaOnNewPage && [self paragraphGlyphRange].location ==
startingGlyphIndex) {
// It might already be on a new page:
if (lineFragmentRect->origin.y > 0.001) {
// Reset origin so text will draw at top of page:
lineFragmentRect->origin.y = 0.0;
if (currentTextContainer == [[self textContainers] lastObject]) {
currentTextContainerIndex = NSNotFound;
currentTextContainer = nil;
currentTextContainerSize = NSZeroSize;
} else {
currentTextContainerIndex++;
unsigned indexOfOldTC = [[self textContainers]
indexOfObjectIdenticalTo:currentTextContainer];
currentTextContainer = [[self textContainers]
objectAtIndex:indexOfOldTC + 1];
currentTextContainerSize = [currentTextContainer containerSize];
}
}
}
}
This works fine for the paragraph that starts on the new page, but
the text of page preceding the jump becomes garbled if I scroll
quickly. Some glyphs don't appear, and others appear but are
overwritten by the glyphs that are drawn on the subsequent page.
Moving the insertion point on that preceding page will fix about two
lines of text at a time.
Aki, I hope you're reading this! At WWDC you said that I should talk
to you if I run into a bug using this approach. Is this the bug?
Any suggestions appreciated.
Ross
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden