equalsraf / neovim-qt

Neovim client library and GUI, in Qt5.
https://github.com/equalsraf/neovim-qt/wiki
ISC License
1.83k stars 171 forks source link

GuiFont not a fixed pitch font #1083

Open sajadspeed opened 11 months ago

sajadspeed commented 11 months ago

I want Noto Sans Mono font: :GuiFont Noto Sans Mono

But i got this error: Noto Sans Mono is not a fixed pitch font

‌ My Fonts: fc-list | grep NotoSansMono

/usr/share/fonts/truetype/noto/NotoSansMono-Light.ttf: Noto Sans Mono,Noto Sans Mono Light:style=Light,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-Regular.ttf: Noto Sans Mono:style=Regular
/usr/share/fonts/truetype/noto/NotoSansMono-CondensedLight.ttf: Noto Sans Mono,Noto Sans Mono Condensed Light:style=Condensed Light,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-SemiCondensedBlack.ttf: Noto Sans Mono,Noto Sans Mono SemiCondensed Black:style=SemiCondensed Black,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-SemiCondensedLight.ttf: Noto Sans Mono,Noto Sans Mono SemiCondensed Light:style=SemiCondensed Light,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-CondensedExtraBold.ttf: Noto Sans Mono,Noto Sans Mono Condensed ExtraBold:style=Condensed ExtraBold,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-ExtraLight.ttf: Noto Sans Mono,Noto Sans Mono ExtraLight:style=ExtraLight,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-CondensedBold.ttf: Noto Sans Mono,Noto Sans Mono Condensed:style=Condensed Bold,Bold
/usr/share/fonts/truetype/noto/NotoSansMono-CondensedExtraLight.ttf: Noto Sans Mono,Noto Sans Mono Condensed ExtraLight:style=Condensed ExtraLight,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-SemiBold.ttf: Noto Sans Mono,Noto Sans Mono SemiBold:style=SemiBold,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-ExtraCondensedBold.ttf: Noto Sans Mono,Noto Sans Mono ExtraCondensed:style=ExtraCondensed Bold,Bold
/usr/share/fonts/truetype/noto/NotoSansMono-ExtraCondensedThin.ttf: Noto Sans Mono,Noto Sans Mono ExtraCondensed Thin:style=ExtraCondensed Thin,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-CondensedMedium.ttf: Noto Sans Mono,Noto Sans Mono Condensed Medium:style=Condensed Medium,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-ExtraCondensedMedium.ttf: Noto Sans Mono,Noto Sans Mono ExtraCondensed Medium:style=ExtraCondensed Medium,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-SemiCondensedBold.ttf: Noto Sans Mono,Noto Sans Mono SemiCondensed:style=SemiCondensed Bold,Bold
/usr/share/fonts/truetype/noto/NotoSansMono-SemiCondensed.ttf: Noto Sans Mono,Noto Sans Mono SemiCondensed:style=SemiCondensed,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-ExtraCondensedSemiBold.ttf: Noto Sans Mono,Noto Sans Mono ExtraCondensed SemiBold:style=ExtraCondensed SemiBold,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-ExtraCondensedExtraBold.ttf: Noto Sans Mono,Noto Sans Mono ExtraCondensed ExtraBold:style=ExtraCondensed ExtraBold,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-Medium.ttf: Noto Sans Mono,Noto Sans Mono Medium:style=Medium,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-Thin.ttf: Noto Sans Mono,Noto Sans Mono Thin:style=Thin,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-ExtraCondensed.ttf: Noto Sans Mono,Noto Sans Mono ExtraCondensed:style=ExtraCondensed,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-Bold.ttf: Noto Sans Mono:style=Bold
/usr/share/fonts/truetype/noto/NotoSansMono-Condensed.ttf: Noto Sans Mono,Noto Sans Mono Condensed:style=Condensed,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-SemiCondensedSemiBold.ttf: Noto Sans Mono,Noto Sans Mono SemiCondensed SemiBold:style=SemiCondensed SemiBold,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-SemiCondensedExtraLight.ttf: Noto Sans Mono,Noto Sans Mono SemiCondensed ExtraLight:style=SemiCondensed ExtraLight,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-CondensedThin.ttf: Noto Sans Mono,Noto Sans Mono Condensed Thin:style=Condensed Thin,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-CondensedSemiBold.ttf: Noto Sans Mono,Noto Sans Mono Condensed SemiBold:style=Condensed SemiBold,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-SemiCondensedMedium.ttf: Noto Sans Mono,Noto Sans Mono SemiCondensed Medium:style=SemiCondensed Medium,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-ExtraCondensedBlack.ttf: Noto Sans Mono,Noto Sans Mono ExtraCondensed Black:style=ExtraCondensed Black,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-Black.ttf: Noto Sans Mono,Noto Sans Mono Black:style=Black,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-SemiCondensedThin.ttf: Noto Sans Mono,Noto Sans Mono SemiCondensed Thin:style=SemiCondensed Thin,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-ExtraCondensedLight.ttf: Noto Sans Mono,Noto Sans Mono ExtraCondensed Light:style=ExtraCondensed Light,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-ExtraBold.ttf: Noto Sans Mono,Noto Sans Mono ExtraBold:style=ExtraBold,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-CondensedBlack.ttf: Noto Sans Mono,Noto Sans Mono Condensed Black:style=Condensed Black,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-ExtraCondensedExtraLight.ttf: Noto Sans Mono,Noto Sans Mono ExtraCondensed ExtraLight:style=ExtraCondensed ExtraLight,Regular
/usr/share/fonts/truetype/noto/NotoSansMono-SemiCondensedExtraBold.ttf: Noto Sans Mono,Noto Sans Mono SemiCondensed ExtraBold:style=SemiCondensed ExtraBold,Regular
equalsraf commented 11 months ago

fc-list does list the fonts, but if GuiFont is failing either there is a problem with the font itself (usually different size for different variants), or some issue with the Qt font metrics code.

We keep a little binary in src/gui/shellwidget/fontinfo.cpp that prints out the font metrics reported by Qt.

As workaround you can also force the font using GuiFont! fontname.

hoofcushion commented 11 months ago

How to force the font by using lua? I use lua vim.opt.guifont="<font-name>" but I got an error like this: image

equalsraf commented 11 months ago

The lua code would be

vim.cmd('GuiFont ...')

If you are running this from init.lua instead of ginit.vim, then you will need something like an autocommand for UIEnter.

hoofcushion commented 11 months ago

It seems there is no command called GuiFont

Both :lua vim.cmd('GuiFont') and :GuiFont doesn't work image image

Am I doing anything wrong?

hoofcushion commented 11 months ago

I got it, nvim_gui_shim.vim is required. and somehow I haven't got one.

equalsraf commented 11 months ago

I got it, nvim_gui_shim.vim is required. and somehow I haven't got one.

Usually you don't need to set it up manually, check its path in https://github.com/equalsraf/neovim-qt#why-are-the-gui-commands-missing

hoofcushion commented 11 months ago

To force the font by using lua, use this lua vim.rpcnotify(0, 'Gui', 'Font', <font-name>, "!").

hoofcushion commented 11 months ago

Usually you don't need to set it up manually, check its path in https://github.com/equalsraf/neovim-qt#why-are-the-gui-commands-missing

I checked, and it just wasn't there, I download one from the repo, and everything is fine now, thanks.

equalsraf commented 11 months ago

That sounds like it is looking for it in the wrong place. If you are building from source it would be in src/gui/runtime. If you installed from some package, it sounds broken, where did you install from?

hoofcushion commented 11 months ago

I think it's from the official website of Neovim

  1. Install Now image
  2. Redirect to Github Wiki
  3. Install from download
  4. Latest stable release
  5. Windows image
sajadspeed commented 11 months ago

I use NotoSansM Nerd Font Mono and is ok. thank you all for your answeres.

equalsraf commented 11 months ago

I assume it is this font https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Noto/Sans-Mono is that correct?

sajadspeed commented 11 months ago

I assume it is this font https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Noto/Sans-Mono is that correct?

Yes, I also use this font.