#!/bin/sh # # Generate a line of text with arbitrary PostScript font # usage() { echo "usage: pstext [-t text] [-s size] [-x xoff] [-y yoff] file" >&2 exit 1 } text="Mats Peterson" size=48 x=50 y=50 while getopts ":t:s:x:y:" c do case "$c" in t) text=$OPTARG;; s) size=$OPTARG;; x) x=$OPTARG;; y) y=$OPTARG;; :|'?') usage;; esac done shift $(($OPTIND - 1)) if [ $# -lt 1 ]; then usage; fi ts="$(file "$1")" t="${ts#*: }" case "$t" in PostScript\ Type\ 1\ font\ text* | PostScript\ Type\ 42\ font\ text*) pfa=$1;; PostScript\ Type\ 1\ font\ program\ data*) tmpfile=$(mktemp ~/.pstext.XXXXXX) || exit 1 pfa=$tmpfile pfbtops "$1" >$pfa || { rm -f $tmpfile; exit 1; };; *) echo "pstext: Unknown file type" >&2; exit 1;; esac name=$(grep '/FontName' "$pfa" | sed -E 's/^.*\/FontName (.*) def.*$/\1/') cat "$pfa" cat <