iosevka-custom/post-process.sh

56 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# Based on:
# https://github.com/sdothum/dotfiles/tree/main/bin/bin/functions/font
font_loc=./dist/Iosevka/TTF/
pushd .
cd $font_loc
regular=$(ls -1 | grep -Ev 'italic|oblique|extended')
italic=$(ls -1 | grep -E 'italic')
basefont() { echo $1 | grep -q '[-]italic.ttf' && echo "${1%italic*}regular.ttf" || echo "${1%italic*}.ttf"; }
# some defaults
ANGLE=${ANGLE:--9} # iosevka italic angle (verify with fontforge).. see font/iosevka
XSHIFT=${XSHIFT:--40} # italic descending capital left side bearing shift
extended=576 # extended regular shape (slightly tighter than Iosevka defaults)
expanded=600 # maximum terminal source code and proof legibility
shape=$expanded
# flit t in a regular font and shift to the left of cell
for f in $regular ;do
echo "Flipping t in $f"
echo "
Open(\$1);
Select(0u0074);
HFlip();
Move($XSHIFT,0); # tweak side bearing towards left
SetWidth($shape);
Generate(\$1);
" | fontforge --quiet --lang=ff --script - $f
done
# italicize flipped from regular glyph and shift to left of cell
for f in $italic ;do
echo "Flipping t in $f"
echo echo "
Open(\$2);
Select(0u0074);
Italic($ANGLE);
Copy();
Open(\$1);
Select(0u0074);
Paste();
Move($XSHIFT,0); # adjust for italic side bearing shift towards left
SetWidth($shape);
Generate(\$1);
" | fontforge --quiet --lang=ff --script - $i $(basefont $i)
done
# return to the initial directory and exit
popd