% tipatone.mf: TIPA symbols for tone letters and other suprasegmentals
% Copyright 1996-2003 FUKUI Rei
%
% This program may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
% This program consists of all files listed in Manifest.txt.
%
% Version 1.2 2003/01/01
%

def tone_bar(suffix $, $$)(expr start_y, end_y) =
 adjust_fit(0,0); pickup if serifs: rule.nib; else: hair_rule.nib; fi
 x$ = 0; x$$ = w; % lft, rt are not used for adjusting tone letters.
 y$ = start_y; y$$ = end_y; % same thing for not using top, bot.
 draw z$--z$$;
 penlabels($,$$); enddef;

def long_width = 6u enddef;
def short_width = 4u enddef;

numeric ipacode;
ipacode := 127;

cmchar "Tone letter: long level tone";
beginchar(incr ipacode,long_width#,0,0);
tone_bar(1,2,0,0); endchar;

cmchar "Tone letter: long falling tone (1)";
beginchar(incr ipacode,long_width#,1/4asc_height#,0);
tone_bar(1,2,h,0); endchar;

cmchar "Tone letter: long falling tone (2)";
beginchar(incr ipacode,long_width#,2/4asc_height#,0);
tone_bar(1,2,h,0); endchar;

cmchar "Tone letter: long falling tone (3)";
beginchar(incr ipacode,long_width#,3/4asc_height#,0);
tone_bar(1,2,h,0); endchar;

cmchar "Tone letter: long falling tone (4)";
beginchar(incr ipacode,long_width#,asc_height#,0);
tone_bar(1,2,h,0); endchar;

cmchar "Tone letter: long rising tone (1)";
beginchar(incr ipacode,long_width#,1/4asc_height#,0);
tone_bar(1,2,0,h); endchar;

cmchar "Tone letter: long rising tone (2)";
beginchar(incr ipacode,long_width#,2/4asc_height#,0);
tone_bar(1,2,0,h); endchar;

cmchar "Tone letter: long rising tone (3)";
beginchar(incr ipacode,long_width#,3/4asc_height#,0);
tone_bar(1,2,0,h); endchar;

cmchar "Tone letter: long rising tone (4)";
beginchar(incr ipacode,long_width#,asc_height#,0);
tone_bar(1,2,0,h); endchar;

cmchar "Tone letter: short level tone";
beginchar(incr ipacode,short_width#,0,0);
tone_bar(1,2,0,0); endchar;

cmchar "Tone letter: short falling tone (1)";
beginchar(incr ipacode,short_width#,1/4asc_height#,0);
tone_bar(1,2,h,0); endchar;

cmchar "Tone letter: short falling tone (2)";
beginchar(incr ipacode,short_width#,2/4asc_height#,0);
tone_bar(1,2,h,0); endchar;

cmchar "Tone letter: short falling tone (3)";
beginchar(incr ipacode,short_width#,3/4asc_height#,0);
tone_bar(1,2,h,0); endchar;

cmchar "Tone letter: short falling tone (4)";
beginchar(incr ipacode,short_width#,asc_height#,0);
tone_bar(1,2,h,0); endchar;

cmchar "Tone letter: short rising tone (1)";
beginchar(incr ipacode,short_width#,1/4asc_height#,0);
tone_bar(1,2,0,h); endchar;

cmchar "Tone letter: short rising tone (2)";
beginchar(incr ipacode,short_width#,2/4asc_height#,0);
tone_bar(1,2,0,h); endchar;

cmchar "Tone letter: short rising tone (3)";
beginchar(incr ipacode,short_width#,3/4asc_height#,0);
tone_bar(1,2,0,h); endchar;

cmchar "Tone letter: short rising tone (4)";
beginchar(incr ipacode,short_width#,asc_height#,0);
tone_bar(1,2,0,h); endchar;

cmchar "Vertical line (minor group)";
beginchar(incr ipacode,CT(5u#,5.56u#),body_height#,paren_depth#);
italcorr body_height#*slant+.5rule_thickness#-2u#;
adjust_fit(0,0);
numeric thickness; thickness=hround.6[hair,stem];
pickup tiny.nib; pos1(thickness,0); pos2(thickness,0);
lft x1l = lft x2l = hround(.5w-.5thickness);
top y1=h+eps; bot y2=-d-eps;
filldraw stroke z1e--z2e;
penlabels(1,2); endchar;

cmchar "Double vertical line (Major group)";
beginchar(incr ipacode,CT(9u#,10u#),body_height#,paren_depth#);
italcorr body_height#*slant+.5rule_thickness#-2u#;
adjust_fit(0,0);
numeric thickness; thickness=hround(.6[hair,stem]-2stem_corr);
pickup tiny.nib; pos1(thickness,0); pos2(thickness,0);
pos3(thickness,0); pos4(thickness,0);
x1=x2; x3=x4=w-x1; lft x1l = hround((w-3.5u-thickness)/2);
top y1=top y3=h+eps; bot y2=bot y4=-d-eps;
filldraw stroke z1e--z2e; filldraw stroke z3e--z4e;
penlabels(1,2,3,4); endchar;

cmchar "Down arrow (Downstep)";
beginchar(incr ipacode,8u#,body_height#,0);
italcorr .76body_height#*slant+.5crisp#-u#;
adjust_fit(0,0); pickup crisp.nib;
pos1(rule_thickness,0); pos2(rule_thickness,0);
pos3(rule_thickness,90); pos4(rule_thickness,90);
lft x1l=hround(.5w-.5rule_thickness); y1+.5rule_thickness=h;
x0=x1=x2; bot y0=bar_height; x0-x3=x4-x0=if monospace:2.5u else:2.5u fi+eps;
y3=y4=y0+if monospace:.24 else:.27 fi asc_height+eps;
pos5(rule_thickness,angle(z4-z0)); z5l=z0;
pos6(rule_thickness,angle(z3-z0)); z6l=z0;
z9=.2[.5[z3,z4],z0];
numeric t; path p; p=z4r{z9-z4}..z6r;
t=xpart(p intersectiontimes((x2r,-d)--(x2r,h))); y2=ypart point t of p;
filldraw z0..{z4-z9}z4l--subpath (0,t) of\\(z4r{z9-z4}..z6r)
 --z2r---z1r..z1l---z2l--subpath (t,0) of\\(z3r{z9-z3}..z5r)
 --z3l{z9-z3}..z0 & cycle;  % arrowhead and stem
penlabels(0,1,2,3,4,5,6,9); endchar;

cmchar "Up arrow (Upstep)";
beginchar(incr ipacode,8u#,body_height#,0);
italcorr .76body_height#*slant+.5crisp#-u#;
adjust_fit(0,0); pickup crisp.nib;
pos1(rule_thickness,0); pos2(rule_thickness,0);
pos3(rule_thickness,90); pos4(rule_thickness,90);
lft x1l=hround(.5w-.5rule_thickness); y1-.5rule_thickness=bar_height;
x0=x1=x2; top y0=h; x0-x3=x4-x0=if monospace:2.5u else:2.5u fi+eps;
y3=y4=y0-if monospace:.24 else:.27 fi asc_height-eps;
pos5(rule_thickness,angle(z4-z0)); z5l=z0;
pos6(rule_thickness,angle(z3-z0)); z6l=z0;
z9=.2[.5[z3,z4],z0];
numeric t; path p; p=z4l{z9-z4}..z6r;
t=xpart(p intersectiontimes((x2r,-d)--(x2r,h))); y2=ypart point t of p;
filldraw z0..{z4-z9}z4r--subpath (0,t) of\\(z4l{z9-z4}..z6r)
 --z2r---z1r..z1l---z2l--subpath (t,0) of\\(z3l{z9-z3}..z5r)
 --z3r{z9-z3}..z0 & cycle;  % arrowhead and stem
penlabels(0,1,2,3,4,5,6,9); endchar;

cmchar "Northeast arrow (Global rise)";
beginchar(incr ipacode,14u#,asc_height#,0);
adjust_fit(0,0); pickup crisp.nib;
x1-.5rule_thickness=hround u; rt x0=hround(w-u);
y1-.5rule_thickness=-d; top y0=h;
numeric theta; theta=angle(z0-z1);
pos1(rule_thickness,90+theta); pos2(rule_thickness,90+theta);
pos3(rule_thickness,theta); pos4(rule_thickness,theta);
z3-z0=(-3u,.27asc_height) rotated theta;
z4-z0=(-3u,-.27asc_height) rotated theta;
pos5(rule_thickness,-90); z5l=z0; pos6(rule_thickness,-180); z6l=z0;
z9=.2[.5[z3,z4],z0];
numeric t; path p; p=z4l{z9-z4}..z6r;
t=xpart(p intersectiontimes (z1l--(z1l+2(z0-z1)))); z2l=point t of p;
filldraw z0..{z4-z9}z4r--subpath (0,t) of\\(z4l{z9-z4}..z6r)
 --z2l---z1l..z1r---z2r--subpath (t,0) of\\(z3l{z9-z3}..z5r)
 --z3r{z9-z3}..z0 & cycle;  % arrowhead and stem
penlabels(0,1,2,3,4,5,6,9); endchar;

cmchar "Southeast arrow (global fall)";
beginchar(incr ipacode,14u#,asc_height#,0);
adjust_fit(0,0); pickup crisp.nib;
x1-.5rule_thickness=hround u; rt x0=hround(w-u);
y1+.5rule_thickness=h; bot y0=-d;
numeric theta; theta=angle(z0-z1);
pos1(rule_thickness,90+theta); pos2(rule_thickness,90+theta);
pos3(rule_thickness,theta); pos4(rule_thickness,theta);
z3-z0=(-3u,.27asc_height) rotated theta;
z4-z0=(-3u,-.27asc_height) rotated theta;
pos5(rule_thickness,180); z5l=z0; pos6(rule_thickness,90); z6l=z0;
z9=.2[.5[z3,z4],z0];
numeric t; path p; p=z4l{z9-z4}..z6r;
t=xpart(p intersectiontimes (z1l--(z1l+2(z0-z1)))); z2l=point t of p;
filldraw z0..{z4-z9}z4r
 --subpath (0,t) of\\(z4l{z9-z4}..z6r)
 --z2l---z1l..z1r---z2r
 --subpath (t,0) of\\(z3l{z9-z3}..z5r)
 --z3r{z9-z3}..z0 & cycle;  % arrowhead and stem
penlabels(0,1,2,3,4,5,6,9); endchar;

cmchar "Mid acute accent";
beginchar(oct"230",9u#,min(asc_height#,2x_height#),0);
italcorr h#*slant-u#;
adjust_fit(0,0); pickup tiny.nib;
numeric accent.stem, accent.hair;
accent.stem = max(.8stem,hair);
accent.hair = max(.6stem,hair);
y1 = y2; x1 = hround(1.5u+.5accent.stem); x2 = x4;
pos1(accent.hair,-90); pos2(accent.hair,-90);
if serifs: pickup tiny.nib;
 x3+.5accent.stem=hround(w-1.5u); x3-x4=1.8u; y2 = y4;
 y3+.5accent.stem=h; top y4'l=vround(.4[x_height,asc_height])+o;
 y4=y4'; pos4'(accent.hair,-90);
 numeric theta; theta=angle(z4-z3)+90;
 pos3(accent.stem,theta); pos4(accent.hair,theta);
 filldraw stroke z1e--z2e;  % bar
 filldraw circ_stroke z3e--z4e;  % right diagonal
else: pickup fine.nib;
 pos3(stem,0); pos4(accent.hair,0); bot y2r = bot y4;
 rt x3r=hround(w-1.5u); rt x4r=hround(rt x3r-1.8u);
 top y3=h; top y2l=vround(.4[x_height,asc_height])+o;
 filldraw stroke z1e--z2e; % bar
 filldraw stroke z3e--z4e; fi   % right diagonal
penlabels(1,2,3,4); endchar;

cmchar "Grave mid accent";
beginchar(oct"231",9u#,min(asc_height#,2x_height#),0);
italcorr h#*slant-u#;
adjust_fit(0,0); pickup tiny.nib;
numeric accent.stem, accent.hair;
accent.stem = max(.8stem,hair);
accent.hair = max(.6stem,hair);
y1 = y2; x1 = hround(w-1.5u-.5accent.stem); x2 = x4;
pos1(accent.hair,-90); pos2(accent.hair,-90);
if serifs: pickup tiny.nib;
 x3-.5accent.stem=hround(1.5u); x4-x3=1.8u; y2 = y4;
 y3+.5accent.stem=h; top y4'r=vround(.4[x_height,asc_height])+o;
 y4=y4'; pos4'(accent.hair,90);
 numeric theta; theta=angle(z4-z3)+90;
 pos3(accent.stem,theta); pos4(accent.hair,theta);
 filldraw stroke z1e--z2e;  % bar
 filldraw circ_stroke z3e--z4e;  % right diagonal
else: pickup fine.nib;
 pos3(stem,0); pos4(accent.hair,0); bot y2r = bot y4;
 lft x3l=hround(1.5u); lft x4l=hround(lft x3l+1.8u);
 top y3=h; top y2l = vround(.4[x_height,asc_height])+o;
 filldraw stroke z1e--z2e; % bar
 filldraw stroke z3e--z4e; fi   % right diagonal
penlabels(1,2,3,4); endchar;

cmchar "Rising-falling accent";
beginchar(oct"232",9u#,min(asc_height#,2x_height#),0);
italcorr h#*slant-u#;
adjust_fit(0,0); pickup tiny.nib;
numeric accent.stem, accent.hair;
accent.stem = max(.8stem,hair);
accent.hair = max(.5stem,hair);
if serifs: pickup tiny.nib;
 x2-x1=x6-x5=2.2u; x2=x4; x3=x5; x1=1.2u; x6=w-1.2u;
 y1=y3=y5=h-.5accent.stem;
 y2=y4=y6=vround(max(2/3[h,x_height],x_height+o+hair));
 numeric theta; theta=angle(z1-z2)+90;
 pos1(accent.stem,theta); pos2(accent.hair,theta);
 pos3(accent.stem,180-theta); pos4(accent.hair,180-theta);
 pos5(accent.stem,theta); pos6(accent.hair,theta);
 full_circ_stroke(1,2);
 full_circ_stroke(3,4);
 full_circ_stroke(5,6);
else: pickup fine.nib;
 x2-x1=x6-x5=2.2u; x2=x4; x3=x5; x1=1.2u; x6=w-1.2u;
 top y1=top y3=top y5=h; bot y2=bot y4=bot y6=vround 2/3[h,x_height];
 pos1(stem,0); pos2(accent.hair,0);
 pos3(stem,0); pos4(accent.hair,0);
 pos5(stem,0); pos6(accent.hair,0);
 filldraw stroke z1e--z2e;
 filldraw stroke z3e--z4e;
 filldraw stroke z5e--z6e; fi
penlabels(1,2,3,4,5,6); endchar;

cmchar "Falling-rising accent";
beginchar(oct"233",9u#,min(asc_height#,2x_height#),0);
italcorr h#*slant-u#;
adjust_fit(0,0); pickup tiny.nib;
numeric accent.stem, accent.hair;
accent.stem = max(.8stem,hair);
accent.hair = max(.5stem,hair);
if serifs: pickup tiny.nib;
 x1-x2=x5-x6=2.2u; x1=x3; x4=x6; x2=1.2u; x5=w-1.2u;
 y1=y3=y5=h-.5accent.stem;
 y2=y4=y6=vround(max(2/3[h,x_height],x_height+o+hair));
 numeric theta; theta=angle(z1-z2)+90;
 pos1(accent.stem,theta); pos2(accent.hair,theta);
 pos3(accent.stem,180-theta); pos4(accent.hair,180-theta);
 pos5(accent.stem,theta); pos6(accent.hair,theta);
 full_circ_stroke(1,2);
 full_circ_stroke(3,4);
 full_circ_stroke(5,6);
else: pickup fine.nib;
 x1-x2=x5-x6=2.2u; x1=x3; x4=x6; x2=1.2u; x5=w-1.2u;
 top y1=top y3=top y5=h; bot y2=bot y4=bot y6=vround 2/3[h,x_height];
 pos1(stem,0); pos2(accent.hair,0);
 pos3(stem,0); pos4(accent.hair,0);
 pos5(stem,0); pos6(accent.hair,0);
 filldraw stroke z1e--z2e;
 filldraw stroke z3e--z4e;
 filldraw stroke z5e--z6e; fi
penlabels(1,2,3,4,5,6); endchar;

% end of tipatone.mf
