%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% File: mxdatoms.mf
% Date: November 5, 2001
% Author: Oliver Corff
% (c) 2001 Ulaanbaatar, Berlin
%
% A metafont for providing the Xewtee
% Dorboljin script to LaTeX-users.
%
% Usage: see package documentation mxd4tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def vowelcarrier =
	squarepen;
	top lft z1=(scribble+margin,height+scribble);
	bot	z2=(scribble+x1,0+scribble);
		x3=scribble+1/3[x1,x8];
		z3=(x3,y2+scribble);
		z4=(scribble+x3,y1+scribble);
		x5=scribble+2/3[x1,x8];
		z5=(x5,y1+scribble);
		z6=(scribble+x5,y2+scribble);
		z7=(scribble+x8,y2+scribble);
	    rt  z8=(scribble+margin+awidth,y1+scribble);
	draw z1--z2--z3--z4--z5--z6--z7--z8;	
enddef;

def empty_vowel =
	pickup pensquare scaled .5thick;
	undraw z1--z2--z3--z4--z5--z6--z7--z8;	
enddef;

def vowel_i (expr li, re) =	% Vowel i
	numeric x[]; numeric y[];
	x1=li;
	x2=x4=1/2[x1,x3];
	x3=re;
	y1=y3=height;
	y2=2/3[height,vheight];
	y4=vheight;
	fill z1..z2..z3 & z3..z4..z1 & cycle;
	numeric x[]; numeric y[];
enddef;

def vowel_e (expr li, re) =	% Vowel oe
	numeric x[]; numeric y[];
	squarepen;
	top lft z1=(li,vheight);
	    rt	z2=(re,y1);
	draw z1--z2;
	pickup pensquare scaled 1/3thick;
	top rt	z3=(re,vheight);
	bot	z4=(x3,height);
	draw z3--z4;
	numeric x[]; numeric y[];
enddef;

def vowel_ue (expr li, re, v) =	% Vowel oe
	numeric x[]; numeric y[];
	squarepen;
	bot lft z1=(li,-depth-v);
	    rt	z2=(re,y1);
	draw z1--z2;
	pickup pensquare scaled 1/3thick;
	bot rt	z3=(re,-depth-v);
	top	z4=(x3,-v);
	draw z3--z4;
	numeric x[]; numeric y[];
enddef;

def vowel_u (expr li, re, v) =	% Vowel i
	numeric x[]; numeric y[];
	x1=li;
	x2=x4=1/2[x1,x3];
	x3=re;
	y1=y3=-v;
	y2=2/3[y1,y4];
	y4=-depth-v;
	fill z1..z2..z3 & z3..z4..z1 & cycle;
	numeric x[]; numeric y[];
enddef;

def vowel_o (expr li, re) = 	% Vowel o
	numeric x[]; numeric y[];
	z1r=(li,vheight);
	z2r=(x3-.75thick,vheight);
	z3l=(1/2[x1,x5],height);
	z4r=(x3+.75thick,vheight);
	z5r=(re,vheight);
	penpos1(thick,100);
	penpos2(thick,90);
	penpos3(thin,90);
	penpos4(thick,90);
	penpos5(thick,80);
	penstroke z1e--z2e--z3e--z4e--z5e;
	numeric x[]; numeric y[];
enddef;

def vowel_oe (expr li, re) =	% Vowel oe
	numeric x[]; numeric y[];
	squarepen;
	top lft z1=(li,vheight);
	    rt	z2=(re,y1);
		z3=(1/2[x1,x2],y1);
	bot	z4=(x3,height);
	draw z1--z2; draw z3--z4;
	numeric x[]; numeric y[];
enddef;

def kya =	% Similar to kra, we build u-, ue-ligatures!
	squarepen;
	bot lft	z1=(scribble+margin,0+scribble);
	top	z2=(scribble+x1,height+scribble);
	    rt	z3=(scribble+margin+cwidth,y2+scribble);
		z4=(scribble+x3,y1+scribble);
		z5=(scribble+1/2[x2,x3],y1+scribble);
		z6=(scribble+x5,y2+scribble);
	draw z1--z2--z3--z4--z5--z6;
		z7=(scribble+margin,-0/8depth+scribble);
		z8=(scribble+1/2[x7,x9],-3/4depth+scribble);
		z9=(scribble+1/2[x7,x11],-0/8depth+scribble);
		z10=(scribble+1/2[x9,x11],y8+scribble);
		z11=(scribble+margin+cwidth,y7+scribble);
		z12=(scribble+x10,-2/4depth+scribble);
		z13=(scribble+x8,y12+scribble);
	fill z7..z8..z9 & z9..z10..z11 & z11..z12..z9 & z9..z13..z7 & cycle;
enddef;

def kra =	% We define kra due to its enormous underlength
		% which requires special -u, -ue-ligatures
	squarepen;
	top lft z1=(scribble+margin,height+scribble);
	top rt  z2=(scribble+cwidth+margin,height+scribble);
	bot     z3=(scribble+x2,-depth+n+scribble);
		z4=(scribble+x1,1/2height+scribble);
	bot	z5=(scribble+x1,0+scribble);
		z6=(scribble+1/2[x1,x2],y5+scribble);
		z7=(scribble+x6,y1+scribble);
	draw z1--z2--z3;
	draw z4--z5--z6--z7;
		z8l=(scribble+cwidth+margin,-depth+scribble);
		penpos8(2/3thick,90); %
		z9r=(scribble+1/3[x1,x2],-1/3depth+scribble);
		penpos9(2/3thick,90); %
		z10=(scribble+margin,-2/3depth+scribble);
		penpos10(2/3thick,90); %
	penstroke z8e..z9e..z10e;
enddef;

def kla =	% Well, same reason as kya and kra!
	squarepen;
	top	z1=(scribble+1/2[x4,x5],height+scribble);
	bot	z2=(scribble+x1,0+scribble);
	    lft z3=(scribble+margin,y2+scribble);
		z4=(scribble+x3,y1+scribble);
	    rt	z5=(scribble+margin+cwidth,y1+scribble);
	bot	z6=(scribble+x5,0+scribble);
	draw z1--z2--z3--z4--z5--z6;
		z11r=(scribble+margin+cwidth,0+scribble);
	penpos11(thick,0); %
		z12r=(scribble+3/4[x3,x5],-3/4depth+scribble);
	penpos12(3/4thick,-90); %
		z13l=(scribble+1/4[x3,x5],-1/4depth+scribble);
	penpos13(3/4thick,-90); %
		z14l=(scribble+margin,-depth+scribble);
	penpos14(thick,0); %
	penstroke z11e..z12e..z13e..z14e;
enddef;

def b = % The character b
	squarepen;
	top lft	z1=(scribble+margin,height+scribble);
	bot 	z2=(scribble+x1,0+scribble);
	    rt	z3=(scribble+margin+bwidth,y2+scribble);
		z4=(scribble+x3,y1+scribble);
	draw z1--z2--z3--z4;	
enddef;

def basic_r =	% The character r. We repeat in another letter.
	squarepen;
	top lft	z1=(scribble+margin,height+scribble);
	    rt	z2=(scribble+margin+cwidth,y1+scribble);
		z3=(scribble+1/2[x1,x2],y1+scribble);
		z4=(scribble+x3,1/2height+scribble);
	bot	z5=(scribble+x1,0+scribble);
		z6=(scribble+x1,y4+scribble);
		z7=(scribble+x2,y4+scribble);
		z8=(scribble+x2,y5);;
	draw z1--z2; draw z3--z4; draw z5--z6--z7--z8; 
enddef;

def basic_w =	% The character w
	squarepen;
	top lft	z1=(scribble+margin,height+scribble);
	bot 	z2=(scribble+x1,0+scribble);
	    rt	z3=(scribble+margin+bwidth,y2+scribble);
		z4=(scribble+x3,y1+scribble);
	draw z1--z2--z3--z4--cycle; 
enddef;

def basic_l =	% The character l, needed for a few things.
	squarepen;
	bot lft	z1=(scribble+margin,0+scribble);
	top	z2=(scribble+x1,height+scribble);
		z3=(scribble+1/2[x2,x6],y2+scribble);
		z4=(scribble+x3,y1+scribble);
	    rt	z5=(scribble+margin+cwidth,y1+scribble);
		z6=(scribble+x5,y2+scribble);
	draw z1--z2--z3--z4--z5--z6; 
enddef;