#!/bin/sh # # Test drive a PostScript font # # letter #w=612 #h=792 # a4 w=595 h=842 usage() { echo "usage: tpsf [-c] [-n] [-e enc_file] file" >&2 exit 1 } while getopts ":cne:" c do case "$c" in c) chart=1;; n) nore=1;; e) enc_file=$OPTARG;; :|'?') usage;; esac done shift $(($OPTIND - 1)) if [ $# -lt 1 ]; then usage; fi ts="$(file -L "$1")" t="${ts#*: }" case "$t" in PostScript\ Type\ 1\ font\ text* | PostScript\ Type\ 42\ font\ text*) pfa=$1;; *) tmpfile=$(mktemp ~/.tpsf.XXXXXX) || exit 1 pfa=$tmpfile pfbtops "$1" >$pfa || { rm -f $tmpfile; exit 1; };; esac name=$(grep '/FontName' "$pfa" | sed -E 's/^.*\/FontName (.*) def.*$/\1/') cat "$pfa" echo if [ -n "$chart" ]; then ps="[$w $h]"; else ps="[$h $w]"; fi echo "1 dict dup /PageSize $ps put setpagedevice" echo if [ -z "$nore" ]; then if [ -n "$enc_file" ]; then sed 's/^.*\[[[:space:]]*$/\/Encoding \[/' "$enc_file" else cat <