cosell@bbn.com (Bernie Cosell) (01/22/90)
I asked a couple of days ago about some simple way to get an EPS version of a plain ASCII file. After fooling, unsuccessfully, with enscript for a while, I decided to just leap in and fix it up brute force. Attached is a little shell script that'll get you a PostScript rendering [that \psfig likes, which is what I was after in the first place!]. __ / ) Bernie Cosell /--< _ __ __ o _ BBN Sys & Tech, Cambridge, MA 02238 /___/_(<_/ (_/) )_(_(<_ cosell@bbn.com #!/bin/sh # $Header: encapsulate,v 1.1 90/01/21 17:33:42 cosell Exp $ # Encapsulate a simple ASCII file. It is assumed that you just want the # file to be PostScripted 'as is', without anything fancy like page breaks # or the like. pgm=`basename $0` Usage="$pgm ASCIIfile" case $# in 1) ;; *) echo >&2 "Usage: $Usage" exit 1 ;; esac file=$1 if [ ! -r $file ] then echo >&2 "$pgm: Can't find \"$file\"" exit 1 fi # First off, figure out how long the file is [gives us Y value for bounding # box] lines=`set \`wc -l $file\`; echo \$1` # Now find the longest line [for giving us the X value for BB] linelength=`awk "BEGIN { max = 0 } { if (length > max) { max = length } } END { print max }" $file` height=`expr $lines \* 12` width=`expr \( $linelength \* 72 + 9 \) / 10` cat <<PREAMBLE %! %%Title: $file %%CreationDate: `date` %%BoundingBox: 0, 0, $width, $height %%EndComments /Courier findfont 12 scalefont setfont /S { 3 1 roll moveto show } bind def PREAMBLE sed 's/\\/\\\\/g s/(/\\(/g s/)/\\)/g' < $file \ | awk "{ if (length > 0) { printf \"%d %d (%s) S\n\", 0, ($lines - NR) * 12, \$0; } }"