equalsraf / neovim-qt

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

Rendering issue with mixed fonts on windows #418

Open Warpulis opened 6 years ago

Warpulis commented 6 years ago

merge

I'm using a colorscheme that uses the "normal" fonts for text and bold fonts for certain keywords on python.

This leads to wrong rendering of underscores with Courier New on Windows. The behaviour also depends on the screen (resolution?) used.

On the Screenshot you see:

My guess would be that there is not enough space for the bold glyphs to be rendered properly in "non bold mode" which leads to the most bottom pixels being truncated. The frameworks seems to know this since it's complaining about the font not being monospaced up to a threshold. This also happens i.e. for Consolas at h11 though I've been unable to pinpoint the exact display error there.

Since Courier New is one of the classic fonts it would be nice for it to be properly supported.

equalsraf commented 6 years ago

Given the resolution dependent behaviour I would suspect something strange is going on with the font metrics returned by Qt.

Is any of the screens using HiDpi? We have some issues pending with that https://github.com/equalsraf/neovim-qt/issues/391#issuecomment-363394722

My guess would be that there is not enough space for the bold glyphs to be rendered properly in "non bold mode"

If this were the case then the font is reporting incorrect metrics, or is missing a bold variant and is behind replaced by some other font at runtime. It is also possible the font does not really provide those sizes (but h12 should be pretty common). And neovim-qt reports those cases as errors when you call Guifont https://github.com/equalsraf/neovim-qt/blob/2cd39097caf9e9a44e1d79788e01b2e9f667aa59/src/gui/shellwidget/shellwidget.cpp#L60

We can test this to some extent. Does it help to increase the linespace? using :Guilinespace 2 or some other value might get you the space you need.

If you are building from the source there is a fontinfo executable target that can print font metric information for you.

Warpulis commented 6 years ago

resolution at work is 1920x1200.

I'm questioning my mind, since today I didn't have the half-width underscores as claimed in the original post. instead I'm also seeing the jump from no underscores to "full" underscores with h12 -> h13.

I'm trying to reproduce the half underscores issue, but I'm not aware of anything I changed with the settings. (except from logging in remote.)

Unfortunately, :Guilinespace 2 didn't affect the issue.

I'm using the version from nvim 0.3.0, not building from source. It would be nice to have the debug infos I saw within isBadMonospace. Not sure if I'm able to build from source since I don't have a Windows installation at home.