geometra/scripts/gen_fonts.sh

37 lines
856 B
Bash
Executable File

#!/usr/bin/env bash
msdf="msdf-atlas-gen"
gen_glyph_map="dune exec --no-print-directory --display=quiet scripts/gen_glyph_map.exe"
out_dir=assets/fonts/
mkdir -p $out_dir
function gen() {
echo "$1..."
src=$(fc-list "$2" --format='%{file}\n')
[[ -f "$src" ]] ||
(echo "no font matching $2"; exit 1)
dst_png=$out_dir/$1.png
dst_map=$out_dir/$1.map
emsize=$3
[[ "$src" -nt "$dst_png" ]] &&
($msdf \
-font $src \
-type mtsdf \
-imageout $dst_png \
-json >($gen_glyph_map > $dst_map) \
-size $emsize \
-yorigin top \
| exit 1)
}
gen liberation.128 "Liberation Mono:style=regular" 128
gen liberation.32 "Liberation Mono:style=regular" 32
gen p052-roman.96 "P052:style=roman" 96
gen p052-roman.32 "P052:style=roman" 32