Skip to content

Commit 2a48750

Browse files
authored
Use a fixed-width font for less jank (#86)
- Change to monospacedDigitSystemFont - Remove old version checks - Update build target to 10.11, as set by the project - Bump version to 1.5.4 Fixes #85
1 parent 9860b81 commit 2a48750

File tree

2 files changed

+8
-25
lines changed

2 files changed

+8
-25
lines changed

Timer.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@
300300
COMBINE_HIDPI_IMAGES = YES;
301301
INFOPLIST_FILE = Timer/Info.plist;
302302
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
303-
MACOSX_DEPLOYMENT_TARGET = 10.10;
304-
MARKETING_VERSION = 1.5.3;
303+
MACOSX_DEPLOYMENT_TARGET = 10.11;
304+
MARKETING_VERSION = 1.5.4;
305305
PRODUCT_BUNDLE_IDENTIFIER = com.michaelvillar.Timer;
306306
PRODUCT_NAME = "$(TARGET_NAME)";
307307
PROVISIONING_PROFILE = "";
@@ -318,8 +318,8 @@
318318
COMBINE_HIDPI_IMAGES = YES;
319319
INFOPLIST_FILE = Timer/Info.plist;
320320
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
321-
MACOSX_DEPLOYMENT_TARGET = 10.10;
322-
MARKETING_VERSION = 1.5.3;
321+
MACOSX_DEPLOYMENT_TARGET = 10.11;
322+
MARKETING_VERSION = 1.5.4;
323323
PRODUCT_BUNDLE_IDENTIFIER = com.michaelvillar.Timer;
324324
PRODUCT_NAME = "$(TARGET_NAME)";
325325
PROVISIONING_PROFILE = "";

Timer/MVClockView.swift

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,14 @@ class MVClockView: NSControl {
9797
self.addSubview(pauseIconImageView)
9898

9999
timerTimeLabel = MVLabel(frame: NSMakeRect(0, 94, 150, 20))
100-
timerTimeLabel.font = timeLabelFont(ofSize: timerTimeLabelFontSize)
100+
timerTimeLabel.font = NSFont.systemFont(ofSize: timerTimeLabelFontSize, weight: .medium)
101101
timerTimeLabel.alignment = NSTextAlignment.center
102102
timerTimeLabel.textColor = NSColor(srgbRed: 0.749, green: 0.1412, blue: 0.0118, alpha: 1.0)
103103
self.addSubview(timerTimeLabel)
104104

105105
minutesLabel = MVLabel(frame: NSMakeRect(0, 57, 150, 30))
106106
minutesLabel.string = ""
107-
if #available(OSX 10.11, *) {
108-
minutesLabel.font = NSFont.systemFont(ofSize: 35, weight: .medium)
109-
} else {
110-
minutesLabel.font = NSFont(name: "HelveticaNeue-Medium", size: 35)
111-
}
107+
minutesLabel.font = NSFont.monospacedDigitSystemFont(ofSize: 35, weight: .medium)
112108
minutesLabel.alignment = NSTextAlignment.center
113109
minutesLabel.textColor = NSColor(srgbRed: 0.2353, green: 0.2549, blue: 0.2706, alpha: 1.0)
114110
self.addSubview(minutesLabel)
@@ -126,11 +122,7 @@ class MVClockView: NSControl {
126122
minutesLabelSecondsSuffixWidth = minutesLabelSecondsSize.width
127123

128124
secondsLabel = MVLabel(frame: NSMakeRect(0, 38, 150, 20))
129-
if #available(OSX 10.11, *) {
130-
secondsLabel.font = NSFont.systemFont(ofSize: 15, weight: .medium)
131-
} else {
132-
secondsLabel.font = NSFont(name: "HelveticaNeue-Medium", size: 15)
133-
}
125+
secondsLabel.font = NSFont.monospacedDigitSystemFont(ofSize: 15, weight: .regular)
134126
secondsLabel.alignment = NSTextAlignment.center
135127
secondsLabel.textColor = NSColor(srgbRed: 0.6353, green: 0.6667, blue: 0.6863, alpha: 1.0)
136128
self.addSubview(secondsLabel)
@@ -301,7 +293,6 @@ class MVClockView: NSControl {
301293
self.seconds = seconds
302294
self.handleClick()
303295
}
304-
305296
}
306297
}
307298

@@ -369,15 +360,7 @@ class MVClockView: NSControl {
369360

370361
// If the local time format includes an " AM" or " PM" suffix, show the suffix with a smaller font
371362
if let ampmRange = timeString.range(of: " AM", options:[.caseInsensitive]) ?? timeString.range(of: " PM", options:[.caseInsensitive]) {
372-
timerTimeLabel.setFont(timeLabelFont(ofSize: timerTimeLabelFontSize - 3), range: NSRange(ampmRange, in:timeString))
373-
}
374-
}
375-
376-
private func timeLabelFont(ofSize fontSize:CGFloat) -> NSFont {
377-
if #available(OSX 10.11, *) {
378-
return NSFont.systemFont(ofSize: fontSize, weight: .medium)
379-
} else {
380-
return NSFont.labelFont(ofSize: fontSize)
363+
timerTimeLabel.setFont(NSFont.systemFont(ofSize: timerTimeLabelFontSize - 3, weight: .medium),range: NSRange(ampmRange, in:timeString))
381364
}
382365
}
383366

0 commit comments

Comments
 (0)