Skip to content

Commit 124be7f

Browse files
committed
fixed font crash. closes #360
1 parent 8857779 commit 124be7f

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

App/BitBar/Plugin.m

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,11 @@ - (NSAttributedString*) attributedTitleWithParams:(NSDictionary *)params {
161161
NSString * title = truncLength < titleLength ? [[fullTitle substringToIndex:truncLength] stringByAppendingString:@""] : fullTitle;
162162

163163
CGFloat size = params[@"size"] ? [params[@"size"] floatValue] : 14;
164-
NSFont * font;
165-
if ([NSFont respondsToSelector:@selector(monospacedDigitSystemFontOfSize:weight:)]) {
166-
font = [self isFontValid:params[@"font"]] ? [NSFont fontWithName:params[@"font"] size:size]
167-
: [NSFont monospacedDigitSystemFontOfSize:size weight:NSFontWeightRegular]
168-
?: [NSFont monospacedDigitSystemFontOfSize:size weight:NSFontWeightRegular];
169-
} else {
170-
font = [self isFontValid:params[@"font"]] ? [NSFont fontWithName:params[@"font"] size:size]
171-
: [NSFont menuFontOfSize:size]
172-
?: [NSFont menuFontOfSize:size];
173-
}
164+
NSFont * font = ([self isFontValid:params[@"font"]] ? [NSFont fontWithName:params[@"font"] size:size]
165+
: nil)
166+
?: [NSFont respondsToSelector:@selector(monospacedDigitSystemFontOfSize:weight:)]
167+
? [NSFont monospacedDigitSystemFontOfSize:size weight:NSFontWeightRegular]
168+
: [NSFont menuFontOfSize:size];
174169

175170
NSDictionary* attributes = @{NSFontAttributeName: font, NSBaselineOffsetAttributeName : @1};
176171
BOOL parseANSI = [fullTitle containsANSICodes] && ![[params[@"ansi"] lowercaseString] isEqualToString:@"false"];

0 commit comments

Comments
 (0)