无法在Windows终端中更改字体。

11
尝试通过settings.json自定义Windows终端,我找到了一个与新约定足够接近的profiles.json,在将其粘贴到settings.json时它能够正常工作(我知道它起作用是因为主题改变了)。问题在于,“fontFace”更改没有任何效果。我正在尝试在某些powerline内容中使用nerd font,在运行于ConEmu的Powershell中可以使用,但在Windows终端中不行。以下是settings.json的相关部分:
{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",

    // You can add more global application settings here.
    // To learn more about global settings, visit https://aka.ms/terminal-global-settings

    // If enabled, selections are automatically copied to your clipboard.
    "copyOnSelect": false,

    // If enabled, formatted data is also copied to your clipboard
    "copyFormatting": false,

    // A profile specifies a command to execute paired with information about how it should look and feel.
    // Each one of them will appear in the 'New Tab' dropdown,
    //   and can be invoked from the commandline with `wt.exe -p xxx`
    // To learn more about profiles, visit https://aka.ms/terminal-profile-settings
    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
            "cursorShape": "vintage",
            "fontFace": "Iosevka Nerd Font"
        },
        "list":
        [
            {
                // Make changes here to the powershell.exe profile.
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false,
                "fontFace": "Iosevka Nerd Font",
                "colorScheme": "PowerShellTom",
                "useAcrylic": true,
                "acrylicOpacity": 0.8
            },
            { ...

我在Windows Terminal Preview中看到了相同的行为,这个版本应该是最不"前沿"的版本。

即使尝试使用非技术人员字体作为"fontFace",也没有效果,但是"fontSize"会起作用。


你使用的 Windows 终端版本是什么? - apena
关于对话框显示的版本为 Version: 1.0.1401.0。 - Tom Fetherston
对于“Windows Terminal Preview”(也有同样的问题),它的版本是:1.1.1671.0。 - Tom Fetherston
我成功地使用了'Cascadia Mono PL'字体,只需在上述注册表路径中添加一个注册表字符串即可:值名称:CascadiaMonoPL.ttf 值数据:C:\Users\tfeth\OneDrive\Documents\Fonts_Power_Line\CascadiaMonoPL.ttf。尝试类似的方法来安装Iosevka字体,但是没有成功。 - Tom Fetherston
那也是我的经验。同时在Windows终端问题#6606上发布。 - Tom Fetherston
显示剩余4条评论
5个回答

40

对于那些来自SCOTT HANSELMAN文章(尤其是第三步)的人

  1. 为所有用户安装Cascadia Code

enter image description here

在settings.json中将"fontFace"属性更改为以下内容:
打开settings.json的快捷方式:Ctrl+Shift+,(逗号)

enter image description here

这里是要复制的代码

"profiles": {
   "defaults": {
      "fontFace": "Cascadia Code PL"
      // Put settings here that you want to apply to all profiles.
    }
}

这是我尝试了两个小时后才让它工作的唯一方法。


1
我在使用Windows终端时遇到了这个问题。这个答案解决了我的问题! - Konstantinos Raptis
很奇怪,只有 Cascadia Code 的 PL 变体在我的笔记本电脑上可以使用,而其他变体则不行,就像答案所述。我已经尝试了其余的变体,它们都显示为矩形。 - Francis
2
打开 settings.json 的快捷键:Ctrl+Shift+, (逗号) - Aleksei Zyrianov

4

将fontFace从"Iosevka Nerd Font"改为"Iosevka";据我所知,fontFace属性期望一个字体系列,文档中似乎没有提到这一点,我是在阅读WT github上的此问题后才发现的。


3
我想在WindowsTerminal for WSL中安装MesloLGS NF Regular字体作为Powerlevel10k的推荐字体: https://github.com/romkatv/powerlevel10k/blob/master/font.md 为了使其工作,我必须要做以下操作:
  1. 像@hakan-fıstık所展示的那样为所有用户安装它。
  2. 在settings.json中更改“fontFace”为“MesloLGS NF”(提供字体的全名不起作用)。
  3. 一定要更改字体大小(更改字体可能会使其变得巨大):https://learn.microsoft.com/en-us/windows/terminal/customize-settings/profile-appearance

3

从我在Windows Terminal的GitHub页面上开启的问题(#6606)的评论中,我被引导到另一个fontFace问题,在那里选择另一个字体如果您重新打开WT,则不会坚持选择另一个字体(不完全是我遇到的问题)。

无论如何,当前解决该问题的方法是卸载您想要使用的任何字体,然后右键单击并选择“为所有用户安装”。双击文件以打开示例视图,并在两个按钮下方找到字体名称。在您的settings.json文件中按原样使用字体名称中的空格。

这对MesloLGL NF有效,但对Iosevka NF无效。


1
根据我的经验,手动编辑“settings.json”文件会产生更多问题而不是解决问题。编辑终端默认字体的最简单方法如下:
  1. 打开设置
  2. 在侧边栏的“配置文件”标题下选择Ubuntu
  3. 向下滚动到“其他设置”并选择“外观”
  4. 在文本标题下,将“字体”属性更改为您喜欢的字体 enter image description here
  5. 打开“settings.json”以查看更改
  6. 您应该看到选择字体的预期格式-如果您希望手动编辑json文件,则应遵循此格式 enter image description here
  7. 保存更改并退出

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接