mirror of
https://github.com/neovim/neovim.git
synced 2026-04-02 05:39:26 +00:00
feat(defaults): per-platform 'guifont' default #37175
Problem: Font rendering and kerning are subpar in GUIs. Solution: Set default 'guifont' based on common CSS fonts per: https://github.com/system-fonts/modern-font-stacks#monospace-code
This commit is contained in:
@@ -3344,7 +3344,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
<
|
||||
|
||||
*'guifont'* *'gfn'* *E235* *E596*
|
||||
'guifont' 'gfn' string (default "")
|
||||
'guifont' 'gfn' string (default "Source Code Pro, DejaVu Sans Mono, Courier New")
|
||||
global
|
||||
This is a list of fonts which will be used for the GUI version of Vim.
|
||||
In its simplest form the value is just one font name. When
|
||||
|
||||
2
runtime/lua/vim/_meta/options.lua
generated
2
runtime/lua/vim/_meta/options.lua
generated
@@ -3237,7 +3237,7 @@ vim.go.gcr = vim.go.guicursor
|
||||
---
|
||||
---
|
||||
--- @type string
|
||||
vim.o.guifont = ""
|
||||
vim.o.guifont = "Source Code Pro, DejaVu Sans Mono, Courier New"
|
||||
vim.o.gfn = vim.o.guifont
|
||||
vim.go.guifont = vim.o.guifont
|
||||
vim.go.gfn = vim.go.guifont
|
||||
|
||||
@@ -32,6 +32,17 @@
|
||||
"%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-Gg%\\?make[%*\\d]: *** [%f:%l:%m,%-Gg%\\?make: *** [%f:%l:%m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory %*[`']%f',%X%*\\a[%*\\d]: Leaving directory %*[`']%f',%D%*\\a: Entering directory %*[`']%f',%X%*\\a: Leaving directory %*[`']%f',%DMaking %*\\a in %f,%f|%l| %m"
|
||||
#endif
|
||||
|
||||
// Default values for 'guifont'
|
||||
#ifdef MSWIN
|
||||
# define DFLT_GFN "Cascadia Code, Cascadia Mono, Consolas, Courier New"
|
||||
#elif defined(__APPLE__)
|
||||
# define DFLT_GFN "SF Mono, Menlo, Monaco, Courier New"
|
||||
#elif defined(__linux__)
|
||||
# define DFLT_GFN "Source Code Pro, DejaVu Sans Mono, Courier New"
|
||||
#else
|
||||
# define DFLT_GFN "DejaVu Sans Mono, Courier New"
|
||||
#endif
|
||||
|
||||
#define DFLT_GREPFORMAT "%f:%l:%m,%f:%l%m,%f %l%m"
|
||||
|
||||
// Possible values for 'encoding'
|
||||
|
||||
@@ -3996,7 +3996,9 @@ local options = {
|
||||
},
|
||||
{
|
||||
abbreviation = 'gfn',
|
||||
defaults = '',
|
||||
defaults = {
|
||||
if_true = macros('DFLT_GFN', 'string'),
|
||||
},
|
||||
desc = [=[
|
||||
This is a list of fonts which will be used for the GUI version of Vim.
|
||||
In its simplest form the value is just one font name. When
|
||||
|
||||
@@ -210,6 +210,7 @@ describe(':TOhtml', function()
|
||||
exec('set termguicolors')
|
||||
local bg = fn.synIDattr(fn.hlID('Normal'), 'bg#', 'gui')
|
||||
local fg = fn.synIDattr(fn.hlID('Normal'), 'fg#', 'gui')
|
||||
exec_lua [[vim.o.guifont='Courier New' ]]
|
||||
n.command('2,2TOhtml')
|
||||
local out_file = api.nvim_buf_get_name(api.nvim_get_current_buf())
|
||||
eq({
|
||||
@@ -221,7 +222,7 @@ describe(':TOhtml', function()
|
||||
'<title></title>',
|
||||
('<meta name="colorscheme" content="%s"></meta>'):format(api.nvim_get_var('colors_name')),
|
||||
'<style>',
|
||||
'* {font-family: monospace}',
|
||||
('* {font-family: "%s",monospace}'):format(n.eval('&guifont')),
|
||||
('body {background-color: %s; color: %s}'):format(bg, fg),
|
||||
'.Visual {background-color: #9b9ea4}',
|
||||
'</style>',
|
||||
|
||||
@@ -45,6 +45,7 @@ describe('UI receives option updates', function()
|
||||
table.insert(clear_opts.args_rm or {}, '--cmd')
|
||||
clear(clear_opts)
|
||||
screen = Screen.new(20, 5, screen_opts)
|
||||
defaults.guifont = eval('&guifont')
|
||||
-- NB: UI test suite can be run in both "linegrid" and legacy grid mode.
|
||||
-- In both cases check that the received value is the one requested.
|
||||
defaults.ext_linegrid = screen._options.ext_linegrid or false
|
||||
|
||||
Reference in New Issue
Block a user