This example is based on Ubuntu Mono downloaded from Google Fonts.
-
Go to the installation directory. The installation directory should contain
bin/,extensions/,out/andresources/subdirectories.cd ~/.vscode/cli/serve-web/d78a74bcdfad14d5d3b1b782f87255d802b57511/-
For Microsoft’s
code serve-webit is in~/.vscode-cli/server-stable-web/bin/<HASH>/.There’s a
~/.vscode/cli/serve-web/lru.jsonwhich likely contains the version hash.
-
-
Create a font directory in the installation directory.
cd ~/.vscode/cli/serve-web/d78a74bcdfad14d5d3b1b782f87255d802b57511/ mkdir fonts -
Copy the fonts files to the fonts directory.
cp ~/Downloads/Ubuntu_Mono/*.ttf fonts/ -
Edit
fonts/fonts.cssto load the font files.@font-face { font-family: 'Ubuntu Mono'; font-style: normal; font-weight: 400; src: url(UbuntuMono-Regular.ttf) format('truetype'); } @font-face { font-family: 'Ubuntu Mono'; font-style: normal; font-weight: 700; src: url(UbuntuMono-Bold.ttf) format('truetype'); } @font-face { font-family: 'Ubuntu Mono'; font-style: italic; font-weight: 400; src: url(UbuntuMono-Italic.ttf) format('truetype'); } @font-face { font-family: 'Ubuntu Mono'; font-style: italic; font-weight: 700; src: url(UbuntuMono-BoldItalic.ttf) format('truetype'); } -
Insert an
@importstatement at the top ofout/vs/code/browser/workbench/workbench.cssto include the customfonts.css.@import url("../../../../../fonts/fonts.css"); /*!-------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. ...NOTE: Imported rules must come before all other types of rules. See https://developer.mozilla.org/en-US/docs/Web/CSS/@import
-
Add our font to
settings.json.{ "editor.fontFamily": "'Ubuntu Mono', monospace", } -
Reload the window to take effect.
Troubleshooting
Font is not loading
Clear the browser cache and reload the page.
Cursor is misaligned in the editor window
Try:
- Set
"editor.disableMonospaceOptimizations": true,. - Change
"editor.fontLigatures". - Change
"editor.fontSize".