安裝Fira Code字體


最近發現了一款比較好看的字體Fira Code,支持連體符號如:≡ 、≥、≤、≠ 等。

除了vscode ,還可在幾十種編輯器中設置該字體,包括JetBrains下的 [ IntelliJ IDEA、Webstorm、Pychrm、PhpStrom ... ]、SublimeText、Visual Studio、Notepad++等主流編輯器。

一、下載並安裝該字體

詳細的安裝細節可參考官方GiyHub:https://github.com/tonsky/FiraCode/wiki/Installing

1.1通用方式

使用直接下載壓縮包,將ttf字體文件放在系統字體所在的目錄,或者雙擊字體逐一安裝。
Linux: /usr/share/fonts/
Windows: C:\Windows\Fonts

下載字體包

進入Fira Code字體包GitHub官網, 下載ZIP壓縮包img

1.2 安裝字體

打開壓縮包,進入[FiraCode-master —> distr —> ttf], 選中所有字體, 右鍵選擇安裝img

Linux安裝方式

https://github.com/tonsky/FiraCode/wiki/Linux-instructions#manual-installation
Linux通用方式:

  1. 創建FiraCode.sh文件
touch FiraCode.sh
  1. 將下列shell寫入FiraCode.sh文件中
#!/usr/bin/env bash

fonts_dir="${HOME}/.local/share/fonts"
if [ ! -d "${fonts_dir}" ]; then
    echo "mkdir -p $fonts_dir"
    mkdir -p "${fonts_dir}"
else
    echo "Found fonts dir $fonts_dir"
fi

for type in Bold Light Medium Regular Retina; do
    file_path="${HOME}/.local/share/fonts/FiraCode-${type}.ttf"
    file_url="https://github.com/tonsky/FiraCode/blob/master/distr/ttf/FiraCode-${type}.ttf?raw=true"
    if [ ! -e "${file_path}" ]; then
        echo "wget -O $file_path $file_url"
        wget -O "${file_path}" "${file_url}"
    else
	echo "Found existing file $file_path"
    fi;
done

echo "fc-cache -f"
fc-cache -f
  1. 添加執行權限
chmode +x FiraCode.sh
  1. 運行FiraCode.sh進行安裝

需要注意的是,該腳本會將字體下載到: ~/.local/share/fonts/下,如果要設置為系統字體,將該目錄中的所有字體復制到系統字體目錄中,即sudo cp ~/.local/share/fonts/FiraCode-*.ttf /usr/share/fonts/

二、配置編輯器字體

2.1 配置vscode字體

2.1.1 進入設置中,搜索 [Font Family] , 將Font Family 的值修改為 [Fira code], 重啟編輯器即可。值得注意的是,在Font Family設置的值的時候,最好不要直接在原有值的基礎上添加,可能會無效,直接用Fira code覆蓋原有值即可。

2.1.2 若上個步驟無效,可在settings.json中進行配置(在設置中,搜索 [配置資源要使用的編輯器], 點擊img)。修改或添加如下代碼:

img

2.2配置 JetBrains編輯器

以Pycharm為例,IDAE等大同小異。

2.2.1 配置Font。依次進入:File —> settings —> Editor —> Font, 在右側的Font下拉菜單中選擇Fira Code img, 勾選[Enable font ligatures]。

2.2.2 配置Color Scheme Font默認字體。在左側菜單Font下的Scheme Font中點擊Color Scheme Font,進行如下配置:(其中,Size為字體大小,Line Spacing為行高)

img

三、在其它編輯器中配置Fira Code字體

如果你使用的的編輯器非JetBrains下的IDE、Vscode,或者想在其它編輯器中也配置該字體,可到GitHub中閱讀readme.md文檔,該文檔的 [Editor support] 列舉了所支持的所有編輯器。戳一下進入文檔


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM