% File:       MF Inputs gribyacc.mf
% Author:     Pierre A. MacKay
% Internet:   mackay@cs.washington.edu
% Date:       Friday, 06 May 1994
% Copyright 1994 by Pierre A. MacKay
% The contents of this file are licensed free for
% use and redistribution under the terms of the  
% GNU General Public License.  For the terms of  
% this license see any publication of the Free   
% Software Foundation or any software packages   
% distributed by the Free Software Foundation.   
% 
% Make sure the macros we want to replace are loaded
if unknown gen_acc : readfrom("gen_acc") fi

% Improve spacing with barytone accent.

vardef spirit_grave(expr center) text type =
numeric sp_bottom, sp_height;
sp_bottom=h-sp_height=max(.8[h,x_height],x_height+o+separator);
numeric dot_diam#; dot_diam# = 3/4dot_size#;
define_whole_blacker_pixels(dot_diam);
dot_diam:=max(fine.breadth,min(dot_diam,floor(2/3sp_height)));
if serifs: x22-x21=1/6w; x21-.5stem=hround(center+.25u);
else: rt x22r=hround (4/5w+.5stem); lft x21l=hround(center+.25u); fi
generate_grave; penlabels(21,22);
% In the original, the following spacing adjustments tracked |spirit_acute|.
% This was wrong way round.  When the accent is barytone, lft x21l is nowhere
% near the left edge of the picture, and the crowding effect is the reverse
% of what it is with the oxytone accent.  Added an extra .15u to make
% up for the first problem, and an extra .45u to relieve the crowding
% against the smooth breathing.
if 1type0: %spirit and accent separated by .65u (rough) or .85u (smooth)
 x31=hround(lft x21l-.5 if serifs:sp_height else:dot_diam fi -.45u);
else: x31+.5dot_diam=hround(lft x21l-.65u); fi
y31+.5dot_diam=h;
if1type0:smooth else:rough fi (31,a,dot_diam,sp_height,0);
enddef;

% Reshape the iota subscript, but only for resolutions above 600
% Thin it out so that it can have a slight hook while remaining
% within the outline of the original simple form.
def iota_sub(expr pos_stem) =
if known pic.iota:
  addto currentpicture also pic.iota shifted (hround(pos_stem),0);
else:
  picture temp_picture; temp_picture=currentpicture; clearit;
  pickup fine.nib;
  x51=0; pos51(stem,180); top y51=vround(-o-2separator);
  x52=x51; pos52(stem,180); bot y52=-iota_dp;
  % Use the original simple subscript for lower resolutions.
  if ( ((pixels_per_inch / mag) < 599) or (pixels_per_inch < 420) ) :
    filldraw circ_stroke z52e--z51e;
  else :
    % iota subscript in same space but with narrower stem and slight hook
    pos51'(.4[hair,stem],180); pos51''(.4[hair,stem],180);
    pos52'(.4[hair,stem],270); pos53'(.3[hair,stem],0);
    x51'r = x51''r = x51r; 
    bot y52'r = -iota_dp; x53'r = x51l; x52' = 1/2[x51',x53'];
    y51' = y51; top y53' = 4/5[y51,y52]; 
    y51'' = y53';
    filldraw double_circ_stroke z51'e--z51''e..z52'e..z53'e;
  fi;
  if not working_hard : picture pic.iota; pic.iota=currentpicture; fi
  currentpicture:=currentpicture shifted (hround(pos_stem),0);
  addto currentpicture also temp_picture;
fi;
enddef;

% Raise the spirit_circumflex 
% to give more room to the breathing under it

Circ_ht#:=body_height#;

% Move two accents out of the way of Ibycus
% Xi and digamma, and recode perispomenon into
% ASCII"="

def selectaccent expr t =
  currenttitle:= t;
  if t = "Diaeresis with circumflex" : let next_ = lose_it_
  elseif t = "Rough breathing with grave" : 
    code_offset := asper_bary - ASCII"C" ;  let next_ = use_it_
  elseif t = "Rough breathing with acute" : 
    code_offset := asper_oxy - ASCII"V" ;  let next_ = use_it_
  elseif t = "Smooth breathing with grave" : let next_ = lose_it_
  else: code_offset := 0 ; let next_ = use_it_ fi; next_ enddef;
let cmchar = selectaccent;
readfrom("graccent");

let cmchar = relax;

% Do lenis-barytone with corrected height.
cmchar "Smooth breathing with grave";
beginchar(lenis_bary,9u#,acc_ht#,0);
spirit_grave(.5w)>;
endchar;

% Takes the place of "Diaeresis with circumflex", which cannot occur.
% iota and upsilon only affected by diaeresis when short.
% This is useful for deligaturing sigma. with the  "s|" digraph.
% Besides, it can often help to have a zero-width character available.
cmchar "Zero-width Space";
beginchar(null_space, 0,0,0);
endchar;

