diff --git a/ChangeLog b/ChangeLog index bab78e997..837f9c29f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,7 +4,7 @@ Fix handling of the case where the exact glyph is found during the binary search. - * Source/NSLayoutManager.m (-drawGlyphsForGlyphRange:atPoint:): + * Source/NSLayoutManager.m (-drawBackgroundForGlyphRange:atPoint:): Check that a range has a background color before checking that there are rectangles for it (since ranges practically always have rectangles, and very rarely a background color). diff --git a/Source/NSLayoutManager.m b/Source/NSLayoutManager.m index 1fdb990de..e819eeece 100644 --- a/Source/NSLayoutManager.m +++ b/Source/NSLayoutManager.m @@ -1188,17 +1188,17 @@ container if (NSMaxRange(r) > NSMaxRange(range)) r.length = NSMaxRange(range) - r.location; - rects = [self rectArrayForGlyphRange: r - withinSelectedGlyphRange: NSMakeRange(NSNotFound, 0) - inTextContainer: textContainer - rectCount: &count]; - - if (count) + color = [_textStorage attribute: NSBackgroundColorAttributeName + atIndex: char_pos + effectiveRange: NULL]; + if (color) { - color = [_textStorage attribute: NSBackgroundColorAttributeName - atIndex: char_pos - effectiveRange: NULL]; - if (color) + rects = [self rectArrayForGlyphRange: r + withinSelectedGlyphRange: NSMakeRange(NSNotFound, 0) + inTextContainer: textContainer + rectCount: &count]; + + if (count) { if (last_color != color) {