% This is UPPERBCD.MF  
% Version 1.1a 
% Date 13-MAR-1992
% 
% (c) 1991 by J"org Knappen. See fc.rme for copying conditions
% This file is part of the fc-package 
% See fc.rme for more information
%
% J"org Knappen
% Institut f"ur Kernphysik
% Postfach 39 80
% D-W 6500 Mainz
% knappen@vkpmzd.kph.uni-mainz.de

% Contents:
%
% The following characters are generated without condition:
%
% B, C, D
%
% And the following on demand, i. e. if their code is known:
%
% hooktop_B, cyr_B (variant of hooktop_B), C_cedilla, hooktop_C, hooktop_D,
% Edh (crossed D, also uppercase of long_d), hooktop_Edh (proposed capital Edh
% for african use)
%
% Higher versions of this file might include more characters.

cmchar "The letter B";
beginchar("B",12.5u#,cap_height#,0);
italcorr .75cap_height#*slant-.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;
z12r=bot z2; y11=y12; y10=.5[y11,y9]; y8=y9; .5[y7l,y8l]=.52h;
x4=x6; x9=x11=x4+.5u; x7=x8=x1; x9l:=x4+.25u;
x5r=hround(w-1.5u); x10r=hround(w-u);
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
math_fit(0,.5ic#); penlabels(1,2,3,4,5,6,7,8,9,10,11,12); endchar;

iff known hooktop_B:
cmchar "Capital letter lefthook B";       % jk, based on cm
beginchar(hooktop_B,12.5u#,cap_height#,0);
italcorr .75cap_height#*slant-.5u#;
adjust_fit(4u#,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;
z12r=bot z2; y11=y12; y10=.5[y11,y9]; y8=y9; .5[y7l,y8l]=.52h;
x4=x6; x9=x11=x4+.5u; x7=x8=x1; x9l:=x4+.25u;
x5r=hround(w-1.5u); x10r=hround(w-u);
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
left_hook(1,1',21,22,23,24);            %left hook
math_fit(0,.5ic#); penlabels(1,2,3,4,5,6,7,8,9,10,11,12,21,22,23,24); endchar;

iff known cyr_B:
cmchar "Capital cyrillic letter BE";      % from cmcyr
beginchar(cyr_B,12.5u#,cap_height#,0);
italcorr .75cap_height#*slant-.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
penpos5(cap_band,90); penpos6(cap_band,90); penpos7(right_curve,0);
penpos8(cap_band,-90); penpos9(cap_band,-90);
z9r=bot z2; y8=y9; y7=.5[y8,y6]; y5=y6=.52h;
x6=x8; x5=x1; x6l:=.5[x1,w-1.5]+.25u; x7r=hround(w-u); x8l:=x8l-.5u;
if serifs: right_curve=cap_curve-stem_corr; x6=.5[x1,w-1.5u]+.5u;
else: right_curve=cap_curve-3stem_corr; x6=.5[x1,w-2.5u]+.5u;
x6l:=x6l-.5u; fi
fill stroke z5e..super_arc.e(6,7) & super_arc.e(7,8)..z9e;  % lower lobe
pickup crisp.nib; pos3(slab,90); pos4(hair,0);
top y3r=h; x3=x1; rt x4r=hround(w-1.5u); y4=good.y(y3l-beak)-eps;
arm(3,4,e,beak_darkness,.7beak_jut);  % upper 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
math_fit(0,.5ic#); penlabels(1,2,3,4,5,6,7,8,9); endchar;

cmchar "The letter C";
if serifs: beginchar("C",13u#,cap_height#,0);
 italcorr cap_height#*slant-.5u#;
 adjust_fit(0,0);
 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
else: beginchar("C",11.5u#,cap_height#,0);
 italcorr cap_height#*slant-.5u#;
 adjust_fit(0,0);
 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); fi % arc and terminals
picture savedpicture;
savedpicture:=currentpicture;
savedpoint:=x4;
math_fit(-.3cap_height#*slant-.5u#,.5ic#);
penlabels(1,1',2,3,4,5,6); endchar;

iff known C_cedilla:
cmchar"Capital letter C with cedilla";
beginchar(C_cedilla,13u#,cap_height#,0.875desc_depth#);
italcorr cap_height#*slant-.5u#;
adjust_fit(if monospace: .5u#,.5u# else: 0,0 fi);
currentpicture:=savedpicture;
x1=savedpoint;
if serifs: pickup crisp.nib; pos1(stem,0); pos2(stem,0);
 pos3(vair,90); pos4(stem,0); pos5(vair,-90);
 x1=x2; z3l=z2l; x4=x2+1.5u; x5=x3-1.5u;
 bot y1=-o; bot y2=-vround 2/7d-o; y4=.5[y3,y5]; bot y5=-d-o;
 filldraw stroke z1e--z2e;  % stem
 filldraw stroke z3e{right}...z4e{down}...{left}z5e;  % hook
else: pickup fine.nib; pos1(vair,0); top y1=-o-2;
 pos2(.5[vair,stem],0); bot y2=-d-o; x2=x1-1.25u;
 filldraw stroke z1e--z2e; fi  % diagonal
penlabels(1,2,3,4,5); endchar;

iff known hooktop_C:
cmchar"Capital letter hooktop C";
beginchar(hooktop_C,13u#,cap_height#+comma_depth#,0);
italcorr cap_height#*slant-.5u#;
adjust_fit(if monospace: .5u#,.5u# else: 0,0 fi);
currentpicture:=savedpicture;
%if serifs:
pickup tiny.nib;
pos0(cap_stem,180); pos1(cap_stem,180); pos2(cap_band,90); 
pos3(cap_hair,0); pos4(flare,0);
x0=x1=savedpoint; y1=.5[h,cap_height]; y0=cap_height; 
x2=.4[x1,x3]; top y2r=h+oo;
rt x3r= if serifs: hround(w-.7u) else: hround(w-1.1u) fi; 
y4=.35[h,cap_height];
filldraw z2r{left}...{down}z1r--z0r--z0l--z1l{up}...{right}z2l--cycle;
bulb(2,3,4);
%else:
%fi                 
penlabels(0,1,2,3,4); endchar;

numeric savedpoint;
savedpicture:=nullpicture;

cmchar "The letter D";
beginchar("D",13.5u#,cap_height#,0);
italcorr .7cap_height#*slant-.5u#;
adjust_fit(cap_serif_fit#,0);
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
penpos3(cap_band,90); penpos4(cap_band,90);
penpos5(cap_curve-stem_corr,0);
penpos6(cap_band,-90); penpos7(cap_band,-90);
z3r=top z1; y4=y3; y5=.51[y4,y6]; y6=y7;
z7r=bot z2; x4=x6=.5w+.25u; x5r=hround(w-u);
x4l:=x6l:=x4-.25cap_curve;
fill stroke z3e..pulled_arc.e(4,5) & pulled_arc.e(5,6)..z7e;  % 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
math_fit(0,ic#-.5u#); penlabels(1,2,3,4,5,6,7); endchar;

iff known hooktop_D:
cmchar "Capital letter hooktop D";  % jk, based on cm
beginchar(hooktop_D,13.5u#,cap_height#,0);
italcorr .7cap_height#*slant-.5u#;
adjust_fit(4u#,0);
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
penpos3(cap_band,90); penpos4(cap_band,90);
penpos5(cap_curve-stem_corr,0);
penpos6(cap_band,-90); penpos7(cap_band,-90);
z3r=top z1; y4=y3; y5=.51[y4,y6]; y6=y7;
z7r=bot z2; x4=x6=.5w+.25u; x5r=hround(w-u);
x4l:=x6l:=x4-.25cap_curve;
fill stroke z3e..pulled_arc.e(4,5) & pulled_arc.e(5,6)..z7e;  % 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
left_hook(1,1',21,22,23,24);     % left hook
math_fit(0,.5ic#); penlabels(1,2,3,4,5,6,7,21,22,23,24); endchar;

iff known Edh:
cmchar"Capital letter crossed D"; % Capital of icelandic edh, kroatian dje and 
                                  % ewe d with tail
% cmchar "Capital Eth";           % from  im
beginchar(Edh,13.5u#,cap_height#,0);
italcorr .7cap_height#*slant-.5u#;
adjust_fit(cap_serif_fit#,0);
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
penpos3(cap_band,90); penpos4(cap_band,90);
penpos5(cap_curve-stem_corr,0);
penpos6(cap_band,-90); penpos7(cap_band,-90);
z3r=top z1; y4=y3; y5=.51[y4,y6]; y6=y7;
z7r=bot z2; x4=x6=.5w+.25u; x5r=hround(w-u);
x4l:=x6l:=x4-.25cap_curve;
fill stroke z3e..pulled_arc.e(4,5) & pulled_arc.e(5,6)..z7e;  % 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
%pickup crisp.nib ; % now the edh bar                 % changed
%pos8(cap_band,90) ; pos9(cap_band,90) ;
%top y8r = vround(.52h + .5cap_band) ; y9 = y8 ;
%lft x8 = 0 ; x1 - x8 = x9 - x1 ;
%filldraw stroke z8e --- z9e ;
pickup crisp.nib; y9-.5bar=.2[bar_height,x_height];
y10+.5bar=.8[bar_height,x_height]; lft x9=0; x1-x9=x10-x1;
numeric theta; theta=angle(z10-z9)+90; pos9(bar,theta); pos10(bar,theta);
filldraw stroke z9e--z10e;   % cross piece (from "Cross for polish l and L")
math_fit(0,ic#-.5u#); penlabels(1,2,3,4,5,6,7,9,10); endchar;

iff known hooktop_Edh:
cmchar"Capital letter hooktop_Edh"; % jk, based on im
beginchar(hooktop_Edh,13.5u#,cap_height#,0);
italcorr .7cap_height#*slant-.5u#;
adjust_fit(4u#,0);
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
penpos3(cap_band,90); penpos4(cap_band,90);
penpos5(cap_curve-stem_corr,0);
penpos6(cap_band,-90); penpos7(cap_band,-90);
z3r=top z1; y4=y3; y5=.51[y4,y6]; y6=y7;
z7r=bot z2; x4=x6=.5w+.25u; x5r=hround(w-u);
x4l:=x6l:=x4-.25cap_curve;
fill stroke z3e..pulled_arc.e(4,5) & pulled_arc.e(5,6)..z7e;  % 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
pickup crisp.nib; y9-.5bar=.2[bar_height,x_height];
y10+.5bar=.8[bar_height,x_height]; lft x9=0; x1-x9=x10-x1;
numeric theta; theta=angle(z10-z9)+90; pos9(bar,theta); pos10(bar,theta);
filldraw stroke z9e--z10e;   % cross piece (from "Cross for polish l and L")
left_hook(1,1',21,22,23,24);     % left hook
math_fit(0,ic#-.5u#); penlabels(1,2,3,4,5,6,7,9,10,21,22,23,24); endchar;

endinput;
