#! /bin/sh
# Filter to extract aspect ratio of Mathematica graphics and apply addBBoxproawk

# 2/1/1991 Dan Dill dan@chme.bu.edu
# Based on scheme developed by Cameron Smith cameron@midd.bitnet

# addBBoxpro height fontsize

# Developed with gawk.  Should also work with latest awk
awk=gawk

cmd=addBBoxpro

if [ $# -lt 2 ]
then
echo Usage: $cmd height fontsize
echo Adjust height and fontsize of Mathematica graphics.
echo See the $cmd shell script for details
exit 1
fi

height=$1
fontsize=$2
tmpname="texmmatmp"

# Abort cleanup
trap 'rm /tmp/$tmpname.$$.ps; exit' 2

# Save the graphic in a temp file
cat >/tmp/$tmpname.$$.ps

# Get aspect ratio
aspratio=`$awk '/AspectRatio/&&flag==0 {print $2; flag=1}' /tmp/$tmpname.$$.ps`

# Filter the file
cat /tmp/$tmpname.$$.ps | $awk -f addBBoxpro.awk $height $fontsize $aspratio

# Cleanup
rm /tmp/$tmpname.$$.ps
