diff --git a/AppKit/CPTextView/CPFontPanel.j b/AppKit/CPTextView/CPFontPanel.j index 2143a95ab..8c36dd73c 100644 --- a/AppKit/CPTextView/CPFontPanel.j +++ b/AppKit/CPTextView/CPFontPanel.j @@ -248,7 +248,7 @@ var _availableTraits= [@"Normal", @"Italic", @"Bold", @"Bold Italic"], if (![self isVisible]) return; - var attribs = [textView typingAttributes], + var attribs = [textView _attributesForFontPanel], font = [attribs objectForKey:CPFontAttributeName] || [[textView textStorage] font] || [CPFont systemFontOfSize:12.0], color = [attribs objectForKey:CPForegroundColorAttributeName]; diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index b5cbb94c8..e38212981 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1341,6 +1341,16 @@ var kDelegateRespondsTo_textShouldBeginEditing [_delegate textViewDidChangeTypingAttributes:[[CPNotification alloc] initWithName:CPTextViewDidChangeTypingAttributesNotification object:self userInfo:nil]]; } +- (CPDictionary)_attributesForFontPanel +{ + var attributes = [[_textStorage attributesAtIndex:CPMaxRange(_selectionRange) effectiveRange:nil] copy]; + + if (![attributes containsKey:CPForegroundColorAttributeName]) + [attributes setObject:[self textColor] forKey:CPForegroundColorAttributeName]; + + return attributes; +} + - (void)delete:(id)sender { [self deleteBackward:sender];