diff --git a/ChangeLog b/ChangeLog index ad37b4850..86bacedb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-07-05 17:20 Alexander Malmberg + + * Source/NSAttributedString.m (-fixParagraphStyleAttributeInRange:): + Handle paragraphs with a paragraph style set for a part of it but + not the first character correctly. + + * Source/NSFont.m (getNSFont): Retain/autorelease when returning a + cached instance to make the retain status of the instance correct. + 2003-07-05 16:07 Alexander Malmberg * Source/NSFont.m (-initWithCoder:): Make sure that the returned diff --git a/Source/NSAttributedString.m b/Source/NSAttributedString.m index e3c67c90f..4efeb26e7 100644 --- a/Source/NSAttributedString.m +++ b/Source/NSAttributedString.m @@ -883,6 +883,11 @@ documentAttributes: (NSDictionary **)dict } // FIXME: Should check for each character if it is supported by the // assigned font + /* + Note that this needs to be done on a script basis. Per-character checks + are difficult to do at all, don't give reasonable results, and would have + really poor performance. + */ } - (void) fixParagraphStyleAttributeInRange: (NSRange)range @@ -918,10 +923,18 @@ documentAttributes: (NSDictionary **)dict the range without the style set. */ if ((NSMaxRange (found) + 1) < end) { - /* This skips the range with style not set, and attempts - again to set the style for the whole paragraph taking - the style at the first location with a style set. */ - loc = NSMaxRange (found) + 1; + /* There is a paragraph style for part of the paragraph. Set + this style for the entire paragraph. + + Since NSMaxRange(found) + 1 is outside the longest effective + range for the nil style, it must be non-nil. + */ + style = [self attribute: NSParagraphStyleAttributeName + atIndex: NSMaxRange(found) + 1 + effectiveRange: NULL]; + [self addAttribute: NSParagraphStyleAttributeName + value: style + range: r]; } else { @@ -930,9 +943,6 @@ documentAttributes: (NSDictionary **)dict [self addAttribute: NSParagraphStyleAttributeName value: [NSParagraphStyle defaultParagraphStyle] range: r]; - - /* Move on to the next paragraph. */ - loc = end; } } else @@ -948,11 +958,10 @@ documentAttributes: (NSDictionary **)dict value: style range: found]; } - - /* Move on to the next paragraph. */ - loc = end; } + /* Move on to the next paragraph. */ + loc = end; } }