summaryrefslogtreecommitdiff
path: root/fonts/cun/cun.mf
blob: 7f0191d7a4be8fdc46bf10f4e84d0dbd13f8cfa6 (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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
%(c) 1992 by Jo Grant

mode_def testing=
		pixels_per_inch:=300*4;
		blacker:=.1;
		o_correction:=1;
		fillin:=.01;
		proofing:=2;
		fontmaking:=0;
		tracingtitles:=1;
	enddef;
if unknown mode:
mode:=testing; fi
mode_setup;
turningcheck := 0;

string style;
style := "classic";
%style := "academic";
%style := "academicbf";

if mode=testing: screenstrokes; fi

% parameters that control what a wedge looks like.
width_to_length_ratio := 1/2;
tailang  := 30;
costail  := cosd tailang;
tantail  := sind tailang/cosd tailang;

u# = 1/384in#;
wedge_len# := 50u#;
letter_fit#:= 5u#;
wedge_wid# := wedge_len#*width_to_length_ratio;
tail_len# := wedge_wid#*costail;
stem_len# := wedge_len# - tail_len#;
tail_porp := tail_len#/wedge_len#;
stem_porp := stem_len#/wedge_len#;
let_height# := wedge_len#+wedge_wid#;
pen_thick# := wedge_len#/25;
half_big# := .5*let_height#*width_to_length_ratio;

define_pixels(wedge_len, wedge_wid, tail_len, stem_len, let_height, pen_thick);
define_pixels(letter_fit);

def wedgepen = pickup pencircle scaled pen_thick; enddef;

def wedgesetup =
	save V;
	numeric	V[]len, V[]width, V[]theta, V[]doit;
	pair	V[]pnt, V[]cw, V[]ccw;

	for n = 0 step 1 until 20:
		wlen(n) := wedge_len;
		wwid(n) := wedge_wid;
		rot(n)  := 0;
		V[n]doit := 0;
	endfor
enddef;

def set (expr n) =
	wccw(n) =  wpnt(n) - ((V[n]len,-V[n]wid/2) rotated (rot(n)));
	wcw(n)  =  wpnt(n) - ((V[n]len, V[n]wid/2) rotated (rot(n)));
	V[n]doit := 1;
enddef;

def drawwedges =
	for n = 0 step 1 until 20:
		if V[n]doit = 1:
			% classic
			if style = "classic":
				wedgepen;
				path	cw, ccw, tail;
				ccw = wpnt(n)..controls mid(n) and mid(n)..wccw(n);
				tail = wccw(n)..controls .7[mid(n),wccw(n)] and .7[mid(n),wcw(n)]..wcw(n);
				cw = wcw(n)..controls mid(n) and mid(n)..wpnt(n);
				filldraw ccw & tail & cw & cycle;
				drawdot wccw(n);
				drawdot wcw(n);
			fi;
			% academic
			if style = "academic":
				wedgepen;
				draw wpnt(n)--mid(n)--wccw(n)--wcw(n)--mid(n);
				unfill edgein(mid(n), tback(n), pen_thick)--
					edgein(wccw(n), cwmid(n), pen_thick)--
					edgein(wcw(n), ccwmid(n), pen_thick)--cycle;
				unfill edgein(mid(n), tback(n), pen_thick)--
					edgein(wccw(n), cwmid(n), pen_thick)--
					edgein(wcw(n), ccwmid(n), pen_thick)--cycle;
			fi;
%			% bf academic
			if style = "academicbf":
				wedgepen;
				draw wpnt(n)--mid(n);
				filldraw mid(n)--wccw(n)--wcw(n)--cycle;
			fi;
		fi;
	endfor;
enddef;

def edgein(expr from, to, amnt) =
	((from) + ((to) - (from))/length((to) - (from))*(amnt))
enddef;

def wedgeset(expr first, last) =
	for n = first step 1 until last:
		set(n);
	endfor;
	drawwedges;
enddef;

def wlen(expr n) =
	V[n]len
enddef;

def wwid(expr n) =
	V[n]wid
enddef;

def wlenwid(expr n, l) =
	V[n]len := l; V[n]wid := l*width_to_length_ratio
enddef;

def rot(expr n) =
	V[n]theta
enddef;

def wpnt(expr n) = 
	V[n]pnt
enddef;

def wccw(expr n) = 
	V[n]ccw
enddef;

def wcw(expr n) = 
	V[n]cw
enddef;

def tback(expr n) = 
	(.5[wcw(n), wccw(n)])
enddef;

def cwmid(expr n) = 
	(.5[wcw(n), mid(n)])
enddef;

def ccwmid(expr n) = 
	(.5[wccw(n), mid(n)])
enddef;

def wmid(expr n) = 	% identical to mid
	((wpnt(n) + wcw(n) + wccw(n))/3)
enddef;

def mid(expr n) = 
	((wpnt(n) + wcw(n) + wccw(n))/3)
enddef;

def cen(expr n) = 
	(.5[tback(n), wpnt(n)])
enddef;

def mstem(expr n) = 
	(.5[mid(n), wpnt(n)])
enddef;

def tmid(expr n) = 
	((mid(n) + wcw(n) + wccw(n))/3)
enddef;

def adjust_fit(expr left_adj, right_adj) =
	l := -hround(left_adj*hppp)-letter_fit;
	interim xoffset := -l;
	charwd := charwd+2letter_fit# + left_adj + right_adj;
	r := l+hround(charwd*hppp);
	w := r-hround(right_adj*hppp) - letter_fit;
	enddef;

def makebox(text r) =
	r((-letter_fit,0), (w+letter_fit,0));
	r((-letter_fit,h), (w+letter_fit,h));
	r((-letter_fit,0), (-letter_fit,h));
	r((w+letter_fit,0), (w+letter_fit,h));
	r((0,0), (0,h));
	r((w,0), (w,h));
	if charic<>0:
		r((w+charic*hppp,h.o_),(w+charic*hppp,.5h.o_)); 
	fi
	enddef;

extra_beginchar := extra_beginchar & "wedgesetup;adjust_fit(0,0);";

input cunsum;
%input cun0076;

font_normal_space wedge_wid#;
font_normal_stretch wedge_wid#/3;
font_normal_shrink wedge_wid#/3;

end;