summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/fonts/frcursive/mkdrv.sh
blob: 0102a56d0c06576974789a1d17cc6ccd180a8270 (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/sh
#
# Automatic generation of driver files for French Cursive.
#
# © Emmanuel Beffara, 2001--2004. This script is covered by the GPL licence,
# and is part of the French Cursive font sources.

calc()
{
	( echo "scale=3"; echo $* ) | bc -l
}

make_driver()
{
	DESCR=""    # textual description
	IDENT=""    # font identifier
	SIZE=$1     # specific size in points

	EX=0        # value of ex# in sharp points
	THIN=0.2    # thickness of thin drawings
	MED=0.4     # thickness of medium drawings
	THICK=0.6   # thickness of thick drawings
	DOT=0.8     # diameter of dots

	WIDTH=0.8   # base width
	SLANT=0     # slant factor

	ACCW=0.7    # relative width of accents

	FIXED=false # fixed-thickness version ?

	shift
	while [ "$#" != 0 ]; do
		case $1 in
		bold)	IDENT="${IDENT}B"; MED=0.55; THICK=0.8; DOT=1.25;
			DESCR="${DESCR}bold ";;
		callig)	IDENT="${IDENT}C"; MED=0.3; THICK=0.8;
			DESCR="${DESCR}calligraphic ";;
		ext)	IDENT="${IDENT}X"; WIDTH=0.9;
			DESCR="${DESCR}extended ";;
		slant)	IDENT="${IDENT}SL"; SLANT=0.3;
			DESCR="${DESCR}slanted ";;
		fixed)	IDENT="${IDENT}F"; FIXED=true;
			THIN=$MED; THICK=$MED; DOT=`calc "2*$MED"`;
			DESCR="${DESCR}fixed-thickness ";;
		esac
		shift
	done

	# The value of ex# is computed the same way as for Computer Modern:
	EX=`calc "$SIZE*15.5"`/36

	# The base width is multiplied by a scale factor related to height
	WIDTH=`calc "$WIDTH/e(l($SIZE/10)/6)"`

	# Correct the thickness values according to the size:
	THIN=`calc "$THIN*$SIZE/10"`
	MED=`calc "$MED*$SIZE/10"`
	THICK=`calc "$THICK*$SIZE/10"`
	DOT=`calc "$DOT*$SIZE/10"`

	# The identifier is "FRC" followed by the letters above (or "R")
	IDENT="FRC${IDENT:-R}"

	# And here we go...

	cat <<EOF
%%% This file is part of the French Cursive font definition.
%%% This is a parameter file for the ${DESCR:-regular }variant

font_identifier := "$IDENT";
font_size $SIZE pt#;

mode_setup;

ex# := $EX pt#;
med# := $MED pt#;
thin# := $THIN pt#;
thick# := $THICK pt#;
dot_size# := $DOT pt#;

base_width := $WIDTH;
slant := $SLANT;
accent_wd := $ACCW;
link_width := 0.13;
straight_ascend := 2;
loop_ascend := 2.5;
uc_ascend := 2.5;
straight_descend := 1.2;
loop_descend := 1.5;
dot_height := 1.4;
accent_bot := 1.2;
accent_top := 1.6;
cedilla_dp = 0.2;

EOF

	# When using a fixed-thickness version, we have to add special code to use
	# the "draw" macro instead of "penstroke":

	$FIXED && cat <<EOF
def penstroke text t =
  begingroup
    save e; def e = enddef;
    draw t withpen pencircle scaled med;
  endgroup
enddef;

EOF

	# And the final line:
	echo "input frcursive"
}


make_series()
{
	local NAME=$1
	shift

	local OPTS=""
	while [ -n "$1" -a "$1" != "at" ]; do
		OPTS="$OPTS $1"
		shift
	done

	if [ -n "$1" ]; then
		shift
		SIZES="$*"
	else
		echo "syntax: ./mkdrv.sh <base name> <modifiers> at <sizes>"
		exit 1
	fi

	local SIZE
	for SIZE in $SIZES; do
		local RS=$(echo "x=$SIZE;y=x-x%1;if(x%1>.5)y+1else y" | bc)
		local FN="$NAME${RS%%.*}.mf"
		echo "making $FN"
		make_driver $SIZE $OPTS > $FN
	done
}

if [ "$#" = 0 ]; then
	cat <<EOF
The syntax is one of:
    $(basename $0) <base name> <modifiers> at <sizes>
    $(basename $0) default

The second form produces a set of standard variants and sizes.

The modifiers are words among:
    bold   = thicker stems and hairlines
    callig = more contrasted stems and hairlines
    fixed  = fixed thickness
    ext    = slightly extended width
    slant  = well, slanted...

The sizes are expressed in points, they can be non-integer. The file names
produced are of the form <base name><integer part of size>.mf.
EOF
elif [ "$1" = default ]; then
	make_series frcr                   at 7 8 9 10 10.95 12 14.4 17.28
	make_series frcsl   slant          at 7 8 9 10 10.95 12 14.4 17.28
	make_series frcbx   bold ext       at 7 8 9 10 10.95 12 14.4 17.28
	make_series frcslbx slant bold ext at 7 8 9 10 10.95 12 14.4 17.28
	make_series frcc    callig         at 10 10.95 12 14.4
	make_series frcf    fixed          at 10 10.95 12 14.4
else
	make_series $@
fi