From 763f4c8cd5a722da36fa1b9e5adae714c8642b49 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 21 Feb 2022 16:51:46 -0800 Subject: [PATCH] Shrink the time field on macOS 10.13 and older Since 10.13 doesn't want to observe the auto sizing attribute of the field properly, gotta use the tiny font size that the field is already configured to use. Should fix #243 Signed-off-by: Christopher Snowhill --- Window/TimeField.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Window/TimeField.m b/Window/TimeField.m index d04d89220..9b6cfc4d1 100644 --- a/Window/TimeField.m +++ b/Window/TimeField.m @@ -22,9 +22,14 @@ NSString *formatTimer(long minutes, long seconds, unichar prefix, int padding) { } - (void)awakeFromNib { + CGFloat fontSize = 11.0; + if(@available(macOS 10.14, *)) { + fontSize = 13.0; + } + showTimeRemaining = [[NSUserDefaults standardUserDefaults] boolForKey:kTimerModeKey]; - NSFontDescriptor *fontDesc = [[NSFont systemFontOfSize:13] fontDescriptor]; + NSFontDescriptor *fontDesc = [[NSFont systemFontOfSize:fontSize] fontDescriptor]; NSDictionary *fontFeatureSettings = @{ NSFontFeatureTypeIdentifierKey: @(kNumberSpacingType), NSFontFeatureSelectorIdentifierKey: @(kMonospacedNumbersSelector) }; @@ -33,10 +38,11 @@ NSString *formatTimer(long minutes, long seconds, unichar prefix, int padding) { fontDesc = [fontDesc fontDescriptorByAddingAttributes:fontFeatureAttributes]; - NSFont *font = [NSFont fontWithDescriptor:fontDesc size:13]; + NSFont *font = [NSFont fontWithDescriptor:fontDesc size:fontSize]; - fontAttributes = - @{ NSFontAttributeName: font }; + fontAttributes = @{ NSFontAttributeName: font }; + + [self update]; } static int _log10(long minutes) {