Use MacOS FontForge's embedded Python if available

This commit is contained in:
Vinz Lee 2023-11-04 16:39:30 +07:00
parent 3c615a8557
commit df8d985251
2 changed files with 37 additions and 1 deletions

View file

@ -122,7 +122,7 @@ def generate_nerd_font(f: str):
system = platform.uname()[0]
script = path.join(
root, f"generate-nerdfont.{'bat' if 'Windows' in system else 'sh'}"
root, f"generate-nerdfont{'-mac' if 'Darwin' in system else ''}.{'bat' if 'Windows' in system else 'sh'}"
)
make_sure_eol(script)

36
source/generate-nerdfont-mac.sh Executable file
View file

@ -0,0 +1,36 @@
#!/bin/sh
set -xeuo
python=$(which python3)
output_dir="../output/NF"
font_dir="../output/ttf"
ff_app_dir="/Applications/FontForge.app"
if [ -d "${ff_app_dir}" ]; then
python="${ff_app_dir}/Contents/MacOS/FFPython"
fi
if [ "$3" = "1" ]; then
font_dir="${font_dir}-autohint"
fi
if [ ! -d "${font_dir}" ]; then
echo "Font directory does not exist: ${font_dir}"
exit 1
fi
# full args: https://github.com/ryanoasis/nerd-fonts#font-patcher
args="-l -c --careful"
if [ "$2" = "1" ]; then
args="${args} -s"
fi
font_name="$1"
target_font_path="${font_dir}/${font_name}.ttf"
if [ ! -f "${target_font_path}" ]; then
echo "Font file does not exist: ${target_font_path}"
exit 1
fi
eval "${python} ./FontPatcher/font-patcher ${args} --outputdir ${output_dir} ${target_font_path}"