def draw_refl_luva(suffix i,j,k,l)
 (expr luva_type,bow_stem_y,bow_arch_x,
       bow_side_y,bow_end_x) =
 y.i = bow_stem_y * ex ;
 x.j - x.i = bow_arch_x * (x.k - x.i) ;
 y.k = (if (luva_type = "calma") or (luva_type = "quesse"): 1 - fi bow_side_y) * ex ;
 x.l - x.i = bow_end_x * (x.k - x.i) ;
 numeric x.luva_serif,y.luva_serif ;
 z.luva_serif = z.l + 0.03em *
   if luva_type = "tinco": dir 135 else: dir 315 fi ;
 
 path luva_path ;
 luva_path = z.i{dir( if (luva_type = "tinco") or (luva_type = "parma"):
                  180-penangle else: -penangle fi)}
      .. z.j{if (luva_type = "tinco") or (luva_type = "parma"):
                   left else: right fi}
     .. z.k ..
      if (luva_type = "parma") or (luva_type = "quesse"): {curl 0.3}z.l
      else: z.l .. {curl 2}z.luva_serif fi ;
 draw luva_path ;
 labels(i,j,k,l)
 enddef ;
 
def draw_refl_parma_luva(suffix i,j,k,l) =
 % this draws a complete reflected parma luva
 rt x.i = w - straight_sidebar ; % intersection with stem
 top y.j = round(ex + o) ; % top
 lft x.k = round (x.i - luva_width) ; % right
 y.l = 0 ;% bottom
 draw_refl_luva(i,j,k,l)("parma",tp_bow_stem_y,
                            pq_bow_arch_x,
                            pq_bow_side_y,
                            pq_bow_end_x )
 enddef ;
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
beginchar("0",.8tinco_width#,ex#,0); "The tengwa number zero";
 pickup main_nib ;
 lft x1 = curve_sidebar = w - rt x3 ; x2 = .5[x1,x3 ] ;
 x4 = .2w ;
 top y2 = h ;
 y1 = .7h ; y3 = .55h ; y4 = 0 ;
 z1' = z1 + .03em*dir(penangle-90) ;
 draw z1'{dir(penangle+90)} .. z1 .. z2{right} .. z3{down} .. z4 ;
endchar ;
 
beginchar("1",.9tinco_width#,ex#,0) ; "The tengwa number one" ;
 pickup main_nib ;
 lft x1 = straight_sidebar = w - rt x2 ; top y1 = h = top y2 ;
 draw_bar(1,2,"r") ;
 x3 = x1 ; y3 = .4h = y5 ;
 x4 = .4w ; bot y4 = 0 - o ;
 rt x5 = .75w ;
 z5' = z5 + 0.05em*dir140 ;
 draw_telco(1,3,"t") ;
 draw z3{down} .. z4{right} .. z5 %%%.. z5' ;
endchar ;
 
beginchar("2",1.4tinco_width#,ex#,0) ; "The tengwa number two" ;
 pickup main_nib ;
 lft x1 = straight_sidebar = w - rt x3 ; top y1 = top y2 = top y3 = h ;
 draw_bar(1,3,"r") ;
 rt x2 = round(.9*.75tinco_width) ; x2 = x6 ;
 y4 = y6 = y8 = .4h ;
 bot y5 = bot y7 = 0 ;
 x8 - x6 = x6 - x4 ;
 x5 = .4*.9tinco_width ;  x4 = x1 ;
 x5 - x4 = x7 - x6 ;
 z8' = z8 + 0.05em*dir140 ;
 draw_telco(1,4,"t") ; draw z2 -- z6 ;
 draw z4{down} .. z5{right} .. z6 ;
 draw z6{down} .. z7{right} .. z8 %%%.. z8' ;
endchar ;
 
beginchar("3",1.9tinco_width#,ex#,0) ; "The tengwa number three" ;
 pickup main_nib ;
 lft x1 = straight_sidebar = w - rt x3 ;
 top y1 = top y2 = top y2' = top y3 = h ;
 draw_bar(1,3,"r") ;
 rt x2 = round(.9*.75tinco_width) ; x2 = x6 ;
 x2' = x8 ;
 y4 = y6 = y8 = y10 = .4h ;
 bot y5 = bot y7 = bot y9 = 0 ;
 x8 - x6 = x6 - x4 = x10 - x8 ;
 x5 = .4*.9tinco_width ;  x4 = x1 ;
 x5 - x4 = x7 - x6 = x9 - x8 ;
 z10' = z10 + 0.05em*dir140 ;
 draw_telco(1,4,"t") ; draw z2 -- z6 ; draw z2' -- z8 ;
 draw z4{down} .. z5{right} .. z6 ;
 draw z6{down} .. z7{right} .. z8 ;
 draw z8{down} .. z9{right} .. z10 %%%.. z10' ;
endchar ;
 
beginchar("4",.9tinco_width#,asc#,desc#) ; "The tengwa number four" ;
 pickup main_nib ;
 lft x1 = straight_sidebar = w - rt x2 ; top y1 = round ex = top y2 ;
 x1' = x1 ; top y1' = h ;
 %%draw_bar(1,2,"r") ;
 x3 = x1 ; top y3 = 0 = y5 ;
 x4 = .4w ; bot y4 = vround(-.7d-o) ;
 rt x5 = .85w ;
 z5' = z5 + 0.05em*dir140 ;
 draw_telco(1',3,"t") ;
 draw z3{down} .. z4{right} .. z5 %%%%.. z5' ;
endchar ;
 
beginchar("5",1.4tinco_width#,asc#,desc#) ; "The tengwa number five" ;
 pickup main_nib ;
 lft x1 = straight_sidebar = w - rt x3 ;
 x1' = x1 ; top y1' = h ;
 top y1 = top y2 = top y3 = round ex ;
 draw_bar(1,3,"r") ;
 rt x2 = round(.9*.75tinco_width) ; x2 = x6 ;
 top y4 = -.1d ; y6 = y8 = .4ex ;
 bot y5 = vround(-.7d-o) ; bot y7 = 0 ;
 x8 - x6 = x6 - x4 ;
 x5 = .4*.9tinco_width ;  x4 = x1 ;
 x5 - x4 = x7 - x6 ; x5' = .5[x4,x7] ; y5' = y5 ;
 z8' = z8 + 0.05em*dir140 ;
 draw_telco(1',4,"t") ; draw z2 -- z6 ;
 draw z4{down} .. z5'{right} ... z7 ;
 draw z6{down} .. z7{right} .. z8 %%%.. z8' ;
endchar ;
 
beginchar("6",1.9tinco_width#,asc#,desc#) ; "The tengwa number six" ;
 pickup main_nib ;
 lft x1 = straight_sidebar = w - rt x3 ;
 x1' = x1 ; top y1' = h ;
 top y1 = top y2 = top y3 = round ex ;
 draw_bar(1,3,"r") ;
 rt x2 = round(.9*.75tinco_width) ; x2 = x6 ;
 x2' - x2 = x2 - x1 ; y2' = y2 ;
 top y4 = -.1d ; y6 = y8 = y10 = .4ex ;
 bot y5 = vround(-.7d-o) ; bot y7 = bot y9 = 0 ;
 x8 - x6 = x6 - x4 = x10 - x8 ;
 x5 = .4*.9tinco_width ;  x4 = x1 ;
 x5 - x4 = x7 - x6 = x9 - x8 ; x5' = .5[x4,x7] ; y5' = y5 ;
 z8' = z8 + 0.05em*dir140 ;
 draw_telco(1',4,"t") ; draw z2 -- z6 ; draw z2' -- z8 ;
 draw z4{down} .. z5'{right} ... z7 ;
 draw z6{down} .. z7{right} .. z8 ; %%%.. z8' ;
 draw z8{down} .. z9{right} .. z10 ;
endchar ;
 
beginchar("7",.9parma_width#,ex#,desc#); "The tengwa number 7";
 pickup main_nib ;
 lft x1 = straight_sidebar ;
 x5 = x1+hround(.6parma_width) ;  top y5 = asc ; % top of stem
 x6 = x5 ; y6 = 0 ; % bottom of stem
 draw_telco(5,6)("t") ;
 lft x9 = curve_sidebar ; top y9 = -.3d ;
 x10 = .5[x6,x9] ; bot y10 = vround(-d-o) ;
 x6' = x6 ; y6' = -.3d ;
 draw z6 .. z6'{down} .. z10{left} .. z9 ;
 endchar ;
 
 
def draw_number_luva(suffix i,j,k,l) =
 % this draws a complete number luva
 lft x.i = hround(.6parma_width) + straight_sidebar ; % intersection with stem
 top y.j = round(ex + o) ; % top
 rt x.k = round (x.i + luva_width) ; % right
 y.l = 0 ;% bottom
 draw_luva(i,j,k,l)("parma",tp_bow_stem_y,
                            pq_bow_arch_x,
                            pq_bow_side_y,
                            pq_bow_end_x )
 enddef ;
 
beginchar("8",1.6parma_width#,ex#,desc#); "The tengwa number 8";
 pickup main_nib ;
 draw_number_luva(1,2,3,4) ;
 x5 = x1 ;  top y5 = asc ; % top of stem
 x6 = x5 ; y6 = 0 ; % bottom of stem
 draw_telco(5,6)("t") ;
 x7 = x5 ; y7 = good.y o = y8 ; x8 = x3 + 0.05em ; % N.B. praps bot y7 = bot y8 = 0
 draw_bar(7,8)("r") ;
 lft x9 = curve_sidebar ; top y9 = -.1d ;
 x10 = .5[x5,x9] ; bot y10 = vround(-d-o) ;
 x6' = x6 ; y6' = -.3d ;
 draw z6 .. z6'{down} .. z10{left} .. z9 ;
 endchar ;
 
def draw_double_number_luva(suffix i,j,k,l,ii,jj,kk,ll) =
 % this draws a complete umbar luva
 % first bow
 lft x.i = hround(.6parma_width)+straight_sidebar ; % intersection with stem
 top y.j = round(ex + o) ; % top
 rt x.k = round (x.i + luva_width) ; % right
 y.l = 0 ;% bottom
 draw_luva(i,j,k,l)("parma",tp_bow_stem_y,
                            pq_bow_arch_x,
                            pq_bow_side_y,
                            pq_bow_end_x ) ;
 %second bow
 z.second = ( (x.i+pt,y.i) .. (infinity,y.i) ) intersectionpoint luva_path ;
 x.ii = good.x (xpart z.second) ;
 y.jj = y.j ;
 rt x.kk = round (x.ii + luva_width) ; % right
 y.ll = y.l ;
 draw_luva(ii,jj,kk,ll)("parma",tp_bow_stem_y,
                            pq_bow_arch_x,
                            pq_bow_side_y,
                            pq_bow_end_x )
 enddef ;
 
beginchar("9",2.25parma_width#,ex#,desc#); "The tengwa number 9";
 pickup main_nib ;
 draw_double_number_luva(1,2,3,4,9,10,11,12) ;
 x5 = x1 ;  top y5 = asc ; % top of stem
 x6 = x5 ; y6 = 0 ; % bottom of stem
 draw_telco(5,6)("t") ;
 x7 = x5 ; y7 = good.y o = y8 ; x8 = x11 + 0.05em ;
 draw_bar(7,8)("r") ;
 lft x13 = curve_sidebar ; top y13 = -.1d ;
 x14 = .5[x5,x13] ; bot y14 = vround(-d-o) ;
 x6 = x6' ; y6' = -.3d ;
 draw z6 .. z6'{down} .. z14{left} .. z13 ;
 endchar ;
 
beginchar("+",0.9*tinco_width#,asc#,0) ; "The tengwa number 10" ;
 pickup main_nib ;
 rt x4 = w - curve_sidebar ; y4 = 0.65ex ; % right side of bow
 bot y3 = round(-o) ; x3 = good.x 0.5w ; % bottom
 x2 = w - x4 ; y2 = 0.45ex ; % left side of bow
 x1 = good.x 0.3w ; y1 = 0.7ex ; % end of bow
 z1' = z1 + 0.03em*dir(10) ; % serif
 x5 = 0.25w ; y5 = 0.95asc ; % top end of letter
 z6 = z5 + 0.05em*(dir(penangle+80)) ; % for serif
 draw z1'{dir(180+penangle)} .. z1 .. z2 .. z3
   .. z4{up} .. tension 0.9 and 3 .. z5 ;
 labels(1,1',2,3,4,5,6) ;
endchar ;
 
beginchar("-",0.85tinco_width#,asc#,desc#) ; "The tengwa number" ;
 pickup main_nib ;
 numeric t[] ;
 % top bow first - make a path for later use
 x1 = 0.25w ; y1 = 0.95asc ; % top
 z1' = z1 + 0.05em*dir(penangle+80) ; % serif
 rt x2 = w - curve_sidebar ; y2 = 0.5h ; % right side of top bow ;
 x3 = 0.5w ; y3 = good.y 0.2h ; % bottom of top bow
 x4 = 0.3w ; y4 = 0.5h ; % end of bow
 z4' = z4 + 0.03em*dir(10) ; % serif
 path p ;
 p = z4'{dir(penangle+180)} .. z4 .. z3{right} .. z2{up} ..
       tension 0.9 and 2.5 .. z1 ;
 draw p ;
 x5' = x1 ; y5'-y7 = y1-y3 ; % top of bottom bow
 x6 = x2 ; y6 - y7 = y2 - y3 ; % side
 x7 = x3 ; bot y7 = round(-0.9desc) ; % bottom
 z8 - z7 = z4 - z3 ; % end
 z8' - z8 = z4' - z4 ;
 path pa ;
 pa = z8'{dir(penangle+180)} .. z8 .. z7{right} .. z6{up} ..
        tension 0.9 and 1.3 .. z5' ;
 (t1,t2) = p intersectiontimes pa ;
 draw subpath(0,t2) of pa ;
 labels(1,2,3,4,5,6,7,8) ;
endchar ;
 
beginchar("/",0.9*tinco_width#,ex#,desc#); "The tengwa number 12";
 pickup main_nib ;
 lft x2 = curve_sidebar ; y2 = 0.6 ex ; % left
 top y3 = round(ex+o) ; x3 = 0.55w ; % top
 rt x4 = w - curve_sidebar ; y4 = 0.4 ex ;
 x1 = x2 + 0.45w ; y1 = 0.2 ex ; % curly end
 x5 = x2 ; y5 = -0.9desc ;
 draw z1{dir(penangle+180)} .. z2{up} .. z3{right} ..
        z4{down} .. tension 3 .. z5 ;
 labels(1,2,3,4,5) ;
endchar ;
 
beginchar("{",0.2em#,1.5ex#,0) ; "The circle-over tehta" ;
 pickup tehta_nib ;
 x1 = x3 = good.x .5w ; bot y3 = vround(1.3ex) ;
 y1 = y3 + vround .45ex ; y1 - y3 = x2 - x4 ;
 y2 = y4 = .5[y1,y3] ; x1 = .5[x2,x4] ;
 draw z1 .. z2 .. z3 .. z4 .. cycle ;
endchar ;
 
beginchar("}",0.2em#,0,desc#) ; "The circle-over tehta" ;
 pickup tehta_nib ;
 x1 = x3 = good.x .5w ; top y1 = vround -.3ex ;
 y1 = y3 + vround .45ex ; y1 - y3 = x2 - x4 ;
 y2 = y4 = .5[y1,y3] ; x1 = .5[x2,x4] ;
 draw z1 .. z2 .. z3 .. z4 .. cycle ;
endchar ;
 
 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
beginchar(28,parma_width#,ex#,desc#); "Reflected parma"; % ^^\
 pickup main_nib ;
 draw_refl_parma_luva(1,2,3,4) ;
 x5 = x1 ;  top y5 = ex ; % top of stem
 x6 = x5 ; bot y6 = -desc ; % bottom of stem
 draw_telco(5,6)("tb") ;
 x7 = x5 ; y7 = good.y o = y8 ; x8 = x3 - 0.05em ; % N.B. praps bot y7 = bot y8 = 0
 draw_bar(7,8)("r") ;
 endchar ;
 
beginchar(29,parma_width#,ex#,0); "Reflected formen";
 pickup main_nib ;
 draw_refl_parma_luva(1,2,3,4) ;
 x5 = x1 ;  top y5 = asc ; % top of stem
 x6 = x5 ; y6 = 0 ; % bottom of stem
 draw_telco(5,6)("t") ;
 x7 = x5 ; y7 = good.y o = y8 ; x8 = x3 - 0.05em ; % N.B. praps bot y7 = bot y8 = 0
 draw_bar(7,8)("r") ;
 endchar ;
 
beginchar("(",0.4em#,asc#,0) ; "Left paren" ;
 pickup main_nib ;
 top y1 = round asc ; bot y3 = 0 ; y2 = 1/2[y1,y3] ;
 lft x2 = straight_sidebar = w - rt x1 = w - rt x3 ;
 draw z1 .. z2 .. z3 ;
endchar ;
 
beginchar(")",0.4em#,asc#,0) ; "Right paren" ;
 pickup main_nib ;
 top y1 = round asc ; bot y3 = 0 ; y2 = 1/2[y1,y3] ;
 lft x1 = lft x3 = straight_sidebar = w - rt x2 ;
 draw z1 .. z2 .. z3 ;
endchar ;
 
beginchar("`",0.5em#,ex#,0) ; "Left guillemet" ;
 pickup tehta_nib ;
 y2 = 0.6ex = 1/2[y1,y3] ;
 y1 - y3 = 0.4ex ;
 lft x2 = straight_sidebar = w - rt x1 - 0.2em ; x1 = x3 ;
 draw z1 .. z2 .. z3 ;
 forsuffixes i=1,2,3: x.i' = x.i + round(0.2em) ; y.i' = y.i ; endfor ;
 draw z1' .. z2' .. z3' ;
endchar ;
 
beginchar("'",0.5em#,ex#,0) ; "Right guillemet" ;
 pickup tehta_nib ;
 y2 = 0.6ex = 1/2[y1,y3] ;
 y1 - y3 = 0.4ex ;
 rt x2 = w - straight_sidebar = w - lft x1 + 0.2em ; x1 = x3 ;
 draw z1 .. z2 .. z3 ;
 forsuffixes i=1,2,3: x.i' = x.i - round(0.2em) ; y.i' = y.i ; endfor ;
 draw z1' .. z2' .. z3' ;
endchar ;
 
end.