Subclassing NSTypesetter: NSRunStorage exception
Subclassing NSTypesetter: NSRunStorage exception
- Subject: Subclassing NSTypesetter: NSRunStorage exception
- From: Jérôme Laurens <email@hidden>
- Date: Tue, 1 Oct 2002 12:45:48 +0200
Thanks for the helpful answer to the rect question...
It turns out that I have a bigger problem i did not suspect at once.
my typesetter only implements the
- (void)layoutGlyphsInLayoutManager:(NSLayoutManager *)layoutManager
startingAtGlyphIndex:(unsigned)startGlyphIndex
maxNumberOfLineFragments:(unsigned)maxNumLines nextGlyphIndex:(unsigned
*)nextGlyph;
method
when the startGlyphIndex is 0, I just typeset the first line in a whole
NSRect fragmentRect = NSMakeRect(0, 0, lineWidth, lineHeight);
NSRect usedRect = fragmentRect;
...
[[textStorage string] getLineStart: nil end: &end contentsEnd:
&contentsEnd forRange: NSMakeRange(0, 1)];
glyphRange = NSMakeRange(0, end);
NS_DURING
[layoutManager setTextContainer: textContainer forGlyphRange:
glyphRange];
NS_HANDLER
// what to do then
NS_ENDHANDLER
{
NSAttributedString * AS = [textStorage
attributedSubstringFromRange: NSMakeRange(0, contentsEnd)];
//NSLog(@"AS: %@", AS);
usedRect.size.width = [AS size].width + 2 * padding;
}
[layoutManager setLineFragmentRect: fragmentRect forGlyphRange:
glyphRange usedRect: usedRect];
[layoutManager setLocation: NSMakePoint(padding, lineAscent)
forStartOfGlyphRange: glyphRange];
when I paste a 1000 chars line (with no eol markers) in a void
document, and I try to insert a char at the beginning, I get the
exception raised inside the setTextContainer:forGlyphRange: method:
Exception raised during background layout: *** NSRunStorage (20b8c40),
_replaceElements(): replaced range {0, 1001} extends beyond current run
storage size 1000.
There is no exception if I append any text to the first line, whatever
length
Does it mean that line ranges MUST be less than 1000 chars long?
If not, how should i typeset a >1000 chars long line...
Finally, I can figure out how should I use maxNumLines, I jut typeset
one line at a time and it seems to work, except the above problem...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.