macvim icon indicating copy to clipboard operation
macvim copied to clipboard

All text is italic after upgrading to macOS Big Sur

Open Naitreey opened this issue 5 years ago • 13 comments

Describe the bug After upgrading macos to latest big sur (11.0.1 as of writing), text in GUI macvim all became italic (while iTerm2 and TUI vim looks normal). Like the following screenshots: CleanShot 2020-12-10 at 15 35 53 CleanShot 2020-12-10 at 15 37 15

Realizing I'm using a custom font, specifically this one, I tried to fix the italic effect by reinstalling the font to system and re-start GUI macvim. It looked, but only temporarily. It seems after one day or two, the problem came back.

I'm not sure what system-wide change might triggered this behavior. But I have definitely turned mac to sleep and back during this time.

Expected behavior Text is normal not italic/oblique.

Environment (please complete the following information):

  • Vim version 8.2.1719
  • OS: macOS 11.0.1
  • Terminal: GUI

Naitreey avatar Dec 10 '20 07:12 Naitreey

Do you know if this is a font issue for sure? When you said "reinstalling the font to system and re-start GUI macvim" what do you mean exactly? Can you just set GUI font to default set guifont= and see if it fixes the issue?

Also, can you run the following in terminal and let me know what you see? defaults read org.vim.MacVim | grep MM

ychin avatar Dec 10 '20 08:12 ychin

To answer your questions, I tried to reproduce the issue but failed. So I'll keep an eye on it and report again if I find anything reproducible.

For the record, Here's what I did before.

When you said "reinstalling the font to system and re-start GUI macvim" what do you mean exactly?

  1. I opened the macOS Font Book app, found the Menlo for Powerline font family, right click and remove the family entirely.
  2. I Added 4 styles of the font family one by one back into the Font Book, Regular, Bold, Italic, etc.
  3. Opened the GUI vim again, and this time it looked normal.

Do you know if this is a font issue for sure?

I'm not absolutely sure it's not just the issue of this font. But since it worked before Big Sur and re-installation works, I thought there might be some sort of sneeky change of macos that macvim didn't adjust to.

Can you just set GUI font to default set guifont= and see if it fixes the issue?

Yes it does.

Output of defaults read org.vim.MacVim | grep MM

    MMAutosaveColumns = 100;
    MMAutosaveRows = 30;
    MMTopLeftPoint = "{2777, 839}";

Naitreey avatar Dec 11 '20 02:12 Naitreey

Yeah I'm thinking it's some font installation issues during the OS upgrade where MacVim couldn't find the regular font. If you can't reproduce I would suggest closing the issue for now.

If you see it again, use set guifont to see what font you have it set to, and also use the builtin font selector (either via the menu or set guifont=*) and see if you could select the font manually (since it may reveal that you don't have the regular font installed).

ychin avatar Dec 11 '20 02:12 ychin

Hi, the issue showed up again. Just a moment ago I opened a new gvim instance and text is italic.

Here's a screenshot of set guifont=*. It looks like Italic sytle took preference over regular style for some reason. I noticed the Regular style of this font is not the first in the Font Book, comparing to other fonts. Maybe this is the cause? CleanShot 2020-12-11 at 11 21 17

Naitreey avatar Dec 11 '20 03:12 Naitreey

So what happens if you pick the regular one in the font selector? Also, what did you put in your vimrc to use Menlo for Powerline as your default font?

ychin avatar Dec 11 '20 03:12 ychin

Is this the font? https://github.com/abertsch/Menlo-for-Powerline

ychin avatar Dec 11 '20 03:12 ychin

If I pick the regular style, text will restore to normal, but only works for current gvim window. Next time italic text comes back again.

In my vimrc:

if g:os == "Linux"
    set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 14
    set guifontwide=Noto\ Sans\ Mono\ CJK\ SC\ 14
elseif g:os == "Darwin"
    set guifont=Menlo\ for\ Powerline:h16
    "set guifont=Source\ Code\ Pro\ for\ Powerline:h16
    set guifontwide=Hiragino\ Sans\ GB\ W3:h16
endif

Is this the font? https://github.com/abertsch/Menlo-for-Powerline

Yes, that's the font I used.

Naitreey avatar Dec 11 '20 05:12 Naitreey

You probably want to do this instead:

set guifont=Menlo\ for\ Powerline-Regular:h16

In fact, after you fixed it in the font selector, if you type set guifont? that should be what you see as well.

ychin avatar Dec 11 '20 05:12 ychin

I still think there is probably something funky going on with the font installation there though, but forcing Regular will work (and italics should still show up if you have highlights that use tem)

ychin avatar Dec 11 '20 06:12 ychin

Forcing -Regular worked for me, except for some reason the correct font name in this case actually has to be:

set guifont=MenloForPowerline-Regular:h16

And I can confirm that italic and bold styles still show up, as tested by:

:so $VIMRUNTIME/syntax/hitest.vim

Naitreey avatar Dec 11 '20 06:12 Naitreey

Nice! Can you close the issue then? I think loading fonts using this method is probably the better way anyway. It could be that in Big Sur they changed the API (https://developer.apple.com/documentation/appkit/nsfont/1525977-fontwithname) behavior, but if you specify "regular" it should always work. This also helps differentiate for fonts that have "light" / etc versions of the font.

ychin avatar Dec 11 '20 08:12 ychin

I had the same issue with the same font in MacOS Sequoia 15.5, set guifont=MenloForPowerline-Regular:h16 saved me. Thank you guys,

flowfelis avatar Jul 19 '25 03:07 flowfelis

Also, keep in mind that these days typing something like set guifont=MenloFor<Tab> can give you tab completion. You can pick from the list of fonts that MacVim can load. No need to guess.

ychin avatar Jul 19 '25 03:07 ychin