Files
FontMM/功能/TTC文件拆分.sh
T
YuleBest f5363ca488 refactor(fonttool): 更换自制的字体处理工具
更换自制 fonttool-rs
优化环境处理,确保权限
优化代码格式
2026-02-05 20:43:38 +08:00

51 lines
1.0 KiB
Bash

#!/bin/bash
# FontMM
# TTC 文件拆分
# By Yule
# shellcheck disable=SC2154
# 配置
SCRIPT_DIR="$(dirname "$(dirname "$(readlink -f "$0")")")"
WORK_DIR="$SCRIPT_DIR/WORK"
. "$SCRIPT_DIR/功能/bin/configurer.sh"
clear
# shellcheck disable=SC2329
cleanup() {
echo "清理临时文件,请稍后..."
rm -rf "/data/adb/local/tmp/fontmm"
exit
}
trap 'cleanup' EXIT
# 环境检查
if ! command -v fonttool-rs >/dev/null 2>&1; then
echo -e "${re}[错误] 缺少 fonttool-rs,请检查环境${res}"
exit 1
fi
mkdir -p "$WORK_DIR/ttc_separated"
echo -en "- 输入一个 TTC 文件完整路径:"
read -r ttc_file
if [ ! -f "$ttc_file" ]; then
echo "! $ttc_file 文件不存在"
exit 1
fi
if ! file "$ttc_file" | grep -q "TrueType font collection"; then
echo "! 这不是一个 TTC 文件"
exit 2
fi
echo "~ 正在使用 fonttool 拆分 TTC..."
if fonttool-rs split -i "$ttc_file" -o "$WORK_DIR/ttc_separated"; then
echo "~ 拆分成功"
echo "$WORK_DIR/ttc_separated"
exit 0
else
echo "! 拆分失败"
exit 3
fi