Skip to content

Commit

Permalink
Use a fixed-width font for less jank (#86)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
karbassi committed Jul 9, 2020
1 parent 9860b81 commit 2a48750
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
8 changes: 4 additions & 4 deletions Timer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Timer/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MARKETING_VERSION = 1.5.3;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 1.5.4;
PRODUCT_BUNDLE_IDENTIFIER = com.michaelvillar.Timer;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
Expand All @@ -318,8 +318,8 @@
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Timer/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MARKETING_VERSION = 1.5.3;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 1.5.4;
PRODUCT_BUNDLE_IDENTIFIER = com.michaelvillar.Timer;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
Expand Down
25 changes: 4 additions & 21 deletions Timer/MVClockView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,14 @@ class MVClockView: NSControl {
self.addSubview(pauseIconImageView)

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

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

secondsLabel = MVLabel(frame: NSMakeRect(0, 38, 150, 20))
if #available(OSX 10.11, *) {
secondsLabel.font = NSFont.systemFont(ofSize: 15, weight: .medium)
} else {
secondsLabel.font = NSFont(name: "HelveticaNeue-Medium", size: 15)
}
secondsLabel.font = NSFont.monospacedDigitSystemFont(ofSize: 15, weight: .regular)
secondsLabel.alignment = NSTextAlignment.center
secondsLabel.textColor = NSColor(srgbRed: 0.6353, green: 0.6667, blue: 0.6863, alpha: 1.0)
self.addSubview(secondsLabel)
Expand Down Expand Up @@ -301,7 +293,6 @@ class MVClockView: NSControl {
self.seconds = seconds
self.handleClick()
}

}
}

Expand Down Expand Up @@ -369,15 +360,7 @@ class MVClockView: NSControl {

// If the local time format includes an " AM" or " PM" suffix, show the suffix with a smaller font
if let ampmRange = timeString.range(of: " AM", options:[.caseInsensitive]) ?? timeString.range(of: " PM", options:[.caseInsensitive]) {
timerTimeLabel.setFont(timeLabelFont(ofSize: timerTimeLabelFontSize - 3), range: NSRange(ampmRange, in:timeString))
}
}

private func timeLabelFont(ofSize fontSize:CGFloat) -> NSFont {
if #available(OSX 10.11, *) {
return NSFont.systemFont(ofSize: fontSize, weight: .medium)
} else {
return NSFont.labelFont(ofSize: fontSize)
timerTimeLabel.setFont(NSFont.systemFont(ofSize: timerTimeLabelFontSize - 3, weight: .medium),range: NSRange(ampmRange, in:timeString))
}
}

Expand Down

0 comments on commit 2a48750

Please sign in to comment.