linux 腳本安裝 Fira Code 字體

原文鏈接:https://github.com/tonsky/FiraCode/wiki/Linux-instructions#installing-with-a-package-manager
  1. 創建 sh 腳本文件
vim download_and_install.sh
  1. 在文件中寫入以下內容
    若需要指定字體安裝的目錄, 更改 file_path 的值即可
#!/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. 運行腳本
sh download_and_install.sh
  1. 查看本地字體
fc-list

看到這一行就說明已經安裝成功了

...
/root/.local/share/fonts/FiraCode-Light.ttf: Fira Code,Fira Code Light:style=Light,Regular
...
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章