Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu icon offset fix #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Classes/GSMenuController.m
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,23 @@ - (void)_updateMenuBarIconText:(BOOL)isUsingIntegrated cardString:(NSString *)ca
traits:NSBoldFontMask|NSItalicFontMask
weight:0
size:fontSize];

// Quick fix for menubar icon offset in macOS Big Sur
double baselineOffset = 2.0;
NSProcessInfo* processInfo = [NSProcessInfo processInfo];

// [NSProcessInfo operatingSystemVersion] is only available since macOS 10.10
if ([processInfo respondsToSelector:@selector(operatingSystemVersion)]) {
NSOperatingSystemVersion systemVersion = [processInfo operatingSystemVersion];
// 10.16 is for backward compatibility targeting 10.x SDK
if (systemVersion.majorVersion >= 11 || (systemVersion.majorVersion >= 10 && systemVersion.minorVersion >= 16)) {
baselineOffset = -1.0;
}
}

NSDictionary *attributes = [[NSDictionary alloc] initWithObjectsAndKeys:
boldItalic, NSFontAttributeName,
[NSNumber numberWithDouble:2.0], NSBaselineOffsetAttributeName, nil];
boldItalic, NSFontAttributeName,
[NSNumber numberWithDouble:baselineOffset], NSBaselineOffsetAttributeName, nil];
NSAttributedString *title = [[NSAttributedString alloc]
initWithString:letter
attributes:attributes];
Expand Down