akiyosi / goneovim

A GUI frontend for neovim.
MIT License
2.39k stars 62 forks source link

Linespace parameter has no effect with negative value #330

Open damanis opened 2 years ago

damanis commented 2 years ago

Both 'Linespace=-1' in .config/goneovim/settings.toml and ':set linespace=-1' from Goneovim. Positive value, seems, works properly.

akiyosi commented 2 years ago

@damanis Linespace has no effect in settings.toml in geneovim. This was a design failure of the goneovim settings: the Neovim side has a linespace setting, and this value overrides the goneovim side's linespace. Therefore, it is necessary to set linespace by "set linespace=x" in init.lua, etc. Also, negative values for linespace have no effect in the current implementation. Do you want to set a negative value to make the line spacing tighter?

damanis commented 2 years ago

@akiyosi

Do you want to set a negative value to make the line spacing tighter?

Yes, I prefer compact lines, but now for same lines number on the screen the bigger goneovim window is needed.

damanis commented 2 years ago

Also, negative values for linespace have no effect in the current implementation

Do you mean in current goneovim implementation? In nvui, for example, it works.

akiyosi commented 2 years ago

The height of each row is calculated from font metrics; smaller values may cause rendering problems.

I recognize the NVUI example, but I do not believe it can be easily accepted by the gooneovim. In fact the description of ":h linespace" is as follows:

'linespace' 'lsp'   number  (default 0)
            global
            {only in the GUI}
    Number of pixel lines inserted between characters.  Useful if the font
    uses the full character cell height, making lines touch each other.
    When non-zero there is room for underlining.
    With some fonts there can be too much room between lines (to have
    space for ascents and descents).  Then it makes sense to set
    'linespace' to a negative value.  This may cause display problems
    though!

If you want to draw more lines, there is another way, for example by setting guifont as follows:

set guifont=fontfamilyname:h9:w5

This is a method of specifying the ratio of the height and width of the font metrics; by specifying a value smaller than the normal height, each glyph will appear stretched or shrunk.

damanis commented 2 years ago

Font size is not same as linespace. May be Go ported QT does not support negative linespace, but original does (used by neovim-qt).

akiyosi commented 2 years ago

@damanis The negative value limitation is done by goneovim and is not a limitation of Qt Go binding. The following commit removes this restriction. Negative values can be set in this artifact. However, please note that as mentioned above, it is expected that some rendering will be incorrect.

https://github.com/akiyosi/goneovim/actions/runs/2304765278

damanis commented 2 years ago

@akiyosi In general, it works. But there are some rendering problem when cursor is moved (with linespace=-1).

image This is normal state. After press twice 'k' (move cursor two lines up) the line '#If not ...' rendered incorrectly.

image

damanis commented 2 years ago

@akiyosi Seems, goneovim adds extra space between lines. I used compact fonts, so text should be compacted ever with linespace=0. There are two examples, both use same font and linespace=0 Goneovim

image FVim

image

akiyosi commented 2 years ago

@damanis Hmmm, there should be no extra space inserted, especially if linespace is 0. If linespace is 0, goneovim will use the font metrics calculated in the Qt layer as is for cell height and width.

damanis commented 2 years ago

@akiyosi Yes, I saw the code. It gets from qt gui float64 metrics, not integer. Maybe math.ceil rounds up?

damanis commented 2 years ago

@akiyosi I checked nvim-qt code - it uses QFontMetrics, not QFontMetricsF.

akiyosi commented 2 years ago

@damanis Thanks for the info! So, are you saying that the extra space does not occur in neovim-qt?

damanis commented 2 years ago

@akiyosi Yes, it doesn't. nvim-qt image

akiyosi commented 2 years ago

@damanis I have created an implementation based on metrics by QFontMetrics. Could you please confirm that it works?

https://github.com/akiyosi/goneovim/actions/runs/2365243227

damanis commented 2 years ago

@akiyosi Seems, it did not help. image

akiyosi commented 2 years ago

@damanis Thank you. I can't see in the screenshot if there is any extra space, does the above screenshot have extra space?

damanis commented 2 years ago

@akiyosi It same as goneovim screenshot above.

damanis commented 2 years ago

@akiyosi May be, the ShellWidget::setCellSize() from neovim-qt shellwidget.cpp might give some idea. Related QT doc: https://doc.qt.io/qt-5/qwidget.html#sizeIncrement-prop

akiyosi commented 2 years ago

@damanis Thanks for the info.

By the way, if you disable the cache mode in settings.toml, does the rendering change a bit?

[Editor]
# ...
CachedDrawing = false
damanis commented 2 years ago

@akiyosi I don't see any difference.

damanis commented 2 years ago

@akiyosi It fixed in c7d444f WindowGeometryBasedOnFontmetrics don't use linespace for calculation, but it easy solve by configuration.

damanis commented 2 years ago

But still interesting where extra line appear from (with linespace=0).