set guifont=default
if has('windows')
"get dpi, strip out utf-16 garbage and new lines
"system() converts 0x00 to 0x01 for 'platform independence'
"should return something like 'PixelsPerXLogicalInch=192'
"get the part from the = to the end of the line (eg '=192') and strip
"the first character
"and convert to a number
let dpi = str2nr(strpart(matchstr(substitute(
\system('wmic desktopmonitor get PixelsPerXLogicalInch /value'),
\'\%x01\|\%x0a\|\%x0a\|\%xff\|\%xfe', '', 'g'),
\'=.*$'), 1))
if dpi > 100
set guifont=high_dpi_font
endif
endif
8条答案
按热度按时间643ylb081#
对于第一个命令,删除空格。空格对于set命令很重要。
对于第二个,它应该是(h指定高度)
我对字体设置的建议是do(如果你的版本支持的话)
这将弹出一个菜单,允许您选择字体。选择字体后,键入
显示当前guifont的设置。然后将该行复制到vimrc或gvimrc中。如果字体中有空格,则添加
\
来转义空格。o2rvlv0m2#
在
12
之前尝试一个\<Space>
,如下所示:8fq7wneg3#
我跨越了同样的问题,我把下面的代码放在文件夹
~/.gvimrc
中,它工作了。p5fdfcr14#
将Regular添加到语法中并使用
gfn
:设置gfn=等宽\常规:h13
acruukt95#
其他答案是你所问的,但如果它对其他人有用,这里是如何从屏幕DPI有条件地设置字体(仅限Windows):
ijnw1ujt6#
您可能会发现我制作的这个插件非常有用,它可以简化
guifont
的设置:https://github.com/awvalenti/vim-simple-guifont。您的vimrc
是这样的,它处理所有操作系统特定的内容:2exbekwf7#
设置guifont=Lucida\控制台:h10
epggiuax8#
在Ubuntu 22中,对于gvim,将“Ubuntu Mono”字体大小设置为11将在.vimrc中显示为:
set guifont=Ubuntu\ Mono\ 11