summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/fonts/source/lh/base/lgrusu.mf
blob: c75aba1879691d8721de8d5c3262bae3e8436447 (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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
%
% lgrusu.mf
%
%% Cyrillic font container with T2 encoding beta-support
%
% This file is future part of lxfonts package
% Version 3.5 // Patchlevel=1
% (c) O.Lapko
%
% This package is freeware product under conditions similar to
% those of D. E. Knuth specified for the Computer Modern family of fonts.
% In particular, only the authors are entitled to modify this file
% (and all this package as well) and to save it under the same name.
%
% Content:
%
% Uppercase Russian letters from a to ya and yo
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

LHver_check(3,5); % like |version_check| in ec

lhchar "Uppercase Russian letter A";
cyrchar(A,13u#,cap_height#,0);
if is_small_cap: getcharcode(a); fi
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upper_a;
numeric left_stem,right_stem,outer_jut,alpha; outer_jut=.8cap_jut;
x1l=w-x4r=l+letter_fit+outer_jut+.5u;
right_stem=cap_stem-stem_corr;
left_stem=min(cap_hair if hefty: -3stem_corr fi,right_stem);
y1=y4=0; x2-x1=x4-x3; x3r=x2r+apex_corr; y2=y3=h+apex_o+apex_oo;
alpha=diag_ratio(2,left_stem,y2-y1,x4r-x1l-apex_corr);
penpos1(alpha*left_stem,0); penpos2(alpha*left_stem,0);
penpos3(alpha*right_stem,0); penpos4(alpha*right_stem,0);
z0=whatever[z1r,z2r]=whatever[z3l,z4l];
if y0<h-cap_notch_cut:
 y0:=h-cap_notch_cut;
 fill z0+.5right{down}...{z4-z3}diag_end(3l,4l,1,1,4r,3r)
  --diag_end(4r,3r,1,1,2l,1l)--diag_end(2l,1l,1,1,1r,2r){z2-z1}
  ...{up}z0+.5left--cycle; % left and right diagonals
else: fill z0--diag_end(0,4l,1,1,4r,3r)--diag_end(4r,3r,1,1,2l,1l)
  --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
penpos5(whatever,angle(z2-z1)); z5=whatever[z1,z2];
penpos6(whatever,angle(z3-z4)); z6=whatever[z3,z4]; y6=y5;
if hefty: y5r else: y5 fi =5/12y0;
y5r-y5l=y6r-y6l=cap_band; penstroke z5e--z6e; % bar line
if serifs:
 numeric inner_jut; pickup tiny.nib;
 prime_points_inside(1,2); prime_points_inside(4,3);
 if rt x1'r+cap_jut+.5u+1<=lft x4'l-cap_jut: inner_jut=cap_jut;
  else: rt x1'r+inner_jut+.5u+1=lft x4'l-inner_jut; fi
 dish_serif(1',2,a,1/2,outer_jut,b,.6,inner_jut)(dark);  % left serif
 dish_serif(4',3,c,1/2,inner_jut,d,1/3,outer_jut); fi  % right serif
%%%%%
penlabels(0,1,2,3,4,5,6); endchar;

lhchar "Uppercase Russian letter B";
cyrchar(B,12.5u#,cap_height#,0);
if is_small_cap: getcharcode(b); fi
italcorr cap_height#*slant-beak_jut#-1.5u#; %Gamma
adjust_fit(cap_serif_fit#,0);
numeric left_stem; left_stem=cap_stem-hround 2stem_corr;
pickup tiny.nib; pos1(left_stem,0); pos2(left_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5left_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
% upper right beak
pickup crisp.nib; pos3(slab,90); pos4(hair,0);
top y3r=h; x3=x1; rt x4r=hround(w-2u); y4=good.y(y3l-beak)-eps;
arm(3,4,e,beak_darkness,beak_jut);
if serifs:
 nodish_serif(1,2,a,1/3,cap_jut,b,1/3,.5cap_jut);  % upper serif
 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,.5cap_jut); fi  % lower serif
% usftsn_bowl(2);
_zero:=2;
_one:=5; _two:=6; _three:=7; _four:=8; _five:=9;
%
pickup tiny.nib;
penpos[_one](cap_bar,90);
penpos[_three](cap_curve if hefty:-3stem_corr fi,0);
penpos[_four](cap_band,-90); penpos[_five](cap_band,-90);
z[_five]r=bot z[_zero]; y[_four]=y[_five];
y[_three]=.5[y[_four],y[_two]];
x[_one]=x[_zero]r; x[_three]r=hround(w-u);
if (serifs=false) or (cap_bar#>.5cap_curve#) or (cap_bar<3):
 penpos[_two](cap_bar,90);
 x[_four]=.5[x[_zero],w-if serifs:1.5u else:2.5u fi]+.5u;
 y[_one]=y[_two]=.52h; x[_two]=x[_four];
else: penpos[_two](1/18[cap_bar,cap_curve],90);
 x[_four]=.5[x[_zero],w-1.5u]+.5u;
 y[_one]l=y[_two]l-.35cap_bar=.52h-.5cap_bar;
 x[_two]=x[_four]-.35u; fi
x[_two]l:=x[_two]l-.5u; x[_four]l:=x[_four]l-.5u;
fill stroke z[_five]e..super_arc.e([_four],[_three])
 & super_arc.e([_three],[_two])..z[_one]e; % lobe
%%%%%
penlabels(0,1,2,3,4,5,6,7,8,9); endchar;

lhchar "Uppercase Russian letter V (looks like B)";
cyrchar(V,12.5u#,cap_height#,0); %V_width#=12.5u#
if is_small_cap: getcharcode(v); fi
italcorr .75cap_height#*slant-u#; %P-.5u#
adjust_fit(cap_serif_fit#,0);
numeric left_stem,right_curve,middle_weight;
left_stem=cap_stem-hround 2stem_corr; middle_weight=.6vair+.5;
pickup tiny.nib; pos1(left_stem,0); pos2(left_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5left_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
penpos3(cap_band,90); penpos4(cap_band,90);
penpos6(middle_weight,-90); penpos7(middle_weight,-90);
penpos8(middle_weight,90); penpos9(middle_weight,90);
penpos5(right_curve-stem_corr,0); penpos10(right_curve,0);
penpos11(cap_band,-90); penpos12(cap_band,-90);
z3r=top z1; y4=y3; y5=.5[y4,y6]; y6=y7; y7l-y8l=vair; .5[y7l,y8l]=.52h;
z12r=bot z2; y11=y12; y10=.5[y11,y9]; y9=y8;
x4=x6; x9=x11=x4+.5u; x7=x8=x1; x9l:=x4+.25u;
x10r=hround(w-u); x5r=min(x10r-1,hround(w-1.5u));
if serifs:
 right_curve=cap_curve-stem_corr; x4=.5[x1,w-1.5u];
else:
 right_curve=cap_curve-3stem_corr; x4=.5[x1,w-2.5u];
 x4l:=x4l-.5u; x9l:=x9l-.5u; fi
x6l:=x6l-.5u; x11l:=x11l-.5u;
fill stroke z3e..super_arc.e(4,5) & super_arc.e(5,6)..z7e;  % upper lobe
fill stroke z8e..super_arc.e(9,10) & super_arc.e(10,11)..z12e;  % lower lobe
if serifs:
 nodish_serif(1,2,a,1/3,cap_jut,b,1/3,.5cap_jut);  % upper serif
 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,.5cap_jut); fi  % lower serif
penlabels(1,2,3,4,5,6,7,8,9,10,11,12); endchar;

lhchar "Uppercase Russian letter G (looks like Gamma)";
cyrchar(G,if monospace: 9u# else: 11u# fi-width_adj#, %G_width
 cap_height#,0);
if is_small_cap: getcharcode(g); fi
italcorr cap_height#*slant-beak_jut#-.25u#; %Gamma
adjust_fit(cap_serif_fit#,0);
% upper_g;
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
lft x1l=lft x2l=hround max(2u ,3u-.5cap_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
pickup crisp.nib; pos3(slab,90); pos4(hair,0);
top y3r=h; x3=x1; rt x4r=hround(w-.75u); y4=good.y(y3l-beak)-eps;
arm(3,4,e,beak_darkness,beak_jut);  % upper arm and beak
if serifs:
 nodish_serif(1,2,a,1/3,cap_jut,b,1/3,.5cap_jut);  % upper serif
 dish_serif(2,1,c,1/3,cap_jut,d,1/3,1.25cap_jut); fi % lower serif
%%%%%
penlabels(1,2,3,4); endchar;

iff not concrete:%
lhchar "Uppercase Russian letter D";
cyrchar(D,13.5u#,cap_height#,cap_sbeak#); % DL_width:N_width
if is_small_cap: getcharcode(d); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit# if not serifs:
	+\\.5(cap_stem#-u#),.5(cap_stem#-u#)+ else:,fi\\ cap_serif_fit#); %D_adj
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
rt x1r=rt x2r=w-hround max(2u,3u-.5cap_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; %right stem
numeric light_hair,light_stem,outer_jut;
light_hair=max(tiny.breadth,fudged.hair if hefty:-4stem_corr fi);
light_stem=max(tiny.breadth+eps,min(fudged.stem,fudged.hair if hefty:-4stem_corr fi));
outer_jut=
   if serifs: max(limit_dist,1.1cap_jut)
   else:      hround (r-rt x2r-.65u) fi;
penpos3(light_hair,0); penpos0(light_hair,0); x0=x3-eps; y0=0; y3=h;
x3=1/3[w-rt x1r-1/6(outer_jut if not serifs:-.5(cap_stem-u) fi),rt x1r]
    if not serifs:-.5(cap_stem-u) fi +eps;
x2'=x2; y2'=if serifs: 2/3 else: 3/4 fi h;
x4l=w-rt x1r-1/3outer_jut-eps; y4l=slab;
penpos4(light_hair,angle((y2',-x2')-(y4l,-x4l))); if y4r<0: y4r:=0; fi
fill z4l{z2'-z4}...{up}diag_end(0l,3l,1,1,3r,0r){down}
 ...{z4-z2'}z4r--cycle; %left stem
numeric inner_jut; inner_jut=min(.5(lft x1l-x3r)-eps,.5cap_jut);
if serifs:
 prime_points_inside(3,0);
 nodish_serif(3',0,a,1/3,cap_jut,b,1/3,inner_jut); % upper left serif
 nodish_serif(1,2,c,1/3,inner_jut,d,1/3,cap_jut);  % upper right serif
 filldraw z.b0--z.b1--z.c1--z.c0--cycle; % upper inter_serif bar
else:
 pos3''(slab,90); pos1'(slab,90);
 lft x3''=x3l; top y3''r=top y1'r=h; rt x1'=x1;
 filldraw stroke z3''e--z1'e; fi % upper bar
% upper descenders
numeric arm_thickness; arm_thickness=vround(slab+vair_corr+eps);
save slab; slab:=arm_thickness; % bottom.bar.slab
r_serif(2,1,e,1/3,inner_jut,f,1/3,beak_darkness,outer_jut,beak_jut); % lower right serif
% upper de_serif
y5=y.f1; y0'=y.f4; x5=good.x(w-x.f1); y6=y7=y.f3;
x6=good.x(w-x.f2); x7=good.x(w-x.f3);
pair beak_corner; ypart beak_corner=y0'; beak_corner=z7+whatever*(z5-z6);
x8=good.x(w-x.f4); x0'=w-x.e1; y8=y0';
filldraw z5--z6--z7{z5-z6}
    ...beak_darkness[beak_corner,.5[z7,z8]]
    ...{right}z8---z0'--(x0',y5)--cycle; % de_serif
filldraw z.f1--z.f4--z0'--(x0',y5)--cycle; % lower inter_serif bar
if serifs:
   numeric bracket_height;
   bracket_height=min(y2+bracket,y1);
   if bracket_height>y4l:
      path p.r,p.l; y5:=top y5;
      p.r=(z4r{z2'-z4}...{up}z3r); p.l=(z4l{z2'-z4}...{up}z3l);
      forsuffixes e=l,r:
          z9e=((0,bracket_height)--(w,bracket_height)) intersectionpoint p.e;
      endfor
      vardef t (suffix @) =
          angle direction directiontime z9@ of p.@ of p.@ enddef;
      fill z9l{dir (t(l)+180)}...1/3[(x4l,y5),.5[z9l,z5]]{z5-z9l}
          ...{left}z5--(x5,y0')--z0'--(x0',y5)
          --(x8-1/3outer_jut-eps,y5){left}
          ...{dir t(r)}z9r--cycle; % top part of de_serif
   fi
fi
penlabels(0',1,2,3,4,5,6,7,8,9); endchar;

lhchar "Uppercase Russian letter E";
cyrchar(E,12u#-width_adj#,cap_height#,0);
if is_small_cap: getcharcode(e); fi
italcorr cap_height#*slant-beak_jut#-.5u#;
adjust_fit(cap_serif_fit#,0);
% upper_e;
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
pickup crisp.nib; pos3(slab,90); pos4(hair,0);
top y3r=h; x3=x1; rt x4r=hround(w-u); y4=good.y(y3l-beak)-eps;
arm(3,4,e,beak_darkness,beak_jut);  % upper arm and beak
pos5(cap_bar,-90); pos6(hair,0);
top y5l=vround(.52[y2,y1]+.5cap_bar); x5=x1;
pos0(cap_bar,90); pos7(hair,0);
z0=z5; x6=x7; y6-y5l=y0l-y7;
if serifs:
 rt x6r=hround(w-4.4u+.5hair); y6=good.y(y5l+.6beak)+eps;
 rt x9r=hround(w-.5u);
else:
 rt x6r=hround(w-1.5u); y6=y5l+eps; rt x9r=hround(w-.75u); fi
arm(5,6,f,beak_darkness,0); arm(0,7,g,beak_darkness,0);  % middle arm and serif
pos8(slab if not serifs:+2stem_corr fi,-90); pos9(hair,0);
bot y8r=0; x8=x2; y9=good.y(y8l+7/6beak)+eps;
arm(8,9,h,beak_darkness,1.5beak_jut);  % lower arm and beak
if serifs:
 nodish_serif(1,2,a,1/3,cap_jut,b,1/3,.5cap_jut);  % upper serif
 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,.5cap_jut); fi  % lower serif
%%%%%
penlabels(0,1,2,3,4,5,6,7,8,9); endchar;

iff not concrete:%
iff not specific:%
lhchar "Uppercase Russian letter ZH (`roman')";
cyrchar(ZH,13.5u#,cap_height#,0); % N_width
if is_small_cap: getcharcode(zh); fi
italcorr cap_height#*slant-.5u#; %K
adjust_fit(w#-2max(2u#+.5fudged.cap_stem#,3u#)+\\ %ZHr_adj
 if monospace: 0,0 else: cap_serif_fit#,cap_serif_fit# fi); %uwlett_adj
% upperr_zh;
if odd((r-l)-fudged.cap_stem): change_width; fi % symmetric & all three equal
pickup tiny.nib; pos1(fudged.cap_stem,0); pos2(fudged.cap_stem,0);
lft x1l=lft x2l=hround (.5[l,r]-.5fudged.cap_stem)-eps; % middle stem point
top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
if serifs:
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,cap_jut); % upper stem serif
 dish_serif(2,1,c,1/3,cap_jut,d,1/3,cap_jut); fi % lower stem serif
% K_rbowl;zh%monospace:+.75u
numeric right_jut,stem[],alpha[]; pickup tiny.nib;
right_jut=if serifs:.6cap_jut else:.4tiny fi;
stem1=max(tiny.breadth,fudged.hair if hefty:-3stem_corr fi);
stem2=max(tiny.breadth,fudged.cap_stem-3stem_corr);
rt x3r=hround(r-letter_fit-u-right_jut if monospace:+.75u fi); %!!!
rt x6r=hround(r-letter_fit-.75u-right_jut if monospace:+.75u fi); %!!!
y4=1/3h; top y3=h; bot y6=0; x4=x1;
penpos3(alpha1*(stem1-tiny),0); penpos4(whatever,-90);
alpha1=diag_ratio(1,.5(stem1-tiny),y3-y4,x3r-x4);
penpos6(alpha2*(stem2-tiny),0);
alpha2=diag_ratio(1,.5(stem2-tiny),y1-y6,x6r-x1);
forsuffixes $=l,r: y3'$=h; y6'$=0; z4.$=z3'$+whatever*(z3-z4);
 z5.$=z6'$+whatever*(z1-z6)=whatever[z3,z4]; endfor
z5=.5[z5l,z5r];
z3'r=z3r+penoffset z3-z4 of currentpen+whatever*(z3-z4);
% we have also |z3'l=z3l+penoffset z4-z3 of currentpen+whatever*(z3-z4)|;\]
z6'r=z6r+penoffset z1-z6 of currentpen+whatever*(z1-z6);
z6'l=z6l+penoffset z6-z1 of currentpen+whatever*(z1-z6);
fill z4r--diag_end(4r,3'r,1,.5,3'l,4l)--z4l--cycle;  % upper diagonal
fill z5l--diag_end(5l,6'l,.5,1,6'r,5r)--z5r--cycle;  % lower diagonal
numeric inner_jut,up_inner_jut;
%%
if serifs:
 if rt x2r+cap_jut+.5u+1<=lft x6l-cap_jut: inner_jut=cap_jut;
  else: rt x2r+cap_jut+.5u+1=lft x6l-inner_jut; fi
 if rt x1r+cap_jut+.5u+1<=lft x3l-1.2cap_jut: up_inner_jut=1.2cap_jut;
  else: rt x1r+cap_jut+.5u+1=lft x3l-up_inner_jut; fi
 dish_serif(3,4,e,2/3,up_inner_jut,f,1/2,right_jut)(dark); % upper diagonal serif
 dish_serif(6,5,g,1/2,inner_jut,h,1/3,right_jut)(dark); fi % lower diagonal serif
%%%
% mirror
forsuffixes $ = 3r,3,3l,3'r,3'l,4r,4,4l,5l,5,5r,6l,6,6r,6'l,6'r:
 x.m$=l+(r-x$); y.m$=y$; endfor;
fill z.m4r--diag_end(.m4r,.m3'r,1,.5,.m3'l,.m4l)--z.m4l--cycle;  % upper diagonal
fill z.m5l--diag_end(.m5l,.m6'l,.5,1,.m6'r,.m5r)--z.m5r--cycle;  % lower diagonal
%%
if serifs:
 penpos7(alpha1*(stem1-tiny),0); penpos8(whatever,-90);
 penpos10(alpha2*(stem2-tiny),0);
 z7=z.m3; z8=z.m4; z9l=z.m5r; z9=z.m5; z9r=z.m5l; z10=z.m6;
 dish_serif(7,8,i,1/2,right_jut,j,2/3,up_inner_jut)(dark); % upper diagonal serif
 dish_serif(10,9,k,1/3,right_jut,l,1/2,inner_jut)(dark); fi % lower diagonal serif
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Uppercase Russian letter Z (looks like numeral 3)";
cyrchar(Z,11u#,cap_height#,0);
if is_small_cap: getcharcode(z); fi
italcorr .75cap_height#*slant-.5u#; %B
adjust_fit(if monospace: .35u#,.25u# else: 0,0 fi);
% upper_z;
pickup fine.nib; numeric right_curve,middle_weight;
middle_weight=max(fine.breadth,.6vair+.5);
pos2(cap_band,90); pos8(cap_band,-90);
if serifs:
   right_curve=cap_curve-stem_corr;
   pos1(cap_hair,180); pos9(cap_hair,-180); y1=.4[y5l,y2l];
else:
   right_curve=cap_curve-3stem_corr;
   pos1(1.1flare,120); pos9(flare,-120);
   top y1r=vround 7/8h+o; bot y9r=vround 1/7h-o; fi
pos4(middle_weight,-90); pos5(middle_weight,-90);
pos6(middle_weight,90); pos5'(middle_weight,90);
pos3(max(fine.breadth,right_curve-stem_corr),0);
pos7(max(fine.breadth,right_curve),0);
top y2r=h+o; bot y8r=-o;
x2=x6=x8=.5[1.5u,x7]; rt x7r=hround(w-.75u); rt x3r=hround(w-1.25u);
lft x5=lft x5'=min(hround 3.5u,lft x6)+eps;
y3=.5[y4l,y2l]; y7=.5[y6l,y8l]; x4=1/3[x5,x3l]; y4=y5; y5'=y6;
lft x1r=hround 1.1u; lft x9r=hround.9u;
top y5l-bot y5'l=vair; .5[y5l,y5'l]=.52h;
if serifs: y9=max(.52[top y8l,bot y5'l],y7+1);
   else: y9l:=good.y y9l; x9l:=good.x x9l; fi
filldraw stroke {{if not serifs:interim superness:=hein_super; fi
 super_arc.e(2,3)}} & super_arc.e(3,4)..z5e; % upper bowl
filldraw stroke z5'e..super_arc.e(6,7) & super_arc.e(7,8); % lower bowl
if serifs:
   filldraw stroke z1e{x2-x1,15(y2-y1)}....{right}z2e; % upper arc
   filldraw stroke
       {{interim superness:=more_super; super_arc.e(8,9)}}; % lower arc
else:
   filldraw stroke rterm.e(2,1,left,.9,4); % upper arc
   filldraw stroke  term.e(8,9,left,.8,4); % lower arc
fi
if serifs:
 path upper_arc; upper_arc=z1{x2-x1,15(y2-y1)}....{right}z2;
 pos10(.3[fine.breadth,cap_hair],0); x10l=x1r; top y10=h+o;
 x1'-x1l=2cap_curve; y1'=y1;
 numeric t; t=xpart(upper_arc intersectiontimes (z10r--z1'));
 filldraw z1r--z10l--z10r--subpath(t,0) of upper_arc--cycle; fi % upper serif
%%%%%
penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

lhchar "Uppercase Russian letter I (looks like backwards N)";
cyrchar(I,13.5u#,cap_height#,0); % N_width
if is_small_cap: getcharcode(i); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upper_i;
pickup tiny.nib; pos1(fudged.cap_stem,0); pos2(fudged.cap_stem,0);
pos3(fudged.cap_stem,0); pos4(fudged.cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
top y1=top y3=h; bot y2=bot y4=0;
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
numeric stem[],alpha[];
if hefty: numeric upper_notch,lower_notch;
 stem1=fudged.hair-stem_corr;
 upper_notch=y6-cap_notch_cut-eps; lower_notch=y5+cap_notch_cut+eps;
 if monospace:
  x5r =rt x1r; x6l =lft x3l; y5=vround(slab+eps); y6=vround(h-slab-eps);
  alpha1=diag_ratio(1,stem1,y5-y6,x5r-x6l);
  penpos5(min(2fudged.cap_stem,alpha1*stem1),0);
  penpos6(min(2fudged.cap_stem,alpha1*stem1),0);
  x5'=lft x1l; z5'=whatever[z5l,z6l]; x6'=rt x4r; z6'=whatever[z5r,z6r];
  x5l:=x5'; x6r:=x6'; y5l:=y5'; y6r:=y6';
 else:
  y5l=0; y6r=h; x5=x1r; x6=x3l; penpos5(stem1,0); penpos6(stem1,0);
 fi
 x2'=rt x1r; z2'=whatever[z5l,z6l]; x3'=lft x4l; z3'=whatever[z5r,z6r];
 fill z5l..
  if y2'>lower_notch: {right}(x2'+1,lower_notch){up}... fi
  {z6-z5}diag_in(5l,6l,1,6r)--z6r..
  if y3'<upper_notch: {left}(x3'-1,upper_notch){down}... fi
  {z5-z6}diag_in(6r,5r,1,5l)--cycle;  % diagonal
else: y5l=y2+bracket+eps; y6r=y3-bracket-eps;
 x5=hround (rt x1r-.5)-eps; x6=hround (lft x3l+.5)+eps;
 stem1=max(tiny.breadth,fudged.hair);
 alpha1=diag_ratio(1,stem1,x6-x5,top y6r-bot y5l);
 penpos5(alpha1*stem1,90); penpos6(alpha1*stem1,90);
 fill stroke z5e--z6e; fi % diagonal
%%%
if serifs: numeric inner_jut;
 if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
 dish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut);  % lower left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
 dish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut); fi % lower right serif
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Uppercase Russian letter I_shrt - SHORT I";
cyrchar(I_shrt,13.5u#,cap_height#+acc_height#,0); % N_width
if is_small_cap: getcharcode(i_shrt); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#,cap_serif_fit#); full_h:=h; h:=cap_height;
% upper_i;
pickup tiny.nib; pos1(fudged.cap_stem,0); pos2(fudged.cap_stem,0);
pos3(fudged.cap_stem,0); pos4(fudged.cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
top y1=top y3=h; bot y2=bot y4=0;
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
numeric stem[],alpha[];
if hefty: numeric upper_notch,lower_notch;
 stem1=fudged.hair-stem_corr;
 upper_notch=y6-cap_notch_cut-eps; lower_notch=y5+cap_notch_cut+eps;
 if monospace:
  x5r =rt x1r; x6l =lft x3l; y5=vround(slab+eps); y6=vround(h-slab-eps);
  alpha1=diag_ratio(1,stem1,y5-y6,x5r-x6l);
  penpos5(min(2fudged.cap_stem,alpha1*stem1),0);
  penpos6(min(2fudged.cap_stem,alpha1*stem1),0);
  x5'=lft x1l; z5'=whatever[z5l,z6l]; x6'=rt x4r; z6'=whatever[z5r,z6r];
  x5l:=x5'; x6r:=x6'; y5l:=y5'; y6r:=y6';
 else:
  y5l=0; y6r=h; x5=x1r; x6=x3l; penpos5(stem1,0); penpos6(stem1,0);
 fi
 x2'=rt x1r; z2'=whatever[z5l,z6l]; x3'=lft x4l; z3'=whatever[z5r,z6r];
 fill z5l..
  if y2'>lower_notch: {right}(x2'+1,lower_notch){up}... fi
  {z6-z5}diag_in(5l,6l,1,6r)--z6r..
  if y3'<upper_notch: {left}(x3'-1,upper_notch){down}... fi
  {z5-z6}diag_in(6r,5r,1,5l)--cycle;  % diagonal
else: y5l=y2+bracket+eps; y6r=y3-bracket-eps;
 x5=hround (rt x1r-.5)-eps; x6=hround (lft x3l+.5)+eps;
 stem1=max(tiny.breadth,fudged.hair);
 alpha1=diag_ratio(1,stem1,x6-x5,top y6r-bot y5l);
 penpos5(alpha1*stem1,90); penpos6(alpha1*stem1,90);
 fill stroke z5e--z6e; fi % diagonal
%%%
if serifs: numeric inner_jut;
 if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
 dish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut);  % lower left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
 dish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut); fi % lower right serif
%%%%%
% the accent
h:=cap_height+acc_height;
cbreve(.5w,0, 7,8,9,10,11,12,13)(cyrcaph);
penlabels(1,2,3,4,5,6, 7,8,9,10,11,12,13); endchar;

iff not concrete:%
iff not specific:%
lhchar "Uppercase Russian letter K (`roman')";
cyrchar(K,13.5u#,cap_height#,0); % N_width
if is_small_cap: getcharcode(k); fi
italcorr cap_height#*slant-.5u#;
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upperr_k;
pickup tiny.nib; pos1(fudged.cap_stem,0); pos2(fudged.cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5fudged.cap_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
if serifs:
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,cap_jut); % upper stem serif
 dish_serif(2,1,c,1/3,cap_jut,d,1/3,cap_jut); fi % lower stem serif
% K_rbowl;
numeric right_jut,stem[],alpha[]; pickup tiny.nib;
right_jut=if serifs:.6cap_jut else:.4tiny fi;
stem1=max(tiny.breadth,fudged.hair if hefty:-3stem_corr fi);
stem2=max(tiny.breadth,fudged.cap_stem-3stem_corr);
rt x3r=hround(r-letter_fit-u-right_jut);
rt x6r=hround(r-letter_fit-.75u-right_jut);
y4=1/3h; top y3=h; bot y6=0; x4=x1;
penpos3(alpha1*(stem1-tiny),0); penpos4(whatever,-90);
alpha1=diag_ratio(1,.5(stem1-tiny),y3-y4,x3r-x4);
penpos6(alpha2*(stem2-tiny),0);
alpha2=diag_ratio(1,.5(stem2-tiny),y1-y6,x6r-x1);
forsuffixes $=l,r: y3'$=h; y6'$=0; z4.$=z3'$+whatever*(z3-z4);
 z5.$=z6'$+whatever*(z1-z6)=whatever[z3,z4]; endfor
z5=.5[z5l,z5r];
z3'r=z3r+penoffset z3-z4 of currentpen+whatever*(z3-z4);
% we have also |z3'l=z3l+penoffset z4-z3 of currentpen+whatever*(z3-z4)|;\]
z6'r=z6r+penoffset z1-z6 of currentpen+whatever*(z1-z6);
z6'l=z6l+penoffset z6-z1 of currentpen+whatever*(z1-z6);
fill z4r--diag_end(4r,3'r,1,.5,3'l,4l)--z4l--cycle;  % upper diagonal
fill z5l--diag_end(5l,6'l,.5,1,6'r,5r)--z5r--cycle;  % lower diagonal
numeric inner_jut,up_inner_jut;
%%
if serifs:
 if rt x2r+cap_jut+.5u+1<=lft x6l-cap_jut: inner_jut=cap_jut;
  else: rt x2r+cap_jut+.5u+1=lft x6l-inner_jut; fi
 if rt x1r+cap_jut+.5u+1<=lft x3l-1.2cap_jut: up_inner_jut=1.2cap_jut;
  else: rt x1r+cap_jut+.5u+1=lft x3l-up_inner_jut; fi
 dish_serif(3,4,e,2/3,up_inner_jut,f,1/2,right_jut)(dark); % upper diagonal serif
 dish_serif(6,5,g,1/2,inner_jut,h,1/3,right_jut)(dark); fi % lower diagonal serif
%%%
%%%%%
penlabels(1,2,3,4,5,6); endchar;

iff not concrete:%
lhchar "Uppercase Russian letter L";
cyrchar(L,13.5u#,cap_height#,0); % DL_width:N_width
if is_small_cap: getcharcode(l); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit# if not serifs:+.5(cap_stem#-u#) fi, %DL_adj
 cap_serif_fit#); %
% upper_l;
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
rt x1r=rt x2r=w-hround max(2u,3u-.5cap_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; %stem
numeric bulb_diam; bulb_diam=flare+(cap_stem-stem);
numeric light_hair,bot_vair,left_jut;
light_hair=max(tiny.breadth,fudged.hair if hefty:-4stem_corr fi);
left_jut=
   if serifs: max(limit_dist,1.1cap_jut)
   else:      hround (w+cap_serif_fit-rt x2r-.65u) fi;
bot_vair=Vround(.5[vair,light_hair]);
x3=1/3[w-rt x1r-(1/6left_jut),rt x1r] if not serifs:-.5(cap_stem-u) fi+eps;
if serifs:
 pos3(light_hair,0); pos4(light_hair,-90);
 pos6(bulb_diam,-180); pos5(cap_hair,-180);
 top y3=h; y6=1/6h-max(0,flare-stem-2vair_corr-.5); z6r=z5r;
 lft x6r=l+letter_fit+hround(.5u-.5);
 x4=max(lft x5r+.5bulb_diam,.4[lft x5r,rt x3r]); bot y4r=-o;
 filldraw stroke z4e{right}..
  controls (min(15/16[x4,x3],max(x4,lft x6r+2flare))+(x3e-x3)+eps,y4e)
  and (x3e,good.y(min(y6-.5,1/3h)+1/3(y4e-y4))-eps)..z3e; % left tail
 {{less_tense; bulb(4,5,6)}};
else:
 pos3'(slab,90); pos1'(slab,90);
 lft x3'=x3-.5light_hair; rt x1'=x1r; top y3'r=top y1'r=h;
 filldraw stroke z3'e--z1'e;
 pickup fine.nib; pos3(max(fine.breadth,light_hair),0); pos4(bot_vair,-90); pos5(bot_vair,-90);
 bot y5r=0; x4=2/3[x3l,x5r]; lft x5=l+letter_fit+hround(.35u-.5);
 bot y4r=bot y5r; y3=y3'; x4l:=.25[x4,x5];
 path p;
 p=stroke z3{down}
   ..controls (x3,y5+.35h-eps) and (min(7/8[x4,x3],x5+2.5light_hair+.5u),y4)
   ..{left}z4--z5;
 z6=point .35 of p;
 pos6(max(fine.breadth,7/8[bot_vair,light_hair]),angle(direction .35 of p)+90);
 filldraw stroke z3e{down}...z6e{direction .35 of p}...{left}z4e--z5e; fi % arc
%%%
if serifs: x0=x3; y0=0;
 numeric inner_jut; inner_jut=min(.5(lft x1l-rt x3r)-eps,.5cap_jut);
 dish_serif(2,1,a,1/3,cap_jut,b,1/3,cap_jut);         %lower right serif
 nodish_serif(1,2,c,1/3,inner_jut,d,1/3,cap_jut);     %upper right serif
 nodish_serif(3,0,e,1/3,1.05cap_jut,f,1/3,inner_jut); %upper left serif
 filldraw z.c0--z.c1--z.f1--z.f0--cycle; fi % upper inter_serif bar
%%%%%
penlabels(0,1,2,3,3,4,5,6); endchar;

lhchar "Uppercase Russian letter M";
cyrchar(M,16u#+width_adj#,cap_height#,0);
if is_small_cap: getcharcode(m); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upper_m;
numeric stem[]; % thicknesses of the four strokes
stem1=hround(fudged.hair+stem_corr);
stem2=hround(fudged.cap_stem-4stem_corr);
stem3=hround(fudged.hair-stem_corr);
stem4=hround(fudged.cap_stem-3stem_corr);
if stem4<stem1: stem4:=stem1; fi
pickup tiny.nib; pos1(stem1,0); pos2(stem1,0);
pos3(stem4,0); pos4(stem4,0);
x1=x2; x3=x4; x1l=w-x3r; rt x3r=hround min(w-2u,w-3u+.5stem4);
top y1=top y3=h; bot y2=bot y4=0;
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
penpos5(stem2,0); penpos6(stem2,0); penpos7(stem3,0); penpos8(stem3,0);
x5l=x1; x6l=x7l; x8=lft x3l; x6-x5=x8-x7; y5=y8=h; y6=y7;
if hefty:
 y6=if monospace: vround 1/3h else: o fi;
 numeric upper_notch,lower_notch;
 upper_notch=h-cap_notch_cut; lower_notch=y6+cap_notch_cut;
 x1'=rt x1r; z1'=whatever[z5l,z6l]; x3'=lft x3l; z3'=whatever[z7r,z8r];
 z0=whatever[z5r,z6r]=whatever[z7l,z8l];
 fill z5l..
  if y1'<upper_notch: {right}(x1'+1,upper_notch){down}... fi
  {z6-z5}diag_in(5l,6l,1,6r)..diag_out(7l,1,7r,8r){z8-z7}
  if y3'<upper_notch: ...{up}(x3'-1,upper_notch){right} fi
  ..z8r--diag_out(8r,1,8l,7l){z7-z8}
  if y0<=lower_notch: ..{z7-z8}z0{z5-z6}..
   else: ...{down}(x0+.5,lower_notch)--(x0-.5,lower_notch){up}... fi
  {z5-z6}diag_in(6r,5r,1,5l)--cycle;  % diagonals
else:
 y6=0; z0=whatever[z5r,z6r]=whatever[z7l,z8l];
 fill z5l..{z6-z5}diag_in(5l,6l,1,6r)..diag_out(7l,1,7r,8r){z8-z7}
  ..z8r--diag_out(8r,1,8l,7l){z7-z8}..{z7-z8}z0{z5-z6}
  ..{z5-z6}diag_in(6r,5r,1,5l)--cycle; fi  % diagonals
%%%
if serifs:
 serif(1,2,a,1/3,-cap_jut); % upper left serif
 dish_serif(2,1,b,1/2,cap_jut,c,1/2,cap_jut)(dark); % lower left serif
 serif(3,4,d,1/3,cap_jut); % upper right serif
 dish_serif(4,3,e,1/3,cap_jut,f,1/3,cap_jut); fi % lower right serif
%%%%%
penlabels(0,1,1',2,3,3',4,5,6,7,8); endchar;

lhchar "Uppercase Russian letter N (looks like H)";
cyrchar(N,13.5u#,cap_height#,0); %N_width#
if is_small_cap: getcharcode(n); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upper_n;
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
pos3(cap_stem,0); pos4(cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
top y1=top y3=h; bot y2=bot y4=0;
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
penpos5(cap_bar,90); penpos6(cap_bar,90);
x5=x1; x6=x3; y5=y6=.52h;
fill stroke z5e--z6e;  % bar
%%%
if serifs:
 numeric inner_jut;
 if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
 dish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
 dish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut); fi  % lower right serif
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Uppercase Russian letter O";
cyrchar(O,14u#-width_adj#,cap_height#,0);
if is_small_cap: getcharcode(o); fi
italcorr .7cap_height#*slant-.5u#; %O
adjust_fit(0,0);
% upper_o;
penpos1(vair',90); penpos3(vround(vair+1.5vair_corr),-90);
penpos2(cap_curve,180); penpos4(cap_curve,0);
if monospace: x2r=hround 1.5u;
 interim superness:=sqrt superness; % make |"O"|, not |"0"|
else: x2r=hround u; fi
x4r=w-x2r; x1=x3=.5w; y1r=h+o; y3r=-o;
y2=y4=.5h-vair_corr; y2l:=y4l:=.52h;
penstroke pulled_super_arc.e(1,2)(.5superpull)
 & pulled_super_arc.e(2,3)(.5superpull)
 & pulled_super_arc.e(3,4)(.5superpull)
 & pulled_super_arc.e(4,1)(.5superpull) & cycle;  % bowl
%%%%%
penlabels(1,2,3,4); endchar;

lhchar "Uppercase Russian letter P (looks like PI)";
cyrchar(P,13.5u#,cap_height#,0); % N_width
if is_small_cap: getcharcode(p); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upper_p;
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
pos3(cap_stem,0); pos4(cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
top y1=top y3=h; bot y2=bot y4=0;
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
%%%
if serifs:
 numeric inner_jut;
 if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
 dish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
 dish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut);   % lower left serif
 inner_jut:=min(.5(lft x3l-rt x1r)-eps,.5cap_jut);
 nodish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
 nodish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper left serif
 filldraw z.b0--z.b1--z.e1--z.e0--cycle; % upper inter_serif bar
else:
 lft x1'= lft x1l; top y1'r=h; pos1'(slab,90);
 rt x3'=rt x3r; y3'=y1'; pos3'(slab,90);
 filldraw stroke z1'e--z3'e; fi % upper_bar
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Uppercase Russian letter R (looks like P)";
cyrchar(R,12u#,cap_height#,0);
if is_small_cap: getcharcode(r); fi
italcorr .75cap_height#*slant-.5u#;
adjust_fit(cap_serif_fit#,0);
% upper_r;
pickup tiny.nib; penpos1(cap_stem'-tiny,0); penpos2(cap_stem-tiny,0);
pos0(cap_stem',0); pos0'(cap_stem,0);
lft x1l=hround max(2u,3u-.5cap_stem'); top y1=h; bot y2=0;
x1l=x2l=x0l=x0'l; y0=y0'=y7;
penpos3(cap_band,90); penpos4(cap_band,90);
penpos5(cap_curve if hefty:-3stem_corr fi,0);
penpos6(.5[vair,cap_band],-90); penpos7(.5[vair,cap_band],-90);
z3r=top z1; y4=y3; y5=.5[y4l,y6l]; y6=y7;
x7=x2; y7l=vround .5h; x4=x6=.5w+.75u; x5r=hround(w-u);
x4l:=x6l:=x4-.25cap_curve;
filldraw stroke z1e--z0e--z0'e--z2e; % stem
fill stroke z3e..pulled_arc.e(4,5) & pulled_arc.e(5,6)..z7e;  % lobe
%%%
if serifs:
 nodish_serif(1,0,a,1/3,cap_jut,b,1/3,.5cap_jut);  % upper serif
 dish_serif(2,0',c,1/3,cap_jut,d,1/3,cap_jut); fi  % lower serif
%%%%%
penlabels(0,1,2,3,4,5,6,7); endchar;

iff serifs:%
lhchar "Uppercase Russian letter S (looks like C)";
cyrchar(S,13u#,cap_height#,0);
if is_small_cap: getcharcode(s); fi
italcorr cap_height#*slant-.5u#;
adjust_fit(0,0);
% upper_s;
pickup fine.nib; pos1(cap_hair,0); pos2(cap_band,90);
pos3(cap_curve,180); pos4(cap_band,270); pos5(hair,360);
rt x1r=rt x5r=hround(w-u); lft x3r=hround u; x2=x4=.55[x3,x1];
top y2r=h+o; bot y4r=-o; y3=.5[y2,y4];
bot y1=min(vround max(.6h,x_height-.5vair),bot y2l-eps);
y5=max(good.y .95(h-y1),y4l+eps);
(x2l',y2l)=whatever[z2r,z1l]; x2l:=min(x2l',x2l+.5u);
(x4l',y4l)=whatever[z4r,z5l]; x4l:=min(x4l',x4l+.5u);
filldraw stroke z1e{x2-x1,10(y2-y1)}
 ...pulled_arc.e(2,3) & pulled_arc.e(3,4)...{up}z5e; % arc
pos6(.3[fine.breadth,cap_hair],0); x6r=x1r; top y6=h+o;
x1r-x1'=2cap_curve-fine; y1'=y1;
path upper_arc; upper_arc=z1{x2-x1,10(y2-y1)}..z2{left};
numeric t; t=xpart(upper_arc intersectiontimes (z6l--z1'));
filldraw z1r--z6r--z6l--subpath(t,0) of upper_arc--cycle; % barb
%%%%%
penlabels(1,1',2,3,4,5,6); endchar;

iff not serifs:%
lhchar "Uppercase Russian letter S (looks like C)";
cyrchar(S,11.5u#,cap_height#,0);
if is_small_cap: getcharcode(s); fi
italcorr cap_height#*slant-.5u#;
adjust_fit(0,0);
% uppers_s;
pickup fine.nib; pos1(1.2flare,80); pos2(slab,90);
pos3(cap_curve,180); pos4(slab,270); pos5(flare,275);
rt x1r=hround(w-1.1u); x2=x4=.5w+1.25u;
lft x3r=hround max(u,2u-.5cap_curve); rt x5r=hround(w-.9u);
top y1r=vround .95h+o; top y2r=h+o; y3=.5h;
bot y4r=-o; bot y5r=vround .08h-o; y5l:=good.y y5l; x5l:=good.x x5l;
filldraw stroke rterm.e(2,1,right,.9,4) & super_arc.e(2,3)
 & super_arc.e(3,4) & term.e(4,5,right,.8,4); % arc and terminals
%%%%%
penlabels(1,2,3,4,5); endchar;

lhchar "Uppercase Russian letter T";
cyrchar(T,13u#-width_adj#,cap_height#,0);
if is_small_cap: getcharcode(t); fi
italcorr cap_height#*slant-beak_jut#-.25u#;
adjust_fit(0,0);
% upper_t;
if odd(cap_stem-w): change_width; fi % symmetric & all three equal
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
lft x1l=lft x2l=hround(.5w-.5cap_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
pickup crisp.nib; pos3(slab,90); pos4(hair,0);
top y3r=h; x3=x1; rt x4r=hround(w-.65u); y4=good.y(y3l-beak)-eps;
arm(3,4,e,beak_darkness,.7beak_jut);  % right arm and beak
pos5(hair,180); x5=w-x4; y5=y4;
arm(3,5,f,beak_darkness,-.7beak_jut);  % left arm and beak
%%%
if serifs:
 dish_serif(2,1,c,1/3,1.414cap_jut,d,1/3,1.414cap_jut);  % lower serif
 nodish_serif(1,2,a,1/3,.5cap_jut,b,1/3,.5cap_jut); fi  % upper bracketing
%%%%%
penlabels(1,2,3,4,5); endchar;

lhchar "Uppercase Russian letter U (looks like y)";
cyrchar(U,13u#,cap_height#,0);
if is_small_cap: getcharcode(u); fi
italcorr cap_height#*slant+.25u#;
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upper_u;
numeric left_stem,right_stem,bot_stem,bot_vair,outer_jut;
left_stem=cap_stem-stem_corr;
right_stem=min(cap_hair if hefty:-2stem_corr fi,left_stem);
bot_stem=min(cap_hair if hefty:-2stem_corr fi,left_stem);
bot_vair=Vround(if serifs:.5[vair',bot_stem] else:slab fi);
outer_jut=.7cap_jut; x1l=w-x4r=l+letter_fit+outer_jut+.25u; % W jut
y1=y4r=h; x2l=x3l;
if monospace: y2=y3=.3h; else: y2=y3=max(if not serifs:1.095 fi stem,1/6h); fi
numeric alpha; x9=.5w-1/2(.5[bot_stem,right_stem]); y9=-o;
alpha=diag_ratio(2,bot_stem,y1-y3,x4r-x1l-2apex_corr);
numeric u_ratio; u_ratio=(y3-y9)/(y1-y9);
x2l-x1l=x4r-x3r+
   if monospace: 2apex_corr else: if serifs: 2 fi (u_ratio*.5[x1l,x4r]) fi;
penpos3(alpha*bot_stem,0); penpos4(alpha*right_stem,0);
numeric alpha[]; alpha3=(y1++(x2l-x1l))/y1;
penpos1(alpha3*left_stem,0); penpos2(alpha3*left_stem,0);
z0l=whatever[z1r,z2r]=z4l+whatever*(z3r-z4r); penpos0(alpha*bot_stem,0);
z0'=whatever[rt z3r,rt z4r]; y0'=bot y6r=if serifs:-o else: 0 fi;
penpos6(bot_vair,-90); x6r=if serifs:.6 else:.5 fi[x3r,x1];
numeric t; t=if monospace: 1.25right_stem else: (x3r-x0')++(y3r-y0') fi;
penpos5(bot_vair,.5[angle(z4r-z6r),angle(z4r-z3r)]-90);
path p; numeric tau; p=z0r{z3r-z4r}....{left}z6r;
z5r=p intersectionpoint ((0,y2l-.5bot_vair)--(w,y2l-.5bot_vair));
tau=xpart(p intersectiontimes (z2l--z2r));
if y0>notch_cut+y2:
 y0l:=notch_cut+y2; % +y2 added for sanserif face
 fill z0l+.5right{up}...{z4r-z3r}diag_end(0,4l,1,1,4r,3r)
  --subpath(0,tau) of p--z2l--diag_end(2l,1l,1,1,1r,2r){z2-z1}
  ...{down}z0l+.5left--cycle; % left and right diagonals
else:
 fill z0l--diag_end(0,4l,1,1,4r,3r)--subpath(0,tau) of p
  --z2l--diag_end(2l,1l,1,1,1r,0)--cycle; % left and right diagonals
fi
fill p--z6l{right}...{-direction tau of p}
     if x5l>x2l: z2l else: z5l fi..{z4r-z3r}z0l--cycle;
pickup fine.nib;
if serifs:
 numeric bulb_diam; bulb_diam=flare+(cap_stem-stem);
 pos6'(bot_vair,-90); z6'=z6; pos7(hair,-180); pos8(bulb_diam,-180);
 y8=1/6h; z7r=z8r; lft x8r=x1;
 cyrbulb(6',7,8);  % arc and bulb
 numeric inner_jut; pickup tiny.nib;
 prime_points_inside(1,2); prime_points_inside(4,3);
 if rt x1'r+jut+.5u+1<=lft x4'l-jut: inner_jut=cap_jut;
  else: rt x1'r+inner_jut+.5u+1=lft x4'l-inner_jut; fi
 dish_serif(1',2,a,1/3,outer_jut,b,1/2,inner_jut);  % left serif
 dish_serif(4',3,c,.6,inner_jut,d,1/2,outer_jut)(dark);  % right serif
else:
 top z6'l=z6l; bot z6'r=z6r;
 pos7(bot_vair,-90); lft x7l=max(3.5u,rt x6r-t); bot y7r=bot y6'r;
 filldraw stroke z6'e--z7e; fi % arc
%%%%%
penlabels(0,0',1,2,3,4,5,6,6',7,8,9); endchar;

lhchar "Uppercase Russian letter F (looks like PHI)";
cyrchar(F,15u#,cap_height#,0);
if is_small_cap: getcharcode(f); fi
italcorr .7cap_height#*slant-.5u#; %O
adjust_fit(if monospace: -.5u#,-.5u# else: 0,0 fi);
numeric shaved_stem,light_curve; shaved_stem=cap_stem-hround 2stem_corr;
light_curve=cap_curve-hround stem_corr;
if odd(shaved_stem-w): change_width; fi % symmetric & all three equal
pickup tiny.nib; pos1(shaved_stem,0); pos2(shaved_stem,0);
lft x1l=lft x2l=hround (.5w-.5shaved_stem); % middle stem point
top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
penpos3(vair,90); penpos5(vair,-90);
penpos4(light_curve,180); penpos6(light_curve,0);
x4r=hround u; x6r=w-x4r; x3=x5=.5w;
y3r=vround(.89h if serifs:-.5slab fi); y4=y6=.5[y3,y5];
y5r=vround(.15h if serifs:+.5slab fi);
clearpen; interim superness:=hein_super; % make |"F"|, not |"fita"|
penstroke pulled_super_arc.e(3,4)(.5superpull)
 & pulled_super_arc.e(4,5)(.5superpull)
 & pulled_super_arc.e(5,6)(.5superpull)
 & pulled_super_arc.e(6,3)(.5superpull) & cycle;  % bowl
if serifs:
 dish_serif(1,2,a,1/3,1.25cap_jut,b,1/3,1.25cap_jut);  % upper serif
 dish_serif(2,1,c,1/3,1.25cap_jut,d,1/3,1.25cap_jut); fi  % lower serif
penlabels(1,2,3,4,5,6); endchar;

lhchar "Uppercase Russian letter H (looks like X)";
cyrchar(H,13u#,cap_height#,0);
if is_small_cap: getcharcode(h); fi
italcorr cap_height#*slant-.25u#;
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upper_h;
numeric stem[],outer_jut,xjut,alpha[];
stem1=cap_stem-2stem_corr; stem2=min(cap_hair,stem1);
outer_jut=.75cap_jut; xjut= if serifs: (stem1-stem2)/4 else: 0 fi;
x1l=l+letter_fit+.5u+outer_jut; x2r=r-letter_fit-u-outer_jut-xjut;
x3l=l+letter_fit+.25u+outer_jut+xjut; x4r=r-letter_fit-.25u-outer_jut;
y1=y2=h; y3=y4=0;
alpha1=diag_ratio(1,stem1,h,x4r-x1l);
alpha2=diag_ratio(1,stem2,h,x2r-x3l);
penpos1(alpha1*stem1,0); penpos2(alpha2*stem2,0);
penpos3(alpha2*stem2,0); penpos4(alpha1*stem1,0);
if hefty:
 z0=whatever[z1,z4]=whatever[z2,z3];
 x12=x34=x0; y13=y24=y0;
 z12=whatever[z2l,z3l]; z13=whatever[z2l,z3l];
 z24=whatever[z2r,z3r]; z34=whatever[z2r,z3r];
 forsuffixes $=13,24,34: z$'=.1[z$,z0]; endfor
 fill diag_end(12,1r,.5,1,1l,13')--z13'--diag_end(13',3l,1,.5,3r,34')--z34'
  --diag_end(34',4l,.5,1,4r,24')--z24'
  --diag_end(24',2r,1,.5,2l,12)--z12--cycle; % diagonals
else:
 fill diag_end(4r,1r,.5,1,1l,4l)
  --diag_end(1l,4l,.5,1,4r,1r)--cycle; % left diagonal
 fill diag_end(2l,3l,.5,1,3r,2r)
  --diag_end(3r,2r,.5,1,2l,3l)--cycle; fi % right diagonal
%%%
if serifs:
 numeric inner_jut[]; pickup tiny.nib;
 prime_points_inside(1,4); prime_points_inside(2,3);
 prime_points_inside(3,2); prime_points_inside(4,1);
 if rt x1'r+cap_jut+.5u+1<=lft x2'l-cap_jut-xjut: inner_jut1=cap_jut;
  else: rt x1'r+inner_jut1+.5u+1=lft x2'l-inner_jut1-xjut; fi
 if rt x3'r+cap_jut+.5u+1<=lft x4'l-cap_jut-xjut: inner_jut2=cap_jut;
  else: rt x3'r+inner_jut2+.5u+1=lft x4'l-inner_jut2-xjut; fi
 dish_serif(1',4,a,1/3,outer_jut,b,2/3,inner_jut1);  % upper left serif
 dish_serif(4',1,c,2/3,inner_jut2,d,1/3,outer_jut);  % lower right serif
 dish_serif(2',3,e,2/3,inner_jut1+xjut,f,1/2,outer_jut+xjut)(dark);  % upper right serif
 dish_serif(3',2,g,1/2,outer_jut+xjut,h,2/3,inner_jut2+xjut)(dark); fi % lower left serif
%%%%%
penlabels(0,1,2,3,4,12,13,24,34); endchar;

lhchar "Uppercase Russian letter C";
cyrchar(C,13.5u#,cap_height#,cap_sbeak#); % N_width
if is_small_cap: getcharcode(c); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#,
 cap_serif_fit# if not serifs:+.5(cap_stem#-u#) fi); %DL_adj
% upper_c;
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
pos3(cap_stem,0); pos4(cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
top y1=top y3=h; bot y2=bot y4=0;
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
numeric inner_jut,arm_thickness;
arm_thickness=vround(slab+vair_corr);
if serifs:
 if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
 save slab; slab:=arm_thickness; % bottom.bar.slab
 inner_jut:=min(.5(lft x3l-rt x1r)-eps,.5cap_jut);
 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
else:
 save slab; slab:=arm_thickness; % bottom.bar.slab
 lft x2'= lft x2l; bot y2'l=0; pos2'(slab,90);
 rt x4'= rt x4r; y4'=y2'; pos4'(slab,90);
 filldraw stroke z2'e--z4'e; fi % lower bar
% uppercase descender
inner_jut:=min(.5(lft x3l-rt x1r)-eps,.5cap_jut);
numeric right_jut;
right_jut=if serifs: max(limit_dist,1.1cap_jut) else: hround (r-rt x4r-.65u) fi;
r_serif(4,3,g,1/3,inner_jut,h,1/3,beak_darkness,right_jut,beak_jut); % lower right descender
if serifs:
 filldraw z.d0--z.d1--z.g1--z.g0--cycle; fi % lower inter_serif bar
penlabels(1,2,3,4,5,6); endchar;

lhchar "Uppercase Russian letter CH";
cyrchar(CH,13.5u#,cap_height#,0); % N_width
if is_small_cap: getcharcode(ch); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upper_ch;
pickup tiny.nib;
pos1(cap_stem,0); pos2(cap_stem,0); pos3(cap_stem,0); pos4(cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
top y1=top y3=h; bot y2=.3[y6,h]; bot y4=0;
x5l=1/3[x1,x3]; y5=y6; if serifs: y6'=y6-cap_hair+1.05cap_stem; fi
x6=x6'=x3; y6=good.y (h-.52h if serifs: -.35(.5[cap_hair,.7cap_stem]) fi);
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
clearpen; penpos2'(cap_stem,0); z2'=z2;
numeric middle_weight; middle_weight=.5[vair,cap_band];
penpos5(middle_weight,90); penpos6(middle_weight,90); penpos6'(middle_weight,90);
if serifs:
 if((y6'-y6)>=middle_weight+1+eps):
  fill stroke  pulled_arc.e(2',5) & z5e{right}...{.75(z5-z6)+z6'}z6'e;
 else:
  fill stroke  pulled_arc.e(2',5) & z5e--z6e; fi % arc
 numeric inner_jut; pickup tiny.nib;
 if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
%%%
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
 dish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut);  % lower right serif
else:
 filldraw stroke  pulled_arc.e(2',5) & z5e--z6e; fi % arc
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Uppercase Russian letter SH";
cyrchar(SH,19.75u#+width_adj#,cap_height#,0);
if is_small_cap: getcharcode(sh); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(if monospace: 0,0 else:cap_serif_fit#,cap_serif_fit# fi); %uwlett_adj
% upper_sh;
if odd(fudged.cap_stem-w): change_width; fi % symmetric & all three equal
pickup tiny.nib;
pos1(fudged.cap_stem,0); pos2(fudged.cap_stem,0);
pos3(fudged.cap_stem,0); pos4(fudged.cap_stem,0);
pos5(fudged.cap_stem,0); pos6(fudged.cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
top y1=top y3=top y5=h; bot y2=bot y4=bot y6=0;
lft x5l=lft x6l=hround (.5[x1,x3]-.5fudged.cap_stem); % middle stem point
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
filldraw stroke z5e--z6e; % center stem
numeric inner_jut,arm_thickness;
arm_thickness=vround(slab+vair_corr);
if serifs:
 if rt x1r+cap_jut+.5u+1<=lft x5l-cap_jut: inner_jut=cap_jut;
  else: rt x1r+inner_jut+.5u+1=lft x5l-inner_jut; fi
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
 dish_serif(5,6,i,1/3,inner_jut,j,1/3,inner_jut); % upper center serif
 inner_jut:=min(.5(lft x3l-rt x1r)-eps,.5cap_jut);
 save slab; slab:=arm_thickness; % bottom.bar.slab
 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
 nodish_serif(6,5,k,1/3,inner_jut,m,1/3,inner_jut); % lower center serif
 nodish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut);   % lower right serif
 filldraw z.d0--z.d1--z.g1--z.g0--cycle; % lower inter_serif bar
else:
 save slab; slab:=arm_thickness; % bottom.bar.slab
 lft x2'= lft x2l; bot y2'l=0; pos2'(slab,90);
 rt x4'=rt x4r; y4'=y2'; pos4'(slab,90);
 filldraw stroke z2'e--z4'e; fi % lower bar
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Uppercase Russian letter SHCH";
cyrchar(SHCH,19.75u#+width_adj#,cap_height#,cap_sbeak#);
if is_small_cap: getcharcode(shch); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(if monospace: 0 else: cap_serif_fit# fi, %uwlett_adj
 if monospace: 0 else: cap_serif_fit# if not serifs:+.5(cap_stem#-u#) fi fi); %DL_adj&uwlett_adj
% upper_sh;
if odd(fudged.cap_stem-w): change_width; fi % symmetric & all three equal
pickup tiny.nib;
pos1(fudged.cap_stem,0); pos2(fudged.cap_stem,0);
pos3(fudged.cap_stem,0); pos4(fudged.cap_stem,0);
pos5(fudged.cap_stem,0); pos6(fudged.cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
top y1=top y3=top y5=h; bot y2=bot y4=bot y6=0;
lft x5l=lft x6l=hround (.5[x1,x3]-.5fudged.cap_stem); % middle stem point
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
filldraw stroke z5e--z6e; % center stem
numeric inner_jut,arm_thickness;
arm_thickness=vround(slab+vair_corr);
if serifs:
 if rt x1r+cap_jut+.5u+1<=lft x5l-cap_jut: inner_jut=cap_jut;
  else: rt x1r+inner_jut+.5u+1=lft x5l-inner_jut; fi
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
 dish_serif(5,6,i,1/3,inner_jut,j,1/3,inner_jut); % upper center serif
 inner_jut:=min(.5(lft x3l-rt x1r)-eps,.5cap_jut);
 save slab; slab:=arm_thickness; % bottom.bar.slab
 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
 nodish_serif(6,5,k,1/3,inner_jut,m,1/3,inner_jut); % lower center serif
else:
 save slab; slab:=arm_thickness; % bottom.bar.slab
 lft x2'= lft x2l; bot y2'l=0; pos2'(slab,90);
 rt x4'=rt x4r; y4'=y2'; pos4'(slab,90);
 filldraw stroke z2'e--z4'e; fi % lower bar
%%%%%
% uppercase descender
inner_jut:=min(.5(lft x3l-rt x1r)-eps,.5cap_jut);
numeric right_jut;
right_jut=if serifs: max(limit_dist,1.1cap_jut) else: hround (r-rt x4r-.65u) fi;
r_serif(4,3,o,1/3,inner_jut,p,1/3,beak_darkness,right_jut,beak_jut); % lower right descender
if serifs:
 filldraw z.d0--z.d1--z.o1--z.o0--cycle; fi % lower inter_serif bar
penlabels(1,2,3,4,5,6); endchar;

lhchar "Uppercase Russian letter HRDSN - HARD SIGN";
cyrchar(HRDSN,12.5u#,cap_height#,0); %V_width#=12.5u#
if is_small_cap: getcharcode(hrdsn); fi
italcorr .52*.7cap_height#*slant-.5u#; % D*.52h
adjust_fit(min(4.5u#-.5stem#,3.5u#)-.5width_adj#, % Beak_adj
 0);
% upper_hrdsn;
numeric left_stem; left_stem=cap_stem-hround 2stem_corr;
pickup tiny.nib; pos1(left_stem,0); pos2(left_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5left_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
% upper left beak
pickup crisp.nib; pos3(slab,90); pos4(hair,180);
top y3r=h; x3=x1; lft x4r=l+letter_fit+hround.65u; y4=good.y(y3l-beak)-eps;
arm(3,4,q,beak_darkness,-.7beak_jut);
if serifs:
 nodish_serif(1,2,a,1/3,.5cap_jut,b,1/3,.5cap_jut);  % upper serif
 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,.5cap_jut); fi  % lower serif
% usftsn_bowl(2);
_zero:=2;
_one:=5; _two:=6; _three:=7; _four:=8; _five:=9;
%
pickup tiny.nib;
penpos[_one](cap_bar,90);
penpos[_three](cap_curve if hefty:-3stem_corr fi,0);
penpos[_four](cap_band,-90); penpos[_five](cap_band,-90);
z[_five]r=bot z[_zero]; y[_four]=y[_five];
y[_three]=.5[y[_four],y[_two]];
x[_one]=x[_zero]r; x[_three]r=hround(w-u);
if (serifs=false) or (cap_bar#>.5cap_curve#) or (cap_bar<3):
 penpos[_two](cap_bar,90);
 x[_four]=.5[x[_zero],w-if serifs:1.5u else:2.5u fi]+.5u;
 y[_one]=y[_two]=.52h; x[_two]=x[_four];
else: penpos[_two](1/18[cap_bar,cap_curve],90);
 x[_four]=.5[x[_zero],w-1.5u]+.5u;
 y[_one]l=y[_two]l-.35cap_bar=.52h-.5cap_bar;
 x[_two]=x[_four]-.35u; fi
x[_two]l:=x[_two]l-.5u; x[_four]l:=x[_four]l-.5u;
fill stroke z[_five]e..super_arc.e([_four],[_three])
 & super_arc.e([_three],[_two])..z[_one]e; % lobe
%%%%%
penlabels(1,2,3,4,5,6,7,8,9); endchar;

lhchar "Uppercase Russian letter ERY";
cyrchar(ERY,12.5u#,cap_height#,0); %V_width#=12.5u#
if is_small_cap: getcharcode(ery); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(if monospace: 0,0 else:cap_serif_fit#,cap_serif_fit# fi %uwlett_adj
 +4.5u#); %ERYadj
% upper_ery;
numeric left_stem; left_stem=cap_stem-hround 2stem_corr;
pickup tiny.nib; pos1(left_stem,0); pos2(left_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5left_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
if serifs: dish_serif(1,2,a,1/3,cap_jut,b,1/3,cap_jut);  % upper serif
 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,.5cap_jut); fi  % lower serif
% usftsn_bowl(2);
_zero:=2;
_one:=3; _two:=4; _three:=5; _four:=6; _five:=7;
%
pickup tiny.nib;
penpos[_one](cap_bar,90);
penpos[_three](cap_curve if hefty:-3stem_corr fi,0);
penpos[_four](cap_band,-90); penpos[_five](cap_band,-90);
z[_five]r=bot z[_zero]; y[_four]=y[_five];
y[_three]=.5[y[_four],y[_two]];
x[_one]=x[_zero]r; x[_three]r=hround(w-u);
if (serifs=false) or (cap_bar#>.5cap_curve#) or (cap_bar<3):
 penpos[_two](cap_bar,90);
 x[_four]=.5[x[_zero],w-if serifs:1.5u else:2.5u fi]+.5u;
 y[_one]=y[_two]=.52h; x[_two]=x[_four];
else: penpos[_two](1/18[cap_bar,cap_curve],90);
 x[_four]=.5[x[_zero],w-1.5u]+.5u;
 y[_one]l=y[_two]l-.35cap_bar=.52h-.5cap_bar;
 x[_two]=x[_four]-.35u; fi
x[_two]l:=x[_two]l-.5u; x[_four]l:=x[_four]l-.5u;
fill stroke z[_five]e..super_arc.e([_four],[_three])
 & super_arc.e([_three],[_two])..z[_one]e; % lobe
%%%
% I
w:=w+4.5u; pickup tiny.nib; rt x8r=rt x9r=w-hround max(2u,3u-.5stem);
top y8=h; bot y9=0; pos8(cap_stem,0); pos9(cap_stem,0);
filldraw stroke z8e--z9e;
if serifs:
 dish_serif(8,9,e,1/3,cap_jut,f,1/3,cap_jut);
 dish_serif(9,8,g,1/3,cap_jut,h,1/3,cap_jut); fi
%%%%%
penlabels(1,2,3,4,5,6,7,8,9); endchar;

lhchar "Uppercase Russian letter SFTSN - SOFT SIGN";
cyrchar(SFTSN,if monospace: 9u# else: 12.5u# fi %V_width#=12.5u#
 ,cap_height#,0);
if is_small_cap: getcharcode(sftsn); fi
italcorr .52*.7cap_height#*slant-.5u#; % D*.52h
adjust_fit(cap_serif_fit#,0);
numeric left_stem; left_stem=cap_stem-hround 2stem_corr;
pickup tiny.nib; pos1(left_stem,0); pos2(left_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5left_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
if serifs:
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,cap_jut);  % upper serif
 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,.5cap_jut); fi  % lower serif
% usftsn_bowl(2);
_zero:=2;
_one:=3; _two:=4; _three:=5; _four:=6; _five:=7;
%
pickup tiny.nib;
penpos[_one](cap_bar,90);
penpos[_three](cap_curve if hefty:-3stem_corr fi,0);
penpos[_four](cap_band,-90); penpos[_five](cap_band,-90);
z[_five]r=bot z[_zero]; y[_four]=y[_five];
y[_three]=.5[y[_four],y[_two]];
x[_one]=x[_zero]r; x[_three]r=hround(w-u);
if (serifs=false) or (cap_bar#>.5cap_curve#) or (cap_bar<3):
 penpos[_two](cap_bar,90);
 x[_four]=.5[x[_zero],w-if serifs:1.5u else:2.5u fi]+.5u;
 y[_one]=y[_two]=.52h; x[_two]=x[_four];
else: penpos[_two](1/18[cap_bar,cap_curve],90);
 x[_four]=.5[x[_zero],w-1.5u]+.5u;
 y[_one]l=y[_two]l-.35cap_bar=.52h-.5cap_bar;
 x[_two]=x[_four]-.35u; fi
x[_two]l:=x[_two]l-.5u; x[_four]l:=x[_four]l-.5u;
fill stroke z[_five]e..super_arc.e([_four],[_three])
 & super_arc.e([_three],[_two])..z[_one]e; % lobe
%%%%%
penlabels(1,2,3,4,5,6,7); endchar;

iff serifs:%
lhchar "Uppercase Russian letter EREV - REVERSE E";
cyrchar(EREV,13u#,cap_height#,0);
if is_small_cap: getcharcode(erev); fi
italcorr .7cap_height#*slant-.5u#; %O
adjust_fit(0,0);
% upper_erev;
pickup fine.nib; pos1(cap_hair,180); pos2(cap_band,90);
pos3(cap_curve,0); pos4(cap_band,-90); pos5(hair,-180);
lft x1r=lft x5r=hround u; rt x3r=hround(w-u); x2=x4=.55[x3,x1];
top y2r=h+o; bot y4r=-o; y3=.5h-vair_corr; y3l:=.52h;
bot y1=min(vround.675h,bot y2l-eps); y5=max(good.y .95(h-y1),y4l+eps);
(x2l',y2l)=whatever[z2r,z1l]; x2l:=max(x2l',x2l-.5u);
(x4l',y4l)=whatever[z4r,z5l]; x4l:=max(x4l',x4l-.5u);
filldraw stroke z1e{x2-x1,10(y2-y1)}...pulled_super_arc.e(2,3)(.5superpull)
 & pulled_super_arc.e(3,4)(.5superpull)...{up}z5e; % arc
pos6(.3[fine.breadth,cap_hair],180); x6r=x1r; top y6=h+o;
x1'-x1r=2cap_curve-fine; y1'=y1;
path upper_arc; upper_arc=z1{x2-x1,10(y2-y1)}..z2{right};
numeric t; t=xpart(upper_arc intersectiontimes (z6l--z1'));
filldraw z1r--z6r--z6l--subpath(t,0) of upper_arc--cycle; % barb
%%%
% uerev_bar;
numeric bar[]; y8=y7=y3;
x8=x3l; x7=max(rt x1l+.5hair,0.85[x3l,x1l]);
if (bar#<=.5curve#):
   penpos7(cap_bar,90); penpos8(cap_bar,90);
   bar2=7/8[cap_bar,fudged.cap_stem-3stem_corr];
   penpos9(bar2,45); z9=.475[z7l,z8l];
   fill circ_stroke z7e{2,1}..{2,-1}z9e..{2,1}z8e; % curve /\/
else:
   pickup fine.nib; pos7(cap_bar,90); pos8(cap_bar,90);
   filldraw stroke z7e--z8e; % bar --
fi
%%%%%
penlabels(1,1',2,3,4,5,6,7,8,9); endchar;

iff not serifs:%
lhchar "Uppercase Russian letter EREV - REVERSE E";
cyrchar(EREV,11.5u#,cap_height#,0);
if is_small_cap: getcharcode(erev); fi
italcorr .7cap_height#*slant-.5u#; %O
adjust_fit(0,0);
% uppers_erev;
 pickup fine.nib; pos1(1.2flare,100); pos2(slab,90);
 pos3(cap_curve,0); pos4(slab,-90); pos5(flare,-95);
 lft x1r=hround1.1u; x2=x4=w-(.5w+1.25u);
 rt x3r=w-hround max(u,2u-.5cap_curve);
 lft x5r=hround.9u;
 top y1r=vround .95h+o; top y2r=h+o; y3=.5h;
 bot y4r=-o; bot y5r=vround .08h-o; y5l:=good.y y5l; x5l:=good.x x5l;
 filldraw stroke rterm.e(2,1,left,.9,4) & super_arc.e(2,3)
  & super_arc.e(3,4) & term.e(4,5,left,.8,4);
%%%
% urevs_bar;
pickup fine.nib; numeric bar[];
bar1=if is_small_cap: max(fine.breadth+eps,.6[thin_join,vair])
        else: cap_bar fi;
pos6(bar1,90); pos7(bar1,90);
y7=y6=y3; x7=x3l; x6=max(rt x1l+.5hair,0.85[x3l,x1l]);
filldraw stroke z6e--z7e; % bar --
%%%%%
penlabels(1,2,3,4,5,6,7,8); endchar;

lhchar "Uppercase Russian letter YU (looks like IO)";
cyrchar(YU,14u#-width_adj#,cap_height#,0);
if is_small_cap: getcharcode(yu); fi
italcorr .7cap_height#*slant-.5u#;
adjust_fit(if monospace: 6.5u# else:
        max(5u#+.5cap_stem#,6u#)+cap_serif_fit# fi, %Ipart_adj
 if monospace:-1.25u# else: 0 fi);
% upper_yu;
penpos1(vair',90); penpos3(vround(vair+1.5vair_corr),-90);
penpos2(cap_curve,180); penpos4(cap_curve,0);
if monospace: x2r=hround 1.5u;
 interim superness:=sqrt superness;  % make |"O"|, not |"0"|
else: x2r=hround u; fi
x4r=w-x2r; x1=x3=.5w; y1r=h+o; y3r=-o;
y2=y4=.5h-vair_corr; y2l:=y4l:=.52h;
penstroke pulled_super_arc.e(1,2)(.5superpull)
 & pulled_super_arc.e(2,3)(.5superpull)
 & pulled_super_arc.e(3,4)(.5superpull)
 & pulled_super_arc.e(4,1)(.5superpull) & cycle;  % bowl
%I_part(2);
_zero:=2;
_one:=5; _two:=6; _three:=7; _four:=8;
%
pickup tiny.nib; pos[_one](cap_stem,0); pos[_two](cap_stem,0);%pos
lft x[_one]l=lft x[_two]l=
	l+letter_fit+if monospace:-.35u else: cap_serif_fit fi
	+hround max(2u,3u-.5cap_stem);
top y[_one]=h; bot y[_two]=0;
filldraw stroke z[_one]e--z[_two]e; % stem
x[_three]=x[_one]; y[_three]=y[_zero];
x[_four]=x[_zero]; y[_four]=y[_three];
pos[_three](cap_bar,90); pos[_four](cap_bar,90);
filldraw stroke z[_three]e--z[_four]e; % bar
if serifs: dish_serif([_one],[_two],s,1/3,cap_jut,t,1/3,cap_jut);
 dish_serif([_two],[_one],u,1/3,cap_jut,v,1/3,cap_jut); fi
%%%%%
penlabels(0,1,2,3,4,5,6,7,8); endchar;

iff not concrete:%
iff not specific:%
lhchar "Uppercase Russian letter YA (looks like backward R) (`roman')";
cyrchar(YA,if serifs:13.5u# else:12.5u#-.5width_adj# fi %N_width; upss R
 ,cap_height#,0);
if is_small_cap: getcharcode(ya); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(if serifs:cap_serif_fit# else:0 fi,cap_serif_fit#);
% upperr_ya;
pickup tiny.nib; pos1(cap_stem',0); pos2(cap_stem',0);
rt x1r=rt x2r=hround(w-max(2u,3u-.5cap_stem')); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
penpos3(cap_band,90); penpos4(cap_band,90);
penpos5(cap_curve if hefty:-3stem_corr fi,180);
numeric middle_weight; middle_weight=.5[vair,cap_band];
penpos6(middle_weight,-90); penpos7(middle_weight,-90);
z3r=top z1; y4=y3; y5=.52[y6l,y4l]; y6=y7;
x7=x2; y7l=vround(.5h+.5vair); x4=x6;
if serifs: x4=.5w+.5u; x5r=hround (2u);
 else: x4=.5w-.5u; x5r=hround u; fi
x4l:=x6l:=x4+.125cap_curve;
fill stroke z7e..pulled_arc.e(6,5) & pulled_arc.e(5,4)..z3e;  % lobe
pickup tiny.nib; numeric stem[],alpha,right_jut;
right_jut=if serifs:.6cap_jut else:.4tiny fi;
if serifs: bot y9=bot y2; else: y9=0; fi
lft x9l=hround(if serifs:l+letter_fit+.75u+right_jut else:.5u fi); y8=y6;
stem1=max(tiny.breadth,fudged.cap_stem-3stem_corr);
alpha=diag_ratio(1,.5(stem1-tiny),y1-y9,x9l-x1);
penpos9(alpha*(stem1-tiny),0);
forsuffixes $=l,r:  y9'$=0;  endfor
z9'r=z9r+penoffset z1-z9 of currentpen+whatever*(z1-z9);
z9'l=z9l+penoffset z9-z1 of currentpen+whatever*(z1-z9);
if serifs: z8r=z9'r+whatever*(z1r-z9); else: x8=x6+.5u; fi
penpos8(if serifs:x9'r-x9'l else: cap_stem fi-2stem_corr,0);
fill z8l--diag_end(8l,9'l,1,.5,9'r,8r)--z8r--cycle;  % diagonal
numeric inner_jut;
if lft x2l-cap_jut-.5u+1>=rt x9r+cap_jut: inner_jut=cap_jut;
 else: lft x2r-cap_jut-.5u+1=rt x9r+inner_jut; fi
if serifs:
 nodish_serif(1,2,a,1/3,.5cap_jut,b,1/3,cap_jut); % upper serif
 dish_serif(2,1,c,1/3,cap_jut,d,1/3,cap_jut); % lower serif
 dish_serif(9,8,g,1/2,right_jut,h,1/3,inner_jut)(dark); fi % lower diagonal serif
%%%%%
penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

lhchar "Uppercase Russian letter YO (looks like E umlaut)";
cyrchar(YO,12u#-width_adj#,cap_height#+acc_height#,0);
if is_small_cap: getcharcode(yo); fi
italcorr cap_height#*slant-beak_jut#-.5u#;
adjust_fit(cap_serif_fit#,0); h:=cap_height;
% upper_e;
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
pickup crisp.nib; pos3(slab,90); pos4(hair,0);
top y3r=h; x3=x1; rt x4r=hround(w-u); y4=good.y(y3l-beak)-eps;
arm(3,4,e,beak_darkness,beak_jut);  % upper arm and beak
pos5(cap_bar,-90); pos6(hair,0);
top y5l=vround(.52[y2,y1]+.5cap_bar); x5=x1;
pos0(cap_bar,90); pos7(hair,0);
z0=z5; x6=x7; y6-y5l=y0l-y7;
if serifs:
 rt x6r=hround(w-4.4u+.5hair); y6=good.y(y5l+.6beak)+eps;
 rt x9r=hround(w-.5u);
else:
 rt x6r=hround(w-1.5u); y6=y5l+eps; rt x9r=hround(w-.75u); fi
arm(5,6,f,beak_darkness,0); arm(0,7,g,beak_darkness,0);  % middle arm and serif
pos8(slab if not serifs:+2stem_corr fi,-90); pos9(hair,0);
bot y8r=0; x8=x2; y9=good.y(y8l+7/6beak)+eps;
arm(8,9,h,beak_darkness,1.5beak_jut);  % lower arm and beak
if serifs:
 nodish_serif(1,2,a,1/3,cap_jut,b,1/3,.5cap_jut);  % upper serif
 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,.5cap_jut); fi  % lower serif
%%%%%
% the accent
h:=cap_height+acc_height;
uppercase_umlaut(if serifs: 0 else: (.5[lft x1l,rt x4r]-.5w) fi,0, 10,11,12,13);
penlabels(0,1,2,3,4,5,6,7,8,9, 10,11,12,13); endchar;

if concrete: input lgrucu; fi % Russian concrete letters

endinput;
%end of file