summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/geomsty/geomfix
blob: aff40c9bd901173ab3d544a6950a8355a08d5496 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#! /bin/sh
#
# This is geomfix, Copyright 1992 Silvio Levy
# $Header: /a/tampa/h/tampa_a/fac/levy/texts/geombook/RCS/geomfix,v 1.1 92/07/17 13:27:45 levy Exp $
#
# This shell file reads stdin (or any list of files) and adds a header
# similar to the one added by psfix, but without any of the definitons.
# It also abbreviates certain PostScript commands.

# Defaults:
lmargin=1.0		# default left margin: .5 inches
rmargin=1.0		# default right margin: .5 inches
bmargin=1.0		# default bottom margin: .5 inches
tmargin=1.0		# default top margin: .5 inches
width=8.5		# default page width: 8.5 inches
height=11		# default page height: 11 inches
transform=''		# default transformation: identity
nodistort=true		# default no-stretching: no
fixwid=false		# default fixwid compensation
fixdash=false		# default fixdash compensation
while :; do
	case $# in
	0)
		break 2
		;;
	esac
	case "$1" in
	-lmarg)
		shift
		lmargin=$1
		shift
		;;
	-rmarg)
		shift
		rmargin=$1
		shift
		;;
	-bmarg)
		shift
		bmargin=$1
		shift
		;;
	-tmarg)
		shift
		tmargin=$1
		shift
		;;
	-width)
		shift
		width=$1
		shift
		;;
	-height)
		shift
		height=$1
		shift
		;;
	-land)
		tmp=$width
		width=$height
		height=$tmp
		transform="90 rotate 0 Mheight neg translate"
		shift
		;;
	-stretch)
		nodistort=false
		shift
		;;
	-stringfix)
		fixwid=false
		shift
		;;
	-dashfix)
		fixdash=false
		shift
		;;
	-*)
		echo \
'Usage: psfix [-lmarg inches] [-rmarg inches] [-bmarg inches] [-tmarg inches]
                          [-land] [-stretch] [-width inches] [-height inches] 
                                  [-stringfix] [-dashfix] [file...]' \
			>&2
		exit 1
		;;
	*)
		break 2
		;;
	esac
done

# Output header
echo '%!PS-Adobe-2.0 EPSF-2.0'
# Compute bounding box
(
bc <<!
$width * 72
$height * 72
!
) | (
	read right
	read top
	echo "%%BoundingBox: 0 0 $right $top"
)
cat <<'!'
%%Creator: Mathematica
%%EndComments
!

# Output default values
sed 's/[ 	]*%.*$//
s/^[ 	]*//
/^[ 	]*$/d' <<!

MyDict begin
/Mlmarg		$lmargin 72 mul def	% left margin (points)
/Mrmarg		$rmargin 72 mul def	% right margin (points)
/Mbmarg		$bmargin 72 mul def	% top margin (points)
/Mtmarg		$tmargin 72 mul def	% bottom margin (points)
/Mwidth		$width 72 mul def	% total page width (points)
/Mheight	$height 72 mul def	% total page height
/Mtransform	{ $transform } bind def	% possible page rotation
/Mnodistort	$nodistort def		% no-stretching flag
/Mfixwid	$fixwid	def		% fixedwidth font only flag
/Mfixdash	$fixdash def		% fixeddash flag
/Mrot		0	def		% angle at which text is rendered
!

# Some of the following abbrevs were used by me 
# prior to version 2.1 to save space.
# In version 2.1 different abbrevs were introduced.  
# Only k causes a conflict.

sed '/^%!$/d
s/^0\.\([0-9]\)/.\1/
s/\([ -]\)0\.\([0-9]\)/\1.\2/g
s/\<k\>$/setcmykcolor/
s/\<Mabswid\>$/Ma/g
s/\<arc\>$/a/g
s/\<curveto\>$/c/g
s/\<setdash\>$/d/g
s/\<fill\>$/f/g
s/\<setgray\>$/g/g
s/\<grestore\>$/gr/g
s/\<gsave\>$/gs/g
s/\<stroke\>$/k/g
s/\<lineto\>$/l/g
s/\<setlinewidth\>$/lw/g
s/\<moveto\>$/m/g
s/\<newpath\>$/n/g
s/\<setrgbcolor\>$/r/g
/^%%Creator:/d' $@

echo end