NSLayoutManager/NSTypesetter ignoring paragraphSpacingBefore
NSLayoutManager/NSTypesetter ignoring paragraphSpacingBefore
- Subject: NSLayoutManager/NSTypesetter ignoring paragraphSpacingBefore
- From: Steve Shepard <email@hidden>
- Date: Thu, 25 Aug 2005 17:58:03 -0700
I'm trying to work around the fact that NSLayoutManager ignores the
NSParagraphStyle paragraphSpacingBefore property for the first
paragraph in a container.
My approach is to subclass NSATSTypesetter and override as follows:
- (float)paragraphSpacingBeforeGlyphAtIndex:(unsigned)glyphIndex
withProposedLineFragmentRect:(NSRect)rect
{
float spacing;
if (glyphIndex == 0) {
unsigned charIndex = [layoutManager
characterIndexForGlyphAtIndex:glyphIndex];
if (charIndex < [[self attributedString] length]) {
NSParagraphStyle *style = [[self attributedString]
attribute:NSParagraphStyleAttributeName atIndex:charIndex
effectiveRange:nil];
spacing = [style paragraphSpacingBefore];
} else {
spacing = [super
paragraphSpacingBeforeGlyphAtIndex:glyphIndex
withProposedLineFragmentRect:rect];
}
} else {
spacing = [super paragraphSpacingBeforeGlyphAtIndex:glyphIndex
withProposedLineFragmentRect:rect];
}
return spacing;
}
This works for most cases. However, there seems to be another path
through the layout code that doesn't call this method, e.g. when text
is pasted at the top of a container or in live resize when the text
contains NSTextBlocks.
What am I missing?
-Steve
_______________________________________________
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