From 0ba766023ea06eb33471586d6be724476623493a Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Fri, 3 Jun 2022 16:46:37 -0700 Subject: [PATCH] Playlist/Time: Simplify font initialization Apparently this simpler API already existed on a minimum of 10.11 for creating a system font with monospaced digits. Signed-off-by: Christopher Snowhill --- Playlist/PlaylistController.m | 13 +------------ Window/TimeField.m | 11 +---------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 37d15d86e..db743e7f7 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -318,18 +318,7 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc if(cellView.textField) { cellView.textField.allowsDefaultTighteningForTruncation = YES; - NSFont *sysFont = [NSFont systemFontOfSize:fontSize]; - - NSFontDescriptor *fontDesc = [sysFont fontDescriptor]; - - NSDictionary *fontFeatureSettings = @{ NSFontFeatureTypeIdentifierKey: @(kNumberSpacingType), - NSFontFeatureSelectorIdentifierKey: @(kMonospacedNumbersSelector) }; - - NSDictionary *fontFeatureAttributes = @{ NSFontFeatureSettingsAttribute: @[fontFeatureSettings] }; - - fontDesc = [fontDesc fontDescriptorByAddingAttributes:fontFeatureAttributes]; - - NSFont *font = [NSFont fontWithDescriptor:fontDesc size:fontSize]; + NSFont *font = [NSFont monospacedDigitSystemFontOfSize:fontSize weight:NSFontWeightRegular]; cellView.textField.font = font; cellView.textField.stringValue = cellText; diff --git a/Window/TimeField.m b/Window/TimeField.m index 9b6cfc4d1..e808d844c 100644 --- a/Window/TimeField.m +++ b/Window/TimeField.m @@ -29,16 +29,7 @@ NSString *formatTimer(long minutes, long seconds, unichar prefix, int padding) { showTimeRemaining = [[NSUserDefaults standardUserDefaults] boolForKey:kTimerModeKey]; - NSFontDescriptor *fontDesc = [[NSFont systemFontOfSize:fontSize] fontDescriptor]; - - NSDictionary *fontFeatureSettings = @{ NSFontFeatureTypeIdentifierKey: @(kNumberSpacingType), - NSFontFeatureSelectorIdentifierKey: @(kMonospacedNumbersSelector) }; - - NSDictionary *fontFeatureAttributes = @{ NSFontFeatureSettingsAttribute: @[fontFeatureSettings] }; - - fontDesc = [fontDesc fontDescriptorByAddingAttributes:fontFeatureAttributes]; - - NSFont *font = [NSFont fontWithDescriptor:fontDesc size:fontSize]; + NSFont *font = [NSFont monospacedDigitSystemFontOfSize:fontSize weight:NSFontWeightRegular]; fontAttributes = @{ NSFontAttributeName: font };