summaryrefslogtreecommitdiff
path: root/fonts/mbboard/source/mbbpunct.mf
blob: 66a939f8fe9789627f984c57230aff851ec9bf71 (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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
% blackboard typefaces by Anthony Phan.
% file: mbbpunct.mf (punctuation)
% last modification: 25.10.2001.

def horizontal_rules_list=
  -body_depth,-desc_depth,x_height,cap_height,asc_height,body_height
enddef;

use_rule1;

iff known bbnormal_space:
beginchar(bbnormal_space,6u#+2letter_fit#,0,0);
  "Normal space";
endchar;

iff known bbcompound_word_mark:
beginchar(bbcompound_word_mark,0,x_height#,0);
  "Compound word mark";
endchar;

beginchar(bbexclamation_point,hthick#+thin#+2appr#,
    asc_height#,0);
  "Exclamation point";
  italcorr (asc_height#
    if not square_dots: -0.4dot_size# fi)*slant-0.5u#;
  center_bar(1,1'); bot y1=0; top y1'=dot_size; dot(1,1');
  if square_dots: bot y2=vround 0.25[top y1',x_height];
    y5=y2; x2=x3=x1; x4=x5=x1'; top y3=top y4=h;
    pickup square.nib; draw z2--z3--z4--z5--cycle;
    labels(2,3,4,5);
  else: top y7=h+o; bot y2=vround 0.25[top y1',x_height];
    y4-y2=0.25dot_size; y7-y6=0.5dot_size;
    x2=x3=x4=x5=x6=x7=0.5[x1,x1'];
    numeric a,r,R;
    R=0.5max(dot_size-thin,0);
    r=0.5max(0.5dot_size-thin,0);
    a=(R-r)/(y6-y4);
    y6-y5=R*a; y4-y3=r*a;
    penpos6(hthick,0); penpos5(hthick*(1+-+a),0);
    penpos3(0.5hthick*(1+-+a),0);
    draw z2...z3r---z5r...z6r up_to_left z7
    left_to_down z6l...z5l---z3l...cycle;
    labels(2,4,6); penlabels(3,5,6); fi
endchar;

beginchar(bbspanish_shriek,hthick#+thin#+2appr#,
    asc_height#-desc_depth#,desc_depth#);
  "Spanish open exclamation point";
  italcorr (asc_height#-desc_depth#
    if not square_dots: -0.4dot_size# fi)*slant-0.5u#;
  center_bar(1,1'); top y1=h; top y1-bot y1'=dot_size;
  dot(1,1');
  if square_dots: top y2=vround 0.25[bot y1',h-x_height];
    y5=y2; x2=x3=x1; x4=x5=x1'; bot y3=bot y4=-d;
    pickup square.nib; draw z2--z3--z4--z5--cycle;
    labels(2,3,4,5);
  else: bot y7=-d-o; top y2=vround 0.25[bot y1',h-x_height];
    y4-y2=-0.25dot_size; y7-y6=-0.5dot_size;
    x2=x3=x4=x5=x6=x7=0.5[x1,x1'];
    numeric a,r,R;
    R=0.5max(dot_size-thin,0);
    r=0.5max(0.5dot_size-thin,0);
    a=(R-r)/(y6-y4);
    y6-y5=R*a; y4-y3=r*a;
    penpos6(hthick,0); penpos5(hthick*(1+-+a),0);
    penpos3(0.5hthick*(1+-+a),0);
    draw z2...z3r---z5r...z6r up_to_left z7
    left_to_down z6l...z5l---z3l...cycle;
    labels(2,4,6); penlabels(3,5,6); fi
endchar;

beginchar(bbquestion_mark,8u#+2appr#,asc_height#,0);
  "Question mark";
  italcorr 0.9asc_height#*slant-0.5u#;
  center_bar(1,2); bot y1=0; top y2=dot_size;
  x5=x2; bot y3=vround 0.25[top y2,x_height];
  x9=0.5[x1,x2]; top y9=h+o; rt x7=w-apprr+ho;
  lft x11=apprl; slope:=2(y9-y3)/24u;
  y5-y3=slope*(x5-x1); ellipse_set(9,7,6,5);
  if square_dots: y4=y3; x12=x3=x1; x4=x2;
    y5+y0-y12=slope*(x5+x0-x12);
  else: x3=0.5[x1,x2]; x3a=0.25[x1,x2];
    x4=0.75[x1,x2]; y4=y3a=0.5[y3,y5]; z12=z5+z0; fi
  z0=(thick*unitvector((z6-z5)slanted slant)
    rotated 90)slanted -slant;
  x14=x7+x0; ellipse_set(9,14,13,12); bot y11=vround y7;
  if square_dots:
    y3l-y3=y3-y3r=y4l-y4=y4-y4r=0.5thin;
    x3l-x3=x3-x3r=x4r-x4=x4-x4l=0.5thin*(1++slant);
    x12l=x3l; x12r=x3r; x5r=x4r; x5l=x4l;
    ortho_penpos6(thin,z6-z5); ortho_penpos13(thin,z12-z13);
    z12l-z13l=whatever*(z12-z13); z12r-z13r=whatever*(z12-z13);
    z5l-z6l=whatever*(z5-z6); z5r-z6r=whatever*(z5-z6);
    penstroke z13e--z12e--z3e--z4e--z5e--z6e;
    draw z9 right_to_down z14...{z12-z13}z13;
    draw z6{z6-z5}...z7 up_to_left z9 left_to_down z11;
  else: draw z9 right_to_down z14...z13---z12...z3a
    ...z3{right}...z4...z5---z6...z7 up_to_left z9
    left_to_down z11;
  fi
  dot(1,2); square_end11(down);
  labels(3a,7,8,9,10,11,14,15); penlabels(3,4,5,6,12,13);
endchar;

beginchar(bbspanish_query,8u#+2appr#,
    asc_height#-desc_depth#,desc_depth#);
  "Spanish open question mark";
% no italic correction
  center_bar(2,1); top y1=h; bot y2=h-dot_size;
  x5=x2; top y3=vround 0.25[bot y2,h-x_height];
  x9=0.5[x1,x2]; bot y9=-d-o; lft x7=apprl-ho; rt x11=w-apprr;
  slope:=-2(y9-y3)/24u;
  y5-y3=slope*(x5-x1); ellipse_set(9,7,6,5);
  if square_dots: y4=y3; x12=x3=x1; x4=x2;
    y5+y0-y12=slope*(x5+x0-x12);
  else: x3=0.5[x1,x2]; x3a=0.25[x1,x2]; x4=0.75[x1,x2];
    y4=y3a=0.5[y3,y5]; z12=z5+z0; fi
  z0=(thick*unitvector((z6-z5)slanted slant)
    rotated 90)slanted -slant;
  x14=x7+x0; ellipse_set(9,14,13,12); top y11=vround y7;
  if square_dots:
    y3l-y3=y3-y3r=y4l-y4=y4-y4r=-0.5thin;
    x3l-x3=x3-x3r=x4r-x4=x4-x4l=-0.5thin*(1++slant);
    x12l=x3l; x12r=x3r; x5r=x4r; x5l=x4l;
    ortho_penpos6(thin,z6-z5); ortho_penpos13(thin,z12-z13);
    z12l-z13l=whatever*(z12-z13); z12r-z13r=whatever*(z12-z13);
    z5l-z6l=whatever*(z5-z6); z5r-z6r=whatever*(z5-z6);
    penstroke z13e--z12e--z3e--z4e--z5e--z6e;
    draw z9 left_to_up z14{up}...{z12-z13}z13;
    draw z6{z6-z5}...z7 down_to_right z9 right_to_up z11;
  else: draw z9 left_to_up z14{up}...z13---z12...z3a
    ...z3{left}...z4...z5---z6...z7 down_to_right z9
    right_to_up z11;
  fi
  dot(1,2); square_end11(up);
  labels(3a,7,8,9,10,11,14,15); penlabels(3,4,5,6,12,13);
endchar;

beginchar(bbasterisk,7u#+2appr#,body_height#,0);
  "Asterisk";
  italcorr body_height#*slant-.5u#;
  numeric a,b; a=round(x_height/(1+cosd 36)); b=vround 0.85thin;
  x0=floor(w/2)+0.5; y0=h-a; x1r=x0; y1r=h+0.5;
  y3r=y9r=vround(y0+a*cosd 72); x3r-x0=x0-x9r=round(a*sind 72);
  y5r=y7r=vround(y0+a*cosd 144)-0.5; x5r-x0=x0-x7r=hround(a*sind 144);
  for i=0 upto 4: z[1+2i]l=z[1+2i]r
    +unitvector((z[1+(2i+4)mod 10]r-z[1+2i]r)slanted slant)
    rotated -90 scaled b slanted -slant
    +whatever*(z[1+(2i+4)mod 10]r-z[1+2i]r);
    z[1+2i]l=z[1+2i]r
    +unitvector((z[1+(2i-4)mod 10]r-z[1+2i]r)slanted slant)
    rotated 90 scaled b slanted -slant
    +whatever*(z[1+(2i-4)mod 10]r-z[1+2i]r);
  endfor
  for i=0 upto 4: 
    z[2i+2]r=whatever[z[2i+1]r,z[(2i+5)mod 10]r];
    z[2i+2]r=whatever[z[(2i-1)mod 10]r,z[(2i+3)mod 10]r];
    z[2+2i]l=whatever[z[1+2i]l,z[1+(2i+4)mod 10]l];
    z[2+2i]l=whatever[z[1+(2i-2)mod 10]l,z[1+(2i+2)mod 10]l];
  endfor
  penstroke for i=0 upto 4: z[1+2i]e--z[2+2i]e-- endfor cycle;
  penlabels(0,1,2,3,4,5,6,7,8,9,10);  
endchar;

beginchar(bbperiod,hthick#+thin#+2appr#,dot_size#,0);
  "Period";
  italcorr (dot_size# if not square_dots: -0.4dot_size# fi)*slant-0.5u#;
  center_bar(1,1'); bot y1=0; top y1'=dot_size; dot(1,1');
endchar;

beginchar(bbcomma,hthick#+thin#+2appr#,
    dot_size#,comma_size#-dot_size#);
  "Comma";
  italcorr (dot_size# if not square_dots: -0.4dot_size# fi)*slant-0.5u#;
  center_bar(5,3); top y4=dot_size; lft x1=apprl-hround u;
  top y4-bot y1=comma_size; complete_comma;
endchar;

beginchar(bbsemicolon,hthick#+thin#+2appr#,
    x_height#,comma_size#-dot_size#);
  "Semicolon";
  italcorr (x_height# if not square_dots: -0.4dot_size# fi)*slant-0.5u#;
  center_bar(5,3); top y4=dot_size; lft x1=apprl-hround u;
  top y4-bot y1=comma_size; complete_comma;
  pickup circle.nib; x7=x5; x7'=x3; top y7'=h;
  bot y7=h-dot_size; dot(7,7');
endchar;

beginchar(bbcolon,hthick#+thin#+2appr#,x_height#,0);
  "Colon";
  italcorr (x_height# if not square_dots: -0.4dot_size# fi)*slant-0.5u#;
  center_bar(1,1'); x2=x1; x2'=x1'; bot y1=0; top y2'=h;
  top y1'-bot y1=top y2'-bot y2=dot_size; dot(1,1'); dot(2,2');
endchar;

iff known bbhyphenchar:
beginchar(bbhyphenchar,4u#+2appr#,x_height#,0);
  "hyphenchar";
  italcorr .5x_height#*slant-.5u#;
  penpos1(rule_thickness,90); penpos2(rule_thickness,90);
  top y1r=top y2r=vround(.5h+.5rule_thickness);
  rt x2=w-apprr; lft x1=apprl-hround .8u;
  penstroke z1e--z2e; penlabels(1,2);
endchar;

iff known bbdash:
beginchar(bbdash,4u#+2appr#,x_height#,0);
  "dash";
  italcorr .5x_height#*slant-.1u#;
  penpos1(rule_thickness,90); penpos2(rule_thickness,90);
  top y1r=top y2r=vround(.5h+.5rule_thickness);
  rt x2=w-apprr+hround 0.4u; lft x1=apprl-hround .4u;
  penstroke z1e--z2e; penlabels(1,2);
endchar;

beginchar(bben_dash,9u#+2letter_fit#,x_height#,0);
  "En dash";
  italcorr 0.61803x_height#*slant+0.5u#;
  penpos1(thin,90); penpos2(thin,90);
  y1r=y2r=good.y(y1r+0.61803h-y1);
  x1=w-x2=hround 0.5(w-9u);
  penstroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(bbem_dash,18u#+4letter_fit#,x_height#,0);
  "Em dash";
  italcorr 0.61803x_height#*slant+0.5u#;
  penpos1(thin,90); penpos2(thin,90);
  y1r=y2r=good.y(y1r+0.61803h-y1);
  x1=w-x2=hround 0.5(w-18u);
  penstroke z1e..z2e; penlabels(1,2);
endchar;

iff known bbunderscore:
beginchar(bbunderscore,18u#+4letter_fit#,0,paren_depth#);
  "Underscore";
  % no italic correction
  penpos1(thin,90); penpos2(thin,90);
  y1l=y2l=-d; x1=w-x2=hround 0.5(w-18u);
  penstroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(bbapostrophe,hthick#+thin#+2appr#,asc_height#,0);
  "Apostrophe";
  italcorr (asc_height# if not square_dots: -0.4dot_size# fi)*slant-0.5u#;
  center_bar(5,3); top y4=h; lft x1=apprl-hround u;
  top y4-bot y1=comma_size; complete_comma;
endchar;

beginchar(bbreverse_apostrophe,hthick#+thin#+2appr#,asc_height#,0);
  "Reverse apostrophe";
  italcorr asc_height#*slant+0.5u#;
  center_bar(3,5); top y1=h; rt x1=w-apprr+hround u;
  top y1-bot y4=comma_size; complete_comma;
endchar;

beginchar(bbopening_quotes,7u#+2appr#,asc_height#,0);
  "Opening quotes";
  italcorr asc_height#*slant+0.5u#;
  pickup circle.nib;
  rt x5=w-apprr; x5-x3=hthick; top y1=h; rt x1=hround(w-apprr+u);
  top y1-bot y4=comma_size; complete_comma;
  addto currentpicture
  also currentpicture shifted (apprl-lft x3,0);
endchar;

beginchar(bbclosing_quotes,7u#+2appr#,asc_height#,0);
  "Closing quotes";
  italcorr (asc_height# if not square_dots: -0.4dot_size# fi)*slant-0.5u#;
  pickup circle.nib;
  lft x5=apprl; x3-x5=hthick; top y4=h; lft x1=hround(apprl-u);
  top y4-bot y1=comma_size; complete_comma;
  addto currentpicture
  also currentpicture shifted (w-apprr-rt x3,0);
endchar;

iff known bbgerman_opening_comma:
beginchar(bbgerman_opening_comma,
    hthick#+thin#+2appr#,dot_size#,comma_size#-dot_size#);
  italcorr (dot_size# if not square_dots: -0.4dot_size# fi)*slant-0.5u#;
  "German opening comma";
  center_bar(5,3); top y4=dot_size; lft x1=apprl-hround u;
  top y4-bot y1=comma_size; complete_comma;
endchar;

iff known bbgerman_opening_quotes:
beginchar(bbgerman_opening_quotes,7u#+2appr#,dot_size#,
    comma_size#-dot_size#);
  "German opening quotes";
  italcorr (dot_size# if not square_dots: -0.4dot_size# fi)*slant-0.5u#;
  pickup circle.nib;
  lft x5=apprl; x3-x5=hthick; top y4=h;
  lft x1=hround(apprl-u); top y4-bot y1=comma_size; 
  complete_comma;
  addto currentpicture
  also currentpicture shifted (w-apprr-rt x3,0);
endchar;

iff known bbstraight_quotes:
beginchar(bbstraight_quotes,7u#+2appr#,asc_height#,0);
  "Straight quotes";
  italcorr (asc_height# if not square_dots: -0.4dot_size# fi)*slant-0.5u#;
  pickup circle.nib;
  if square_dots:
    lft x1-apprl=w-apprr-rt x6=0; x1=x4; x6=x7;
    x2-x1=x3-x4=x6-x5=x7-x8=hthick;
    top y3=h; y3=y4=y7=y8; top y1=x_height; y1=y2=y5=y6;
    pickup square.nib; draw z1--z2--z3--z4--cycle;
    draw z5--z6--z7--z8--cycle; labels(1,2,3,4,5,6,7,8);
  else:
    y1=y3=x_height-thin+0.25dot_size; y2=y4=h-0.5dot_size;
    x1=x2=apprl+0.5(thin+hthick); x3=x4=w-apprr-0.5(thin+hthick);
    long_dot(1,2); long_dot(3,4);
  fi
endchar;

if (known bbfso_quotes)or(known bbfsc_quotes)
  or(known bbfdo_quotes)or(known bbfdc_quotes):
  def complete_quote(expr $,$$,$$$)=
    h-y[$]r=y[$+2]r=hround 0.06h; y[$+1]l=0.5[y[$]r,y[$+2]r];
    x[$]r=x[$+2]r=x[$+1]l if $$$>0: + else:- fi(hround 4u+2eps)=$$;
    adjust_slanted_bar([$+1]l,[$]r,[$+1]a,[$]l)
    (thin,if $$$>0: -1 else: 1 fi);
    adjust_slanted_bar([$+1]l,[$+2]r,[$+1]b,[$+2]l)
    (thin,if $$$>0:1 else: -1 fi);
    z[$+1]r-z[$]r=whatever*(z[$+1]l-z[$]l);
    z[$+1]r-z[$+2]r=whatever*(z[$+1]l-z[$+2]l);
    penstroke z[$]e--z[$+1]e--z[$+2]e;
    penlabels([$],[$+1],[$+2]); labels([$+1]a,[$+1]b);
  enddef;
fi

iff known bbfso_quotes:
beginchar(bbfso_quotes,6u#+2appr#,x_height#,0);
  "French single opening quote";
  italcorr x_height#*slant-0.5u#;
  complete_quote(1,w-apprr-hround u+eps,1);
endchar;

iff known bbfsc_quotes:
beginchar(bbfsc_quotes,6u#+2appr#,x_height#,0);
  "French single closing quote";
% no italic correction
  complete_quote(1,apprl+hround u-eps,-1);
endchar;

iff known bbfdo_quotes:
beginchar(bbfdo_quotes,8u#+2appr#,x_height#,0);
  "French double opening quote";
  italcorr x_height#*slant-0.5u#;
  complete_quote(1,w-apprr+eps,1);
  complete_quote(4,w-apprr-hround 3u+eps,1);
endchar;

iff known bbfdc_quotes:
beginchar(bbfdc_quotes,8u#+2appr#,x_height#,0);
  "French double closing quote";
% no italic correction
  complete_quote(1,apprl-eps,-1);
  complete_quote(4,apprl+hround 3u-eps,-1);
endchar;

%
% delimiters (see bbbigdel.mf if it still exists)
%

iff known parenthesis_left:
beginchar(parenthesis_left,5.5u#+2appr#,body_height#,paren_depth#);
  "Left parenthesis";
  pickup circle.nib;
  top y1=h; bot y3=-d; y2=0.5[y1,y3];
  rt x1=rt x3=w-apprr; x4-x2=hthick;
  lft x2=min(apprl+hround u-ho,
    hround 0.5(w+apprl-apprr-thin-hthick)-eps);
  tmp_path:=z1{3(x2-x1),y2-y1}...z2{down}...z3{3(x3-x2),y3-y2};
  z4=tmp_path intersectionpoint ((x4,y1)..(x4,y2));
  z5=tmp_path intersectionpoint ((x4,y3)..(x4,y2));
  draw tmp_path; draw z4..z5;
  square_end1((3(x1-x2),y1-y2));
  square_end3((3(x3-x2),y3-y2)); 
  labels(1,2,3,4,5);
endchar;

iff known parenthesis_right:
beginchar(parenthesis_right,5.5u#+2appr#,body_height#,paren_depth#);
  "Right parenthesis";
  pickup circle.nib;
  top y1=h; bot y3=-d; y2=0.5[y1,y3];
  lft x1=lft x3=apprl; x4-x2=-hthick;
  rt x2=max(w-apprr-hround u+ho,
    hround 0.5(w+apprl-apprr+thin+hthick)+eps);
  tmp_path:=z1{3(x2-x1),y2-y1}...z2{down}...z3{3(x3-x2),y3-y2};
  z4=tmp_path intersectionpoint ((x4,y1)..(x4,y2));
  z5=tmp_path intersectionpoint ((x4,y3)..(x4,y2));
  draw tmp_path; draw z4..z5;
  square_end1((3(x1-x2),y1-y2));
  square_end3((3(x3-x2),y3-y2)); 
  labels(1,2,3,4,5);
endchar;

def tmp_program(expr orientation,top_f,bot_f)=
  save a;
  a=hround(thin*(1++slant));
  y6r=h; y8r=-d-1; y5r=top_f[y6r,y8r]; y7r=bot_f[y8r,y6r];
  if orientation=left:
    forsuffixes @#=1,2,3,4: x@#r-x@#=x@#-x@#l=-0.5a; endfor
    x1r=x2r=x5r=x7r=min(apprl+hround u,
      hround 0.5(w+apprl-apprr-a-hthick));
    x1-x3=x2-x4=-hthick; x6r=x8r=w-apprr+hround 0.5u;
  else:
    forsuffixes @#=1,2,3,4: x@#r-x@#=x@#-x@#l=0.5a; endfor
    x1r=x2r=x5r=x7r=max(w-apprr-hround u,
      hround 0.5(w+apprl-apprr+a+hthick));
    x1-x3=x2-x4=hthick; x6r=x8r=apprl-hround 0.5u;
  fi
  forsuffixes @=1,1r,1l,3,3r,3l: z@=whatever[z5r,z6r]; endfor
  forsuffixes @=2,2r,2l,4,4r,4l: z@=whatever[z7r,z8r]; endfor
  penpos5(thin/abs cosd angle((z6r-z5r)slanted slant),90);
  penpos6(thin/abs cosd angle((z6r-z5r)slanted slant),90);
  penpos7(thin/abs cosd angle((z8r-z7r)slanted slant),-90);
  penpos8(thin/abs cosd angle((z8r-z7r)slanted slant),-90);
  penstroke z1e..z2e; penstroke z3e..z4e;
  penstroke z5e..z6e; penstroke z7e..z8e;
  penlabels(1,2,3,4,5,6,7,8);
enddef;

iff known bracket_left:
beginchar(bracket_left,5.5u#+2appr#,body_height#,paren_depth#);
  "Left bracket";
  tmp_program(left,0,0);
endchar;

iff known bracket_right:
beginchar(bracket_right,5.5u#+2appr#,body_height#,paren_depth#);
  "Right bracket";
  tmp_program(right,0,0);
endchar;

iff known angle_left:
beginchar(angle_left,5.5u#+2appr#,body_height#,paren_depth#);
  "Left angle bracket";
  tmp_program(left,.15,.15);
endchar;

iff known angle_right:
beginchar(angle_right,5.5u#+2appr#,body_height#,paren_depth#);
  "Right angle angle";
  tmp_program(right,.15,.15);
endchar;

vardef tmp_program(expr orientation)=
  path tmppp_path,tmpppp_path;
  pickup circle.nib;
  if orientation=left:
    lft x1=apprl-hround 0.5u;
    rt x4r=w-apprr+hround 0.5u;
    x6r=good.x 0.5(x1+x4r-hthick); x3r-x6r=hthick;
  else:
    rt x1=w-apprr+hround 0.5u;
    lft x4r=apprl-hround 0.5u;
    x6r=good.x 0.5(x1+x4r+hthick); x3r-x6r=-hthick;
  fi 
  x2-x1=x4r-x5r=0.25(x6r-x1);
  x3r=x3l; x4l=x4r; x5r=x5l; x6r=x6l;
  y1=y2=good.y 0.5[-d,h];
  top y4r=top y5r=h; y1-y4l=y1-y5l=y4r-y1;
  y5r-y6r=y3r-y1=y6l-y5l=y1-y3l=min(0.4(y5r-y1),0.75dh);
  tmp_path:=z1..z2 right_to_up z3r;
  tmpp_path:=z4r..z5r left_to_down z6r;
  tmppp_path=z2 right_to_down z3l;
  tmpppp_path=z4l..z5l left_to_up z6l;
  draw tmp_path; draw tmpp_path;
  draw tmppp_path; draw tmpppp_path;
  hbbowl(z2,z3r,(x3r,y6r),abs(x3r-x6r)) tmp_path;
  hbbowl(z2,z3l,(x3l,y6l),abs(x3l-x6l)) tmppp_path;
  hbbowl(z5r,z6r,(x6r,y3r),abs(x3r-x6r)) tmpp_path;
  hbbowl(z5l,z6l,(x6l,y3l),abs(x3l-x6l)) tmpppp_path;
  square_end1((x1-x4r,0));
  square_end4r((x4r-x1,0));
  square_end4l((x4l-x1,0));
  penlabels(1,2,3,4,5,6);
enddef;

iff known brace_left:
beginchar(brace_left,5.5u#+2appr#,body_height#,paren_depth#);
  "Left brace";
  tmp_program(left);
endchar;

iff known brace_right:
beginchar(brace_right,5.5u#+2appr#,body_height#,paren_depth#);
  "Right brace";
  tmp_program(right);
endchar;

% the widths of the two next characters are calculated
% to fit computer modern corresponding ones.

iff known vertical:
beginchar(vertical,3u#+2appr#,body_height#,paren_depth#);
  "Vertical";
  save a; a=hround(thin*(1++slant));
  penpos1(a,0); penpos2(a,0); penpos3(a,0); penpos4(a,0);
  penpos5(thin,90); penpos6(thin,90); penpos7(thin,90); penpos8(thin,90);
  x1l=x2l=x5r=x7l=hround 0.5(w+apprl-apprr-hthick-a);
  x3r=x4r=x6r=x8l=x1l+hthick+a;
  y1=y3=y5r=y6r=h+1; y2=y4=y7l=y8l=-d-1; 
  penstroke z1e..z2e; penstroke z3e..z4e;
  penstroke z5e..z6e; penstroke z7e..z8e;
  penlabels(1,2,3,4,5,6,7,8);
endchar;

numeric slash_width#;
slash_width#=(7u#-rule_thickness#)
*((body_height#+paren_depth#)/(body_height#+paren_depth#-rule_thickness#))
+diag_width(thick#,
  (7u#-rule_thickness#,body_height#+paren_depth#-rule_thickness#));

beginchar(bbslash,slash_width#+2appr#,
    body_height#,paren_depth#);
  "Slash";
  italcorr body_height#*slant-.5u#;
  x1r=w-apprr+0.5u; x4l=apprl-0.5u; y1r=h; y4l=-d;
  adjust_slanted_bar(1r,4l,2l,3r)(thick+thin,-1);
  a:=diag_width(thin,z1r-z3r);
  penpos1(a,0); penpos2(a,0); penpos3(a,0); penpos4(a,0);
  y1-y1a=thin; z1a=whatever[z1,z3]; z1-z1a=z2-z2a=z3a-z3=z4a-z4;
  penstroke z1e..z3e; penstroke z2e..z4e; fill z1--z2--z2a--z1a--cycle;
  fill z3--z4--z4a--z3a--cycle; penlabels(1,2,3,4); labels(1a,2a,3a,4a);
endchar;

numeric slash_width#;
slash_width#=(7u#-rule_thickness#)
*((body_height#+paren_depth#)/(body_height#+paren_depth#-rule_thickness#))
+diag_width(thick#,
  (-7u#+rule_thickness#,body_height#+paren_depth#-rule_thickness#));

beginchar(bbback_slash,slash_width#+2appr#,
    body_height#,paren_depth#);
  "Backlash";
  italcorr body_height#*slant-.5u#;
  x1l=apprl-0.5u; x4r=w-apprr+0.5u; y1l=h; y4r=-d;
  adjust_slanted_bar(1l,4r,2r,3l)(thick+thin,1);
  a:=diag_width(thin,z1l-z3l);
  penpos1(a,0); penpos2(a,0); penpos3(a,0); penpos4(a,0);
  y1-y1a=thin; z1a=whatever[z1,z3]; z1-z1a=z2-z2a=z3a-z3=z4a-z4;
  penstroke z1e..z3e; penstroke z2e..z4e; fill z1--z2--z2a--z1a--cycle;
  fill z3--z4--z4a--z3a--cycle; penlabels(1,2,3,4); labels(1a,2a,3a,4a);
endchar;