:
# width - produce C troff width table from HP ASCII file
# Usage: width hpfile

# for use with troff2lj

if test $# -ne 1
then
	echo "Usage: width hpfile" >&2; exit 1
fi

awk '
BEGIN		{
			char = 0
			printf "char xxW [256-32] = {\n"
		}
$2 == "POINTS"	{ ps = $1 }
$1 == "32"	{ char = 1 }
$1 == "127"	{ char = 0 }
NF > 0 		{
			if (char == 1) {
				width = int ($9 * 8.64 / ps + 0.5)
				printf "%d,	/* %c */\n", width, $1
			}
		}
END		{ printf "}	/* from file %s, ps=%f */\n", FILENAME, ps }
' $1
