如何在没有管理员权限的情况下在VS Code(Windows)中使用自定义字体来安装字体? [英] How to use custom font in VS Code(Windows) without admin privilege to install the font?

查看:254
本文介绍了如何在没有管理员权限的情况下在VS Code(Windows)中使用自定义字体来安装字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在工作正常的PC(Windows 7)上没有管理员权限,因此无法在系统中安装自定义字体(Fira Code).是否可以在不安装VS Code的情况下使用这种字体?

I don't have Admin privilege on my working PC(Windows 7), so I can't install custom font(Fira Code) into my system. Is there a way to use such font without installing in VS Code?

推荐答案

为此问题找到一个丑陋的解决方法:使用网络字体.

Find a ugly workaround for this issue: using webfont.

  1. 打开帮助->切换菜单中的开发人员工具
  2. 将以下js代码粘贴并在DevTools控制台中执行以设置"Fira Code"字体.

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/tonsky/FiraCode/master/distr/eot/FiraCode-Regular.eot') format('embedded-opentype'),
             url('https://raw.githubusercontent.com/tonsky/FiraCode/master/distr/woff2/FiraCode-Regular.woff2') format('woff2'),
             url('https://raw.githubusercontent.com/tonsky/FiraCode/master/distr/woff/FiraCode-Regular.woff') format('woff'),
             url('https://raw.githubusercontent.com/tonsky/FiraCode/master/distr/ttf/FiraCode-Regular.ttf') format('truetype');
        font-weight: normal;
        font-style: normal;
    }`); 
styleNode.appendChild(styleText); 
document.getElementsByTagName('head')[0].appendChild(styleNode);

  1. 确保"Fira代码"是字体系列"设置中的第一个参数.
  2. 启用字体连字设置,否则> ="不会传输到≥"
  3. (可选)在DevTools的源"选项卡中,使用代码创建一个新的代码段,然后右键单击该新创建的文件以运行.重新启动应用程序后,就可以保留它.

这篇关于如何在没有管理员权限的情况下在VS Code(Windows)中使用自定义字体来安装字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆