home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / pc / 0600 / CCE_0690.ZIP / CCE_0690.PD / YANNIS / RGEN_ACC.MF < prev    next >
Text File  |  1993-11-01  |  9KB  |  230 lines

  1. % This file contains some code from Computer Modern's accent.mf.
  2. % It defines all Greek diacritic marks.
  3.  
  4. gen_acc:=1;
  5.  
  6. def separator=max(1,vround(1/20x_height)) enddef;
  7.  
  8. def grave(expr center) =
  9. if serifs: x22-x21=1/4w; x21-.5stem=hround(center-2/3(x22-x21)-.5stem);
  10. else: lft x21l=hround (1/4w-.5stem); rt x22r=hround(center+.25u+.5vair); fi
  11. generate_grave; penlabels(21,22);
  12. enddef;
  13.  
  14. def acute(expr center) =
  15. if serifs: x21-x22=1/4w; x21+.5stem=hround(center+2/3(x21-x22)+.5stem);
  16. else: rt x21r=hround (3/4w+.5stem); lft x22l=hround(center-.25u-.5vair); fi
  17. generate_grave; penlabels(21,22);
  18. enddef;
  19.  
  20. vardef search(expr xyzzy) =
  21. pair p;ypart(p)=y22l;p-(x22,xyzzy)=whatever*((z21-(x22,xyzzy))rotated 90);
  22. length(p-(x22,xyzzy))>.5(hair-currentbreadth) enddef;
  23.  
  24. vardef generate_grave=
  25. if serifs: pickup crisp.nib;
  26.   y21+.5stem=h+eps; bot y22l=max(.8[h,x_height],x_height+o+separator);
  27.   y22=solve search(y21,y22l); x22l=xpart(p); z22r=2z22-z22l;
  28.   pos21(stem,angle(z22r-z22l));
  29.   filldraw circ_stroke z21e--z22e;  %  diagonal
  30. else: pickup fine.nib; pos21(stem,0); pos22(vair,0);
  31.   top y21=h; bot y22=vround .8[h,x_height];
  32.   filldraw stroke z21e--z22e; %  diagonal
  33. fi
  34. enddef;
  35.  
  36. def corr_circumflex(expr center,corr)=
  37. w:=w+corr; generate_circumflex(center,false);
  38. w:=w-corr;
  39. enddef;
  40.  
  41. def circumflex(expr center)=
  42. generate_circumflex(center,false);      % variable `squeeze'
  43. enddef;
  44.  
  45. def generate_circumflex(expr center,squeeze)=
  46. numeric mid_width; mid_width=if squeeze:.1 else: .5 fi [vair,stem];
  47. if serifs:
  48. pickup fine.nib; pos21(hround(mid_width-eps),180); pos22(vair,90);
  49.  pos23(mid_width,90); pos24(vair,90); pos25(hround(mid_width-eps),180);
  50.  lft x21r=w-rt x25l=hround (center-w/3); x22-x21=x23-x22=x24-x23=x25-x24;
  51.  bot y21=bot y24l=vround(.75[x_height,h]-vair);
  52.  top y22r=top y25=h; y23=.5[y22,y24];
  53.  filldraw stroke z21e{up}...z22e{right}..z23e..{right}z24e...{up}z25e;
  54. else:
  55.  pos21(vair,-180); pos23(vair,0); y21=y23;
  56.  lft x21r=hround(center-w/3); rt x23r=hround(center+w/3);
  57.  bot y23=vround max(x_height+o+separator,
  58.    if squeeze: 2/3 else: 1/3 fi [x_height,h]-.5mid_width);
  59.  x22=center; pos22(mid_width,90); top y22r=h;
  60.  filldraw stroke z21e{up}...z22e...{down}z23e;
  61. fi
  62. enddef;
  63.  
  64. vardef diaeresis(expr center)=
  65.   generate_diaeresis(center,dot_size,dot_size+1/8w,h,x_height+separator);
  66. enddef;
  67.  
  68. vardef diaeresis_acute(expr center)=
  69.   if serifs: x21-x22=1/4w; x21+.5stem=hround(center+5/6(x21-x22)+.5stem);
  70.   else: rt x21r=hround (3/4w+.5stem); lft x22l=hround(center-.5vair); fi
  71.   generate_grave; penlabels(21,22);
  72.   generate_diaeresis(center,.9dot_size,-1,.5[h,x_height],x_height+separator);
  73. enddef;
  74.  
  75. vardef diaeresis_grave(expr center)=
  76.   if serifs: x22-x21=1/4w; x21-.5stem=hround(center-5/6(x22-x21)-.5stem);
  77.   else: lft x21l=hround (1/4w-.5stem); rt x22r=hround(center+.5vair); fi
  78.   generate_grave; penlabels(21,22);
  79.   generate_diaeresis(center,.9dot_size,-1,.5[h,x_height],x_height+separator);
  80. enddef;
  81.  
  82. vardef diaeresis_circumflex(expr center)=
  83.   generate_circumflex(center,true);
  84.   numeric sp_bottom, sp_top;
  85.   sp_top=vround(.15[bot y21l,x_height]); sp_top+sp_bottom=bot y21l+x_height;
  86.   generate_diaeresis(center,5/8dot_size,5/8dot_size+1/4w,sp_top,sp_bottom);
  87. enddef;
  88.  
  89. vardef generate_diaeresis(expr center,target_dot_diam,sep,eff_h,base)=
  90. pickup tiny.nib; numeric dot_diam;
  91. dot_diam:=max(tiny.breadth,hround(target_dot_diam));
  92. pos31(dot_diam,0); pos32(dot_diam,90); x31=x32; top y32r=vround(eff_h);
  93. if bot y32l<base: y32l:=min(y32r-eps,base+.5currentbreadth); fi
  94. y31=.5[y32l,y32r];
  95. pos33(dot_diam,0); penpos34(y32r-y32l,90); y33=y34=y31; x33=x34;
  96. if sep>0 : center=.5[x31,x33]; x33-x31=sep;
  97. else:
  98.   y35l=y35r=.5[y31,y32]; z35l=whatever[z21l,z22l]; z35r=whatever[z21r,z22r];
  99.   rt x31r=hround((min(x35l,x35r)-.5currentbreadth)-.05w);
  100.   lft x33l=hround((max(x35l,x35r)+.5currentbreadth)+.05w);
  101. fi
  102. dot(31,32); dot(33,34);
  103. penlabels(31,32,33,34,35);
  104. enddef;
  105.  
  106. def rough(suffix $,@)(expr dot_size,depth,shear) =
  107.  pickup fine.nib; pos$(dot_size,90);
  108.  if square_dots: pos$'(dot_size,180); z$'=z$; dot($',$);  %  squarish dot
  109.   comma_join_:=max(fine.breadth,floor .7dot_size);
  110.   comma_bot_:=max(fine.breadth,floor .5dot_size);
  111.   pos@0(comma_join_,180); pos@1(comma_join_,180);
  112.   pos@2(comma_bot_,180); y@0=y$; y@1=y$l; y@2=y@1+dot_size-depth;
  113.   x@0r=x@1r=x$'r; lft x@2r=good.x(x$-eps);
  114.   filldraw stroke z@0e--z@1e..z@2e;  %  tail
  115.  else: pos@1(vair,90); pos@2(vair,180); pos@3(vair,-90);
  116.   z@1r=z$r; lft x@2r=hround(x$-.5depth+.5shear);
  117.   x@3+.5vair=x$+.5dot_size+shear;
  118.   y@2=.5[y@1,y@3]; bot y@3r=vround(top y@1r-depth);
  119.   y_:=ypart((z@1{left}...z@2{down}...z@3)
  120.    intersectiontimes (z$l{left}..{right}z$r)); if y_<0: y_:=1; fi
  121.   filldraw z$r{right}..subpath (0,y_) of (z$l{left}..{right}z$r)--cycle; %  dot
  122.   filldraw stroke z@1e{left}...z@2e{down}...{right}z@3e; fi  %  tail
  123.  penlabels(@1,@2,@3); enddef;
  124.  
  125. def smooth(suffix $,@)(expr dot_size,depth,shear) =
  126.  pickup fine.nib; pos$(dot_size,90);
  127.  if square_dots: pos$'(dot_size,0); z$'=z$; dot($',$);  %  squarish dot
  128.   comma_join_:=max(fine.breadth,floor .7dot_size);
  129.   comma_bot_:=max(fine.breadth,floor .5dot_size);
  130.   pos@0(comma_join_,0); pos@1(comma_join_,0);
  131.   pos@2(comma_bot_,0); y@0=y$; y@1=y$l; y@2=y@1+dot_size-depth;
  132.   x@0r=x@1r=x$'r; rt x@2r=good.x(x$-eps);
  133.   filldraw stroke z@0e--z@1e..z@2e;  %  tail
  134.  else: pos@1(vair,90); pos@2(vair,0); pos@3(vair,-90);
  135.   z@1r=z$r; rt x@2r=hround(x$+.5depth+.5shear);
  136.   x@3-.5vair=hround(x$-.5dot_size+shear);
  137.   y@2=.5[y@1,y@3]; bot y@3r=vround(top y@1r-depth);
  138.   y_:=ypart((z@1{right}...z@2{down}...z@3)
  139.    intersectiontimes (z$l{right}..{left}z$r)); if y_<0: y_:=1; fi
  140.   filldraw z$r{left}..subpath (0,y_) of (z$l{right}..{left}z$r)--cycle; %  dot
  141.   filldraw stroke z@1e{right}...z@2e{down}...{left}z@3e; fi  %  tail
  142.  penlabels(@1,@2,@3); enddef;
  143.  
  144. vardef spirit(expr center) text type=
  145. numeric sp_bottom, sp_height;
  146. sp_bottom=h-sp_height=max(.8[h,x_height],x_height+o+separator);
  147. numeric dot_diam#; dot_diam# = 3/4dot_size#;
  148. define_whole_blacker_pixels(dot_diam);
  149. dot_diam:=max(fine.breadth,min(dot_diam,floor(2/3sp_height)));
  150. x31 if1type0:-else:+fi.5dot_diam=hround(center if1type0:-else:+fi.5dot_diam);
  151. y31+.5dot_diam=h;
  152. if1type0:smooth else:rough fi (31,a,dot_diam,sp_height,0);
  153. penlabels(31);
  154. enddef;
  155.  
  156. vardef spirit_acute(expr center) text type =
  157. numeric sp_bottom, sp_height;
  158. sp_bottom=h-sp_height=max(.8[h,x_height],x_height+o+separator);
  159. numeric dot_diam#; dot_diam# = 3/4dot_size#;
  160. define_whole_blacker_pixels(dot_diam);
  161. dot_diam:=max(fine.breadth,min(dot_diam,floor(2/3sp_height)));
  162. if serifs: x21-x22=1/6w;
  163.  x21+.5stem=hround(center+.25u+.5vair+(x21-x22)+.5stem);
  164. else: rt x21r=hround (4/5w+.5stem); lft x22l=hround(center+.25u); fi
  165. generate_grave; penlabels(21,22);
  166. if 1type0: % spirit and accent separated by .5u (rough) or .25u (smooth)
  167.  x31=hround(lft x22 if serifs:r-.5sp_height else:l-.5dot_diam fi -.25u);
  168. else: x31+.5dot_diam=hround(lft x22 if serifs:r else: l fi -.5u); fi
  169. y31+.5dot_diam=h;
  170. if1type0:smooth else:rough fi (31,a,dot_diam,sp_height,0);
  171. enddef;
  172.  
  173. vardef spirit_grave(expr center) text type =
  174. numeric sp_bottom, sp_height;
  175. sp_bottom=h-sp_height=max(.8[h,x_height],x_height+o+separator);
  176. numeric dot_diam#; dot_diam# = 3/4dot_size#;
  177. define_whole_blacker_pixels(dot_diam);
  178. dot_diam:=max(fine.breadth,min(dot_diam,floor(2/3sp_height)));
  179. if serifs: x22-x21=1/6w; x21-.5stem=hround(center+.25u);
  180. else: rt x22r=hround (4/5w+.5stem); lft x21l=hround(center+.25u); fi
  181. generate_grave; penlabels(21,22);
  182. if 1type0: % spirit and accent separated by .5u (rough) or .25u (smooth)
  183.  x31=hround(lft x21l-.5 if serifs:sp_height else:dot_diam fi -.25u);
  184. else: x31+.5dot_diam=hround(lft x21l-.5u); fi
  185. y31+.5dot_diam=h;
  186. if1type0:smooth else:rough fi (31,a,dot_diam,sp_height,0);
  187. enddef;
  188.  
  189. vardef spirit_circumflex(expr center) text type=
  190. generate_circumflex(center,true);       % variable `squeeze'
  191. numeric sp_bottom, sp_height, sp_top, box_top;
  192. box_top=bot if serifs: y21l else: y22l fi;
  193. sp_top=sp_bottom+sp_height=vround(.15[box_top,x_height]);
  194. sp_top+sp_bottom=box_top+x_height;
  195. numeric dot_diam#; dot_diam# = 5/8dot_size#;
  196. define_whole_blacker_pixels(dot_diam);
  197. pickup fine.nib;
  198. dot_diam:=max(fine.breadth,min(dot_diam,floor(2/3sp_height-eps)));
  199. x31 if1type0:-else:+fi.5dot_diam=hround(center if1type0:-else:+fi.5dot_diam);
  200. y31+.5dot_diam=vround(sp_top);
  201. if1type0:smooth else:rough fi (31,a,dot_diam,sp_height,0);
  202. penlabels(31);
  203. enddef;
  204.  
  205. def iota_sub(expr pos_stem) =
  206. if known pic.iota:
  207.   addto currentpicture also pic.iota shifted (hround(pos_stem),0);
  208. else:
  209.   picture temp_picture; temp_picture=currentpicture; clearit;
  210.   pickup fine.nib;
  211.   x51=0; pos51(stem,180); top y51=vround(-o-2separator);
  212.   x52=x51; pos52(stem,180); bot y52=-iota_dp;
  213.   filldraw circ_stroke z52e--z51e;
  214. %  edw arqizei to diko mou
  215. % z54=z52;x53=x54+0.5(y51-y54); y53=y54;
  216. % pos54(stem,90); pos53(stem,90);
  217. % filldraw circ_stroke z54e---z53e;
  218. % lft x55=0.5(rt x52+x52); bot y55=0.5(y52-bot y52)+y52;
  219. % x56=x55;top y56=y51; pos55(stem,180); pos56(stem,180);
  220. % unfilldraw circ_stroke z55e--z56e;
  221.   if not working_hard : picture pic.iota; pic.iota=currentpicture; fi
  222.   currentpicture:=currentpicture shifted (hround(pos_stem),0);
  223.   addto currentpicture also temp_picture;
  224. fi;
  225. enddef;
  226.  
  227.