如何更改 VSCode 中的字体?

How to change fonts in VSCode?

似乎到处都在说我只需要改变'editor.fontFamily'。但是怎么办?这是它的默认值:

  "editor.fontFamily": "'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'",

所有这些多个条目是什么意思(例如带引号和不带引号的等宽字体),我如何将其更改为 'DejaVu' 字体?

VScode 通过 CSS 进行样式设置。这被称为“fallback group”。如果一种字体不可用,它会自动从左到右使用下一种字体。

完成您的要求:

"editor.fontFamily": "'DejaVu Mono', 'monospace'"

如果这不起作用,请查找正确的字体名称并将其输入。引号主要用于其中包含空格的名称。

关于多个条目,来自CSS spec

Font family names that happen to be the same as a keyword value ('inherit', 'serif', 'sans-serif', 'monospace', 'fantasy', and 'cursive') must be quoted to prevent confusion with the keywords with the same names.

所以换句话说,monospace是为font-familyCSS属性保留的word/font,如果你有相同的字体名字,你需要引用它。因此 VS Code 的默认设置将 'monospace' 字体优先于默认 monospace 字体。

我希望这是有道理的。