Merge remote-tracking branch 'batch_font_render/master'
This commit is contained in:
commit
221362d19b
1 changed files with 54 additions and 0 deletions
54
render.zsh
Normal file
54
render.zsh
Normal file
|
@ -0,0 +1,54 @@
|
|||
#!/bin/zsh
|
||||
in=(**/*.(otf|ttf))
|
||||
size=16
|
||||
outdir='rendered-again'
|
||||
lipsum='Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.'
|
||||
|
||||
mkdir -p $outdir
|
||||
|
||||
flags=(-q --font $size --pixels --justify --hinting=auto)
|
||||
flags+=(--width=$((size*32)) --margin=$((size*4))\ $((size*5)))
|
||||
|
||||
cleanup() {
|
||||
rm -f $tf $out
|
||||
rm -rf $td
|
||||
exit
|
||||
}
|
||||
trap cleanup INT
|
||||
|
||||
tf=$(mktemp)
|
||||
td=$(mktemp -d)
|
||||
<<<"$lipsum">$tf
|
||||
export FONTCONFIG_PATH=$td
|
||||
|
||||
<<<'<?xml version="1.0"?>
|
||||
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
||||
<fontconfig>
|
||||
<dir>'$td'</dir>
|
||||
<cachedir>'$td'</cachedir>
|
||||
<include ignore_missing="yes">/etc/fonts/infinality/infinality.conf</include>
|
||||
<config></config>
|
||||
</fontconfig>
|
||||
'>>$td/fonts.conf
|
||||
|
||||
for font in ${in[@]}; do
|
||||
filename=${font:t}
|
||||
stripped=${filename:r}
|
||||
out=$outdir/$stripped.png
|
||||
[ -s $out ] && continue
|
||||
|
||||
ok=1
|
||||
cp $font $td
|
||||
pango-view ${flags[@]} -o $out $tf 2>&1 | while read -r; do
|
||||
<<<$REPLY >&2
|
||||
ok=0
|
||||
done
|
||||
[ $ok -eq 1 ] && <<<$stripped || {
|
||||
<<<$'\e[7m'$stripped$'\e[0m'
|
||||
rm -f $out
|
||||
}
|
||||
|
||||
rm -f $td/$filename $td/*.cache-4
|
||||
done
|
||||
|
||||
cleanup
|
Loading…
Reference in a new issue