-
-
Notifications
You must be signed in to change notification settings - Fork 680
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support native macOS monospace font (SF Mono)
Can now set guifont to `-monospace-` to use the system default monospace font, which is SF Mono on recent macOS versions (but could be updated to other fonts in future macOS releases). The reason why this is necessary instead of specifying the actual font name is that Apple does not expose the SF Mono font for the user and instead only exposes an AppKit API `monospacedSystemFontOfSize:weight:` to access it. The actual font name (`.AppleSystemUIFontMonospaced` in macOS 14) is internal and subject to change in different OS versions. In older macOS versions, setting `-monospace-` will just use `Menlo-Regular` just like the default font. Also allow specifying the font weight for the font, e.g. `-monospace-Semibold` / `-monospace-Light`. The list of weights follows the NSFontWeight enum, but not all values yield unique fonts. E.g. "UltraLight", "Thin", "Light" will all use the "Light" version of SF Mono. The list of all font weights can be tab-completed but only if the user has already filled in `-monospace-` in `:set guifont=`. This helps prevents showing too many options when the user does tab completion just to see the list of all fonts. Note that SF Mono is currently available to be downloaded from Apple's website as a standalone for testing. That font is mostly the same but seems to have slightly different line spacing behavior, and when using bold it uses the "Bold" font variant, whereas the system monospace font uses "Semibold" variant instead. Also make font panel not show misc formatting options like underline as they aren't used by MacVim. Keep the background/foreground option just so the font preview colors in the panel can be adjusted. Also fix an existing potential buffer overflow issue in the Core Text renderer in that `changeFont:` (when setting a new font using font panel or using font size up/down) isn't setting `wideLen` which could cause an unsafe memory access in Vim side. Notes: - Known issue: When using macaction `fontSizeUp:`/`fontSizeDown:` (Cmd +/-), `-monospace-` will get replaced by the internal font name (e.g. `.AppleSystemUIFontMonospaced-Regular`) instead due to how the `changeFont:` currently works. This could be fixed but it's low enough priority that it's ok for now. - In the future, this may become the default font instead of Menlo, to make MacVim more consistent with Apple software like Terminal and Xcode.
- Loading branch information
Showing
12 changed files
with
188 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters