Papure/scripts/subset-fonts.sh
2026-09-26 19:13:02 +02:00

13 lines
659 B
Bash
Executable file

#!/usr/bin/env bash
# Subsets the bundled fonts to Latin (+Extended), Greek, Cyrillic, punctuation,
# arrows and common math. pdf-lib's own subsetter drops glyphs, so the PDF
# writer embeds these pre-subset files whole.
set -euo pipefail
cd "$(dirname "$0")/.."
UNICODES="U+0000-024F,U+0300-036F,U+0370-03FF,U+0400-04FF,U+1E00-1EFF,U+2000-206F,U+20A0-20CF,U+2100-214F,U+2190-21FF,U+2200-22FF,U+2460-24FF,U+25A0-25FF,U+2713,U+2717"
for f in static/fonts/*.ttf; do
pyftsubset "$f" --unicodes="$UNICODES" --layout-features='kern,liga,calt,ccmp,locl,mark,mkmk' \
--no-hinting --desubroutinize --output-file="$f.sub"
mv "$f.sub" "$f"
done
ls -la static/fonts