jetsung Linux 快速安装当前目录及子目录下的所有字体 源码随时更新 https://framagit.org/jetsung/sh-files/-/blob/main/sh/fonts-install.sh https://github.com/jetsung/sh-files/blob/main/sh/fonts-install.sh #!/usr/bin/env bash ## # 安装当前目录及子目录下的字体 ## set -e CUSTOM_FONTS="/usr/share/fonts/custom" [ -d $CUSTOM_FONTS ] || sudo mkdir -p $CUSTOM_FONTS for EXT in ".otf" ".ttf"; do while IFS= read -r -d '' _V; do printf "cp font: %s\n" "$_V" sudo chmod 644 "$_V" sudo cp "$_V" "$CUSTOM_FONTS" done < <(sudo find . -name "*$EXT" -type f -print0) done pushd "$CUSTOM_FONTS" >/dev/null || exit 1 sudo mkfontdir sudo mkfontscale sudo fc-cache popd >/dev/null || exit 1 使用方法 需要给 fonts-install.sh 添加可执行权限:chmod +x fonts-install.sh 将 fonts-install.sh 添加到 PATH 目录下(比如: /usr/local/bin ) 进入字体目录,执行 sudo fonts-install.sh 注意: 若需安装除 otf, ttf 后缀的字体,需要添加到 for 中 for EXT in ".otf" ".ttf"; do