view etc/gnusrefcard/makelogo @ 161:28f395d8dc7a r20-3b7

Import from CVS: tag r20-3b7
author cvs
date Mon, 13 Aug 2007 09:42:26 +0200
parents
children
line wrap: on
line source

#!/bin/csh -f
# Copies gnuslogo.ps to gnuslogo.tmp and fixes the image 
# by the scale specified in $1.tex

echo Scaling-down gnuslogo.ps to gnuslogo.$1
set bb = `grep "^%%BoundingBox:" gnuslogo.ps`
if ($bb[2] != 0 || $bb[3] != 0) then
  echo Please make gnuslogo.ps have zero-based coordinates
  exit 1
endif
set logowidth  = $bb[4]
set logoheight = $bb[5]
set logoscale = \
 `grep "\\def\\logoscale{" $1.tex |sed -e "s/\\def\\logoscale{\([^}]*\)}/\1/"`
# check if a program is present
alias executable '(\!* </dev/null >&/dev/null)'
executable calc 0
if ($status != 1) then  # calc is demented and returns 2 on success
  # -p is "precision"
  set newwidth  = `calc -p1 $logowidth  \* $logoscale`
  set newheight = `calc -p1 $logoheight \* $logoscale`
else if ( { executable dc } ) then
  # the k command of dc doesn't seem to have much of an effect
  set newwidth  = `echo 0 k $logowidth  $logoscale \* p | dc`
  set newheight = `echo 0 k $logoheight $logoscale \* p | dc`
else if ( { executable bc } ) then
  # nor does the scale variable of bc. This will lead to fractional numbers
  # in the %%BoundingBox statement of the EPS file.
  # Let's hope your dvips doesn't have a problem with it.
  set newwidth  = `echo "scale=0; $logowidth  * $logoscale" | bc`
  set newheight = `echo "scale=0; $logoheight * $logoscale" | bc`
endif
sed -e"/%%BoundingBox/{s/$logowidth/$newwidth/;s/$logoheight/$newheight/;}"\
    -e"/scale/{s/$logowidth.0/$newwidth/;s/$logoheight.0/$newheight/;}"\
    gnuslogo.ps >! gnuslogo.$1