File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change 41
41
- (BOOL ) refresh ;
42
42
- (void ) cycleLines ;
43
43
- (void ) contentHasChanged ;
44
- - (BOOL ) isFontValid : (NSString *)fontName ;
45
44
46
45
// actions
47
46
- (void )changePluginsDirectorySelected : (id )sender ;
Original file line number Diff line number Diff line change @@ -161,8 +161,7 @@ - (NSAttributedString*) attributedTitleWithParams:(NSDictionary *)params {
161
161
NSString * title = truncLength < titleLength ? [[fullTitle substringToIndex: truncLength] stringByAppendingString: @" …" ] : fullTitle;
162
162
163
163
CGFloat size = params[@" size" ] ? [params[@" size" ] floatValue ] : 14 ;
164
- NSFont * font = ([self isFontValid: params[@" font" ]] ? [NSFont fontWithName: params[@" font" ] size: size]
165
- : nil )
164
+ NSFont * font = [self validFont: params[@" font" ] size: size]
166
165
?: [NSFont respondsToSelector: @selector (monospacedDigitSystemFontOfSize:weight: )]
167
166
? [NSFont monospacedDigitSystemFontOfSize: size weight: NSFontWeightRegular ]
168
167
: [NSFont menuFontOfSize: size];
@@ -494,15 +493,13 @@ - (void) contentHasChanged {
494
493
_allContentLines = nil ;
495
494
}
496
495
497
- - (BOOL ) isFontValid : (NSString *)fontName {
498
- if (fontName == nil ) {
499
- return NO ;
500
- }
496
+ - (NSFont *)validFont : (NSString *)fontName size : (CGFloat)size {
497
+ if (!fontName) return nil ;
501
498
502
- NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes: @{NSFontNameAttribute : fontName}];
503
- NSArray *matches = [fontDescriptor matchingFontDescriptorsWithMandatoryKeys: nil ];
499
+ NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes: @{NSFontNameAttribute : fontName}];
500
+ NSFontDescriptor *match = [fontDescriptor matchingFontDescriptorWithMandatoryKeys: nil ];
504
501
505
- return ([matches count ] > 0 ) ;
502
+ return match ? [ NSFont fontWithDescriptor: match size: size] : nil ;
506
503
}
507
504
508
505
- (void ) setContent : (NSString *)content {
You can’t perform that action at this time.
0 commit comments