- 创建 sh 脚本文件
vim download_and_install.sh
- 在文件中写入以下内容
若需要指定字体安装的目录, 更改 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
- 运行脚本
sh download_and_install.sh
- 查看本地字体
fc-list
看到这一行就说明已经安装成功了
...
/root/.local/share/fonts/FiraCode-Light.ttf: Fira Code,Fira Code Light:style=Light,Regular
...