#! /bin/sh
#
#                             COPYRIGHT
# 
#   PCB, interactive printed circuit board design
#   Copyright (C) 1994 Thomas Nau
# 
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
# 
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
# 
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# 
#   Contact addresses for paper mail and Email:
#   Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
#   Thomas.Nau@medizin.uni-ulm.de
# 
#   RCS: $Header: scalefont,v 1.1 94/04/26 20:07:24 nau Exp $
#
#
# scale font information of PCB
# Usage: scalefont scale fontfile
#

if [ $# -ne 2 ]
then
	echo "Usage: $0 scale fontfile" >&2
	exit 1
fi

scale=$1
file=$2

awk -v "scale=$scale" '
# scale spacing between characters
	/Symbol[(]/		{
		delta = substr($NF, 1, length($NF)-1)
		delta = delta*scale+0.5
		for (i = 1; i < NF; i++)
			printf("%s ", $i)
		printf("%d)\n", delta)
		next
	}

# scale lines of symbols	
	/SymbolLine/	{
		start = match($0, "[0-9 ]+")
		values = substr($0, start, RLENGTH);
		number = split(values, a)
		for (i = 1; i <= 5; i++)
			a[i] = scale*a[i]+0.5;
		printf("\tSymbolLine(%d %d %d %d %d)\n", a[1], a[2], a[3], a[4], a[5]);
		next
	}

# copy all other lines
	{ print $0 }
' $file

