如何让我的 vscode 字体像 sublime 一样倾斜?

How to make my vscode font slant like sublime?

我在 VScode 和 sublime 中使用 相同的字体 (Consolas)。但是在同一个地方看起来不一样:

这是我的 sublime 设置:

{
    "auto_complete_selector": "source,text",
    "color_scheme": "Packages/Material Theme/schemes/Material-Theme-Darker.tmTheme",
    "font_face": "Consolas",
    "font_size": 12,
    "ignored_packages":
    [
    ],
    "theme": "Default.sublime-theme"
}

这是我的 vscode 设置:

    "materialTheme.accent": "Blue",
    "editor.fontFamily": "Consolas, 'Courier New', monospace",
    "editor.fontWeight": 520,
    "editor.codeLensFontSize": 11,
    "editor.fontSize": 15,
    "editor.formatOnType": true,
    "debug.console.fontFamily": "Cascadia Mono",
    "python.showStartPage": false,
    "workbench.editorAssociations": [
        {
            "viewType": "jupyter.notebook.ipynb",
            "filenamePattern": "*.ipynb"
        }
    ],
    "explorer.confirmDelete": false,
    "todo-tree.tree.showScanModeButton": true,
    "editor.fontLigatures": true,
    "editor.tokenColorCustomizations": {
       "comments": "#7ea9eb"
    

我的问题是:如何使我的 vscode 字体像 sublime 一样倾斜?

根据 VS Code documentation,您可以使用用户设置中的 editor.tokenColorCustomizations 规则自定义主题颜色:

  1. 打开您的 settings.json 并首先添加以下规则(将 YOUR THEME NAME HERE 替换为您的颜色主题名称):

    "editor.tokenColorCustomizations": {
       "[YOUR THEME NAME HERE]": {
          "textMateRules": []
       }
    }
    
  2. 打开您选择的 Python 文件。然后,使用 Ctrl+Shift+P 和 运行 打开命令面板“开发人员:检查编辑器标记和作用域

  3. 单击您希望将其设为斜体的关键字。例如,我们单击 class 关键字以查看其 TextMate 范围。复制突出显示的第一个 TextMate 范围 ID:

  4. 回到你的settings.json。在 textMateRules 数组中,插入一个新对象,其中 scope 属性 是您刚刚复制的 TextMate 范围 ID。

    "editor.tokenColorCustomizations": {
       "[YOUR THEME NAME HERE]": {
          "textMateRules": [
            {
              "scope": "storage.type.class.python",
              "settings": {
                "fontStyle": "italic"
              }
            }
          ]
       }
    }
    
  5. 保存您的 settings.json,您应该会看到 class 键盘为斜体

备注

您可以在 textMateRules 数组中附加更多对象,使更多关键字的字体变为斜体。例如:

"editor.tokenColorCustomizations": {
  "[YOUR THEME NAME HERE]": {
    "textMateRules": [
      {
        "scope": "variable.parameter.function.language.special.self.python",
        "settings": {
          "fontStyle": "italic"
        }
      },
      {
        "scope": "storage.type.class.python",
        "settings": {
          "fontStyle": "italic"
        }
      }
    ]
  }
},