From 226fd82f45c4a4137a5ea301657f8ce0a42351b4 Mon Sep 17 00:00:00 2001 From: Thomas Bachem Date: Fri, 8 Jan 2016 16:44:00 +0100 Subject: [PATCH] Use monospacedDigitSystemFontOfSize on OS X 10.11+ Fixes #123 --- App/BitBar/Plugin.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/App/BitBar/Plugin.m b/App/BitBar/Plugin.m index 19bc1619c..57c717e0c 100644 --- a/App/BitBar/Plugin.m +++ b/App/BitBar/Plugin.m @@ -75,9 +75,16 @@ - (NSAttributedString*) attributedTitleWithParams:(NSDictionary *)params { NSString * title = truncLength < titleLength ? [[fullTitle substringToIndex:truncLength] stringByAppendingString:@"…"] : fullTitle; CGFloat size = params[@"size"] ? [params[@"size"] floatValue] : 14; - NSFont * font = [self isFontValid:params[@"font"]] ? [NSFont fontWithName:params[@"font"] size:size] - : [NSFont menuFontOfSize:size] - ?: [NSFont menuFontOfSize:size]; + NSFont * font; + if ([NSFont respondsToSelector:@selector(monospacedDigitSystemFontOfSize:weight:)]) { + font = [self isFontValid:params[@"font"]] ? [NSFont fontWithName:params[@"font"] size:size] + : [NSFont monospacedDigitSystemFontOfSize:size weight:NSFontWeightRegular] + ?: [NSFont monospacedDigitSystemFontOfSize:size weight:NSFontWeightRegular]; + } else { + font = [self isFontValid:params[@"font"]] ? [NSFont fontWithName:params[@"font"] size:size] + : [NSFont menuFontOfSize:size] + ?: [NSFont menuFontOfSize:size]; + } NSColor * fgColor; NSMutableAttributedString * attributedTitle = [NSMutableAttributedString.alloc initWithString:title attributes:@{NSFontAttributeName: font}]; if (!params[@"color"]) return attributedTitle;