#!/bin/sh # # Edit AFM file in order to enable 'ff', 'fi', 'fl', 'ffi' and 'ffl' ligatures # [ $# -eq 0 ] && { echo "usage: fixlig afm_file" >&2; exit 1; } [ -f "$1" ] || { echo "fixlig: Can't find file '$1'" >&2; exit 1; } tmpfile=$(mktemp ~/.fixlig.XXXXXX) || exit 1 cat "$1" | nawk ' /^C 102 / { where = match($0, /; L /) if (where != 0) printf substr($0, 1, where) else printf $0 print " L f ff ; L i fi ; L l fl ;" next } /; N ff ;/ { where = match($0, /; L /) if (where != 0) printf substr($0, 1, where) else printf $0 print " L i ffi ; L l ffl ;" next } { print }' >$tmpfile mv -f $tmpfile "$1" chmod go+r "$1" .