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 <kode54@gmail.com>
swiftingly
Christopher Snowhill 2022-06-03 16:46:37 -07:00
parent eaa73bc52f
commit 0ba766023e
2 changed files with 2 additions and 22 deletions

View File

@ -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;

View File

@ -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 };