From 3d31ce8269e9c664194c9142e66cb19e91bda7db Mon Sep 17 00:00:00 2001 From: Abhi Date: Sat, 22 Apr 2023 16:50:06 -0400 Subject: [PATCH] Line Height Multiple for Location Text in Status Bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addressing feedback: In the menu bar, whenever I have locations that have letters like “p”, “q”, “y”, and “g” (i.e. they go below the “line”) the portion below the “line” gets truncated. So it ends up that “p”, “q” and “g” look kind of like “o” and “y” looks like “v”. This means I can’t really pick the names I want sometimes (e.g. for Germany I use Frankfurt as a workaround). Please fix! --- Clocker/Preferences/Menu Bar/StatusItemView.swift | 13 ++++++++++++- .../Menu Bar/UpcomingEventStatusItemView.swift | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Clocker/Preferences/Menu Bar/StatusItemView.swift b/Clocker/Preferences/Menu Bar/StatusItemView.swift index ea61d36..c130f53 100644 --- a/Clocker/Preferences/Menu Bar/StatusItemView.swift +++ b/Clocker/Preferences/Menu Bar/StatusItemView.swift @@ -3,10 +3,21 @@ import Cocoa import CoreModelKit +var defaultTimeParagraphStyle: NSMutableParagraphStyle { + let paragraphStyle = NSMutableParagraphStyle() + paragraphStyle.alignment = .center + paragraphStyle.lineBreakMode = .byTruncatingTail + return paragraphStyle +} + var defaultParagraphStyle: NSMutableParagraphStyle { let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = .center paragraphStyle.lineBreakMode = .byTruncatingTail + // Better readability for p,q,y,g in the status bar. + let userPreferredLanguage = Locale.preferredLanguages.first ?? "en-US" + let lineHeight = userPreferredLanguage.contains("en") ? 0.92 : 1 + paragraphStyle.lineHeightMultiple = lineHeight return paragraphStyle } @@ -50,7 +61,7 @@ class StatusItemView: NSView { NSAttributedString.Key.font: compactModeTimeFont, NSAttributedString.Key.foregroundColor: textColor, NSAttributedString.Key.backgroundColor: NSColor.clear, - NSAttributedString.Key.paragraphStyle: defaultParagraphStyle, + NSAttributedString.Key.paragraphStyle: defaultTimeParagraphStyle, ] return attributes } diff --git a/Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift b/Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift index 52196ac..d5abbd2 100644 --- a/Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift +++ b/Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift @@ -21,7 +21,7 @@ class UpcomingEventStatusItemView: NSView { NSAttributedString.Key.font: compactModeTimeFont, NSAttributedString.Key.foregroundColor: textColor, NSAttributedString.Key.backgroundColor: NSColor.clear, - NSAttributedString.Key.paragraphStyle: defaultParagraphStyle, + NSAttributedString.Key.paragraphStyle: defaultTimeParagraphStyle, ] return attributes }