From 5f9557287db5df5c0de3448fb803101a94c2c17e Mon Sep 17 00:00:00 2001 From: Yee Cheng Chin Date: Fri, 25 Dec 2020 23:06:01 -0800 Subject: [PATCH] Fix issue with font line spacing support and add option for it Recent change to stateful renderer (#858) has inadvertantly changed how MacVim handles line spacing. Previously, MacVim intentionally ignores the line spacing of a font and creates a new dummy font that essentially has line spacing of 1, but the new code uses the font as is. This means font with non-standard line spacing (e.g. Input Mono) will look different. This is technically the correct way to handle fonts but is different from how MacVim has worked for years. Also, see last time this regression (where MacVim didn't discard line spacing) happened in #928 / #949 which was fixed in #957. Also see #977 where the bug was filed the other way requesting for using the font's line spacing instead of discarding it. This commit re-introduces the behavior to discard line spacing, but only provides it as an option (can be set in the preference pane), while defaulting to using the line spacing as that seems more correct. Note that from a casual survey of other terminals and editors, this behavior is quite inconsistent. Xcode does use the font's line spacing, and was partially the motivation of switching to that as a default. Close #1152. --- runtime/doc/gui_mac.txt | 3 +- runtime/doc/tags | 1 + src/MacVim/Base.lproj/Preferences.xib | 75 +++++++++++++++++---------- src/MacVim/MMAppController.h | 1 + src/MacVim/MMAppController.m | 10 ++++ src/MacVim/MMCoreTextView.h | 2 + src/MacVim/MMCoreTextView.m | 64 ++++++++++++++++++++--- src/MacVim/MMPreferenceController.m | 6 +++ src/MacVim/MMTextView.h | 1 + src/MacVim/MMTextView.m | 5 ++ src/MacVim/MMWindowController.h | 1 + src/MacVim/MMWindowController.m | 5 ++ src/MacVim/Miscellaneous.h | 1 + src/MacVim/Miscellaneous.m | 1 + 14 files changed, 141 insertions(+), 35 deletions(-) diff --git a/runtime/doc/gui_mac.txt b/runtime/doc/gui_mac.txt index 5d1fc2b1b3..35a1946c41 100644 --- a/runtime/doc/gui_mac.txt +++ b/runtime/doc/gui_mac.txt @@ -241,7 +241,7 @@ is sent back to the server application. Some settings are global to the MacVim application and would not make sense as Vim options. These settings are stored in the user defaults database and can -be accessed via the "MacVim.Preferences..." menu item. +be accessed via the "MacVim.Preferences…" menu item. *macvim-user-defaults* Not all entries in the user defaults database are exposed via the preference @@ -265,6 +265,7 @@ KEY VALUE ~ *MMNativeFullScreen* use native full screen mode [bool] *MMNoFontSubstitution* disable automatic font substitution [bool] (Deprecated: Non-CoreText renderer only) +*MMFontPreserveLineSpacing* use the line-spacing as specified by font [bool] *MMNoTitleBarWindow* hide title bar [bool] *MMTitlebarAppearsTransparent* enable a transparent titlebar [bool] *MMAppearanceModeSelection* dark mode selection (|macvim-dark-mode|)[bool] diff --git a/runtime/doc/tags b/runtime/doc/tags index 8bf69374f4..1f13751e8f 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -5015,6 +5015,7 @@ MMAppearanceModeSelection gui_mac.txt /*MMAppearanceModeSelection* MMCellWidthMultiplier gui_mac.txt /*MMCellWidthMultiplier* MMDialogsTrackPwd gui_mac.txt /*MMDialogsTrackPwd* MMDisableLaunchAnimation gui_mac.txt /*MMDisableLaunchAnimation* +MMFontPreserveLineSpacing gui_mac.txt /*MMFontPreserveLineSpacing* MMFullScreenFadeTime gui_mac.txt /*MMFullScreenFadeTime* MMLoginShellArgument gui_mac.txt /*MMLoginShellArgument* MMLoginShellCommand gui_mac.txt /*MMLoginShellCommand* diff --git a/src/MacVim/Base.lproj/Preferences.xib b/src/MacVim/Base.lproj/Preferences.xib index 568add5082..c402c241c1 100644 --- a/src/MacVim/Base.lproj/Preferences.xib +++ b/src/MacVim/Base.lproj/Preferences.xib @@ -1,8 +1,9 @@ - + - + + @@ -183,7 +184,7 @@ - - - + @@ -226,11 +227,11 @@ - + - + @@ -291,25 +292,22 @@ - + - - + @@ -318,15 +316,12 @@ - + + + + + + + + + + + + + + + + - + - + @@ -352,7 +375,7 @@ - - + @@ -373,7 +396,7 @@ - - + @@ -395,7 +418,7 @@ - - + @@ -416,7 +439,7 @@ -