Ubuntu – How to “install” fonts to use in Visual Studio Code

fontsmono

I have this beautiful mono font https://github.com/tonsky/FiraCode that I'd like to use in Visual Studio Code in Ubuntu.

I downloaded the font files (.ttf), I understood that to make a font systemwide available I have to copy it to /usr/share/fonts, so I sudo-copied those files to /usr/share/fonts/truetype/fira-code

I noticed the premissions after the copy were 750, so I chmoded to 755

Now I go to the Visual Studio Code preferences and tell it I will use "Fira Code", and does nothing. If I change it to "DejaVu Sans Mono" for example, it will use that font.

Doing this, I don't see the fonts in LibreOffice, either.

After this fail, I created a .fonts directory on my home and copied the .ttf files, same result. (I followed the instructons here: https://itsfoss.com/install-fonts-ubuntu-1404-1410/)

Copying the fonts here, I see them in LibreOffice, but I can't use them in Visual Studio Code

So looks like there most be some kind of "font registry" sort to speak, how do you correctly install font files in Ubuntu?

Best Answer

To set this beautiful fonts up use the following steps

  1. Download the fonts from here

  2. Unzip and in the ttf folder double click each file and select install from the dialogue box that appears

  3. Setup VSCode:

    1. Open File -> Preferences -> Settings
    2. Top right click on {} and the user settings (settings.json) will open up
    3. Add the following lines:

      "editor.fontFamily": "'Fira Code'",
      "editor.fontLigatures": true,
      
      • Note: I had to comment out the normal font family entry which I can switch back to by reversing the process.
    4. To change the font weight add any of the following lines but not all

      "editor.fontWeight": "300" // Light
      "editor.fontWeight": "400" // Regular
      "editor.fontWeight": "500" // Medium
      "editor.fontWeight": "600" // Bold
      
  4. Restart and enjoy.

    enter image description here

My sample user settings.json

{
    "files.autoSave": "onFocusChange",
    "editor.minimap.enabled": false,
    "workbench.iconTheme": "material-icon-theme",
    "vsicons.projectDetection.autoReload": true,
    "workbench.editor.enablePreview": false,
    "workbench.editor.enablePreviewFromQuickOpen": false,
    // "editor.fontFamily": "'Noto Mono', 'Droid Sans Mono', 'Courier New', monospace, 'Droid Sans Fallback'",
    "breadcrumbs.enabled": true,
    "typescript.updateImportsOnFileMove.enabled": "always",
    "git.enableSmartCommit": true,
    "java.home": "/usr/lib/jvm/java-8-oracle",
    // "editor.fontLigatures": true,
    "editor.fontFamily": "'Fira Code', 'Noto Mono', 'Droid Sans Mono', 'Courier New', monospace, 'Droid Sans Fallback'",
    "editor.fontLigatures": true,
    // "editor.fontWeight": "300", // Light
    // "editor.fontWeight": "400", // Regular
    // "editor.fontWeight": "500", // Medium
    // "editor.fontWeight": "600" // Bold
}
Related Question