Skip to content

Instantly share code, notes, and snippets.

@adamdehaven
Created February 7, 2020 19:06
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save adamdehaven/10fe04b212dfc28bc7a092a849ccd2e1 to your computer and use it in GitHub Desktop.
Save adamdehaven/10fe04b212dfc28bc7a092a849ccd2e1 to your computer and use it in GitHub Desktop.
VS Code Custom Font without Font Install Privileges

VS Code Custom Font without Font Install Admin Privileges

  1. Open Help -> Toggle Developer Tools in the menu (Ctrl + Shift + I)

  2. Paste JavaScript code below into the Console and execute.

    var styleNode = document.createElement('style'); 
    styleNode.type = "text/css"; 
    var styleText = document.createTextNode(`
        @font-face {
            font-family: "Fira Code";
            src: url("https://raw.githubusercontent.com/adamdehaven/FiraCode/master/distr/woff2/FiraCode-Regular.woff2") format("woff2"),
                url("https://raw.githubusercontent.com/adamdehaven/FiraCode/master/distr/woff/FiraCode-Regular.woff") format("woff"),
                url("https://raw.githubusercontent.com/adamdehaven/FiraCode/master/distr/ttf/FiraCode-Regular.ttf") format("truetype"),
                url("https://raw.githubusercontent.com/adamdehaven/FiraCode/master/distr/otf/FiraCode-Regular.otf") format("opentype");
            font-weight: normal;
            font-style: normal;
        }`); 
    styleNode.appendChild(styleText); 
    document.getElementsByTagName('head')[0].appendChild(styleNode);
  3. Ensure 'Fira Code' is the first entry in VS Code Font Family settings: 'Fira Code', Consolas, 'Courier New', monospace

  4. Enable Font Ligatures in settings: "editor.fontLigatures": true

  5. Optional: In the "Sources" tab of the Developer Tools, create a new Snippet with the code above, right-click the created Snippet to execute. This can be preserved even after restarting the application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment