%% sunrune.mf
%% Part of the tolkienfonts package
%% Copyright 2010 Ariel Barton
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% 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.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Ariel Barton.
%
% This work consists of all the files listed in Appendix F of the file
% `tolkienfontsdoc.pdf'.
%
% Date: 2010/08/29

% Set up the font
mode_setup;

% Don't flash pictures of the characters as you draw them.
% This is dizzying, and UNIX can't do it anyway.
displaying := 0;

% If you want actual documentation, say 
% "mf sunrune" and then
% "gftodvi sunrune.2602gf" and then
% "dvipdfm sunrune"
% at a command prompt in the directory containing this file.
% This will give you a PDF with big pictures of all the characters in 
% the font with the important points labeled.

if known ps_output:
	font_coding_scheme := "ansinew.enc";
	% This tells it where to put the 256 characters in a MetaFont font
	% in the several-thousand-character PFB font
fi

% Some dimensions that we will use a lot
wd# := 5 pt#;   % width of medium-width characters
ht# := 7 pt#;   % height of almost all characters
o#:=1/9pt#;     % overshoot
ho#:=1/9pt#;    % horizontal overshoot
dot#:=1pt#;     % diameter of punctuation dots
gap# := 1pt#;   % Controls gap between characters
stroke# := 0.6pt#;      % Width of the standard pen
barstroke# := 0.4pt#;   % Width of the pen for overbars and underbars
tehtadepth# := 1.6pt#;  % Depth of dots to be put under runes

wide# := 1.3wd#; narrow# := 0.7wd#; 
% The widths of various characters
% We only want three of them, so we can use tehtar as usual.

% wd# is a real dimension, 5/72.27 inches.
% wd is a number of pixels.
% define_pixels makes wd from wd#
define_pixels(wd,ht,gap,o,ho,dot,gap,stroke,wide,narrow,tehtadepth,barstroke);

% The font name and the font dimensions
font_identifier:="SunRune";
font_size 10pt#;    % the "design size" of this font
font_slant 0pt#;    % It doesn't slant
font_x_height ht#;  % Height of most of the characters in the font 
                    % (in a Roman font, this is called the x-height)
font_normal_space 5pt#;   % Spaces are between 4 and 8 pts in this font
font_normal_stretch 3pt#;
font_normal_shrink 1pt#;
font_quad wide#;    % Quad is the width of an "m" in a Roman font.
                    % Here it's the width of the widest characters.
font_extra_space 1.1111pt#; % Extra space to add after punctuation

% Do we want some of the lines in this font to be curved?
boolean curved; curved := true;

pickup pencircle scaled stroke; 
logo_pen:=savepen;
pickup pencircle scaled dot; dot_pen:=savepen;	

%input ansinew;

def beginrune(expr charcode, width) = beginchar(charcode, width+2gap#, ht#, 0); pickup logo_pen; enddef;

path p[];

doublelinegap := 0.35ht;

def flipvert = reflectedabout((0,h/2),(w,h/2)) enddef;
def fliphoriz = reflectedabout((w/2,0),(w/2,h)) enddef;
def leftstem = draw bot (gap,h+o)--top (gap,-o) enddef;
def rightstem = draw bot (w-gap,h+o)--top (w-gap,-o) enddef;
def midstem = draw bot (w/2,h+o)--top (w/2,-o) enddef;

% Particularly simple things

beginrune(98,wd#); "Cirth O";
	z0 = top (gap-ho,-o);
	z1 = bot(0.5w,h+o);
	z2 = top(w-gap+ho,-o);
	p0:= z0--z1--z2;
	draw p0;
	labels(0,1,2);
endchar;
beginrune(238,wd#); "Cirth O with check";
	draw p0;
	z0 = whatever[point 0 of p0, point 1 of p0];
	z2 = whatever[point 2 of p0, point 1 of p0];
	x1 = w/2;
	y0-y1 = -x0+x1; y2-y1 = x2-x1;
	y1 = 0.4 h;
	p1 := z0--z1--z2;
	draw p1;
	labels(0,1,2);
endchar;
beginrune(240,wd#); "Cirth O flipped";
	draw p0 flipvert;
endchar;
beginrune(239,wd#); "Cirth O flipped with check";
	draw p0 flipvert;
	draw p1 flipvert;
endchar;
beginrune(252,wd#); "Cirth O flipped with dot";
	draw p0 flipvert;
	pickup dot_pen;
	z1 = point 1 of p0 flipvert;
	z2 = point 2 of p0 flipvert;
	x0 = w/2; 
	z0 = (whatever[z1,z2])
		 + ((0,h-y0) rotated (angle (z2-z1)));
	drawdot z0;
	labels(0,1,2);
endchar;
beginrune(95,wd#);
	draw p0; draw p0 flipvert;
endchar;
beginrune(109,wd#); "Cirth OO";
	draw p0;
	p1:= bot(0.5w,h+o)--top(0.5w,-o);
	draw p1;
endchar;
beginrune(243,wd#); "Cirth OO flipped";
	draw p0 flipvert;
	draw p1 flipvert;
endchar;
beginrune(41,wd#);
	draw p0;
	z0 = top (w/2,-o); z2 = bot (gap,h+o);
	z3 = whatever[z0,z2]; z3 = whatever[point 0 of p0, point 1 of p0];
	x4 = w-x3; y4=y3;
	draw z3--z0--z4;
	labels(0,3,4);
endchar;


beginrune(77,wd#); "Cirth OO"; %Looks like a M
	draw top (gap,-o)--bot(gap,h+o)--top (0.5w,-o)--bot (w-gap,h+o)--top(w-gap,-o);
endchar;

beginrune(102,narrow#); "Cirth S";
	draw bot (gap-ho,h+o) -- (w+ho-gap,0.5 h) -- top (gap-ho,-o);
endchar;
beginrune(103,narrow#); "Cirth S reversed";
	draw bot (w+ho-gap,h+o) -- (gap-ho,0.5 h) -- top (w+ho-gap,-o);
endchar;
beginrune(68,narrow#); "Cirth UU";
	draw bot (gap-ho,h+o) -- (w+ho-gap,0.5 h) -- top (gap-ho,-o);
	draw bot (w+ho-gap,h+o) -- (gap-ho,0.5 h) -- top (w+ho-gap,-o);
endchar;
beginrune(250,narrow#); "Cirth UU with dots";
	draw bot (gap-ho,h+o) -- (w+ho-gap,0.5 h) -- top (gap-ho,-o);
	draw bot (w+ho-gap,h+o) -- (gap-ho,0.5 h) -- top (w+ho-gap,-o);
	pickup dot_pen;
	z0 = lft (gap-ho,0.5[h/2,bot h+o]);
	drawdot rt z0; drawdot rt z0 fliphoriz;
	labels(0);
endchar;
beginrune(104,wd#); "Daeron Z"; %Looks like an X
	draw bot (gap-ho,h+o)--top (w-gap+ho,-o);
	draw bot (w-gap+ho,h+o)--top (gap-ho,-o);
endchar;
beginchar(93,2gap#+wd#,wd#+2stroke#,0); %Short X
	pickup logo_pen;
	draw bot (gap-ho,h+o)--top (w-gap+ho,-o);
	draw bot (w-gap+ho,h+o)--top (gap-ho,-o);
endchar;
beginchar(85,2gap#+wd#,wd#+2stroke#,0); %Short asterisk
	pickup logo_pen;
	draw bot (gap-ho,h+o)--top (w-gap+ho,-o);
	draw bot (w-gap+ho,h+o)--top (gap-ho,-o);
	draw (gap-ho,h/2)--(w-gap+ho,h/2);
	draw top(w/2,-o)--bot(w/2,h+o);
endchar;

beginrune(107,wide#); "Hobbit D";
	draw bot (gap,h+o)--top (w-gap,-o) -- bot (w-gap,h+o)--top (gap,-o)--cycle;
endchar;
beginrune(247,wide#); 
	draw bot (gap,h+o)--top (w-gap,-o) -- bot (w-gap,h+o)--top (gap,-o)--cycle;
	pickup dot_pen;
	drawdot bot (w/2,h); drawdot top (w/2,0);
endchar;

beginrune(249,wd#);
	draw (gap-ho,h/2)--bot(w/2,h+o)--(w-gap+ho,h/2)--top(w/2,-o)--cycle;
	pickup dot_pen; drawdot(w/2,h/2);
endchar;

beginrune(108,0); "Cirth H";
	leftstem;
endchar;

beginrune(214,wd#); "Hobbit EO"; % Looks like a Z
	draw bot (gap-ho,h)--bot (w-gap+ho,h) -- top (gap-ho,0) -- top (w-gap+ho,0);
endchar;

beginrune(92,dot#-stroke#-2ho#); "Single low dot";
	pickup dot_pen; drawdot top(w/2,-o);
endchar;
beginrune(73,dot#-stroke#-2ho#); "Single dot";
	pickup dot_pen; drawdot (w/2,h/2);
endchar;
beginrune(123,dot#-stroke#-2ho#); "Three stretched dots";
	pickup dot_pen; 
	drawdot top(w/2,-o);
	drawdot bot(w/2,h+o);
	drawdot (w/2,h/2);
endchar;
beginrune(125,dot#-stroke#-2ho#); "Four dots";
	pickup dot_pen; 
	z0 = top(w/2,-o);
	z3 = bot(w/2,h+o);
	z1 = 1/3[z0,z3];
	z2 = 2/3[z0,z3];
	drawdot z0; drawdot z1; drawdot z2; drawdot z3;
	dotgap := y1-y0;
	labels(0,1,2,3);
endchar;
beginrune(80,dot#-stroke#-2ho#); "Three dots";
	pickup dot_pen; 
	z1 = (w/2,h/2);
	z2 = z1 + (0,dotgap);
	z0 = z1 - (0,dotgap);
	drawdot z0; drawdot z1; drawdot z2;
	labels(0,1,2);
endchar;
beginrune(79,dot#-stroke#-2ho#); "Two dots";
	pickup dot_pen; 
	0.5[z1,z2] = (w/2,h/2);
	z2 = z1 + (0,dotgap);
	drawdot z1; drawdot z2;
	labels(1,2);
endchar;

beginrune(82,narrow#); "Looks like a K";
	leftstem;
	z0 = (-w-2gap,-2h);
	x1 = -x0; y1=y0;
	if curved: 
		p2 := bot (w-gap+ho,h+o){z0} ..  (gap, h/2);
		p1 :=  (gap, h/2) .. top (w-gap+ho,-o){z1};
		p0 := p2 & p1;
	else: p0 := bot (w-gap+ho,h+o) -- rt(gap, h/2) -- top (w-gap+ho,-o);
	fi
	draw p0;
endchar;
beginrune(84,narrow#);
	rightstem;
	draw p0 fliphoriz;
endchar;

% Tehtar

beginchar(208, 0, 0, tehtadepth#);
	pickup dot_pen;
	drawdot top(-gap,-d-o);
endchar;
beginchar(209, 0, 0, tehtadepth#);
	pickup dot_pen;
	drawdot top(-narrow/2,-d-o);
endchar;
beginchar(210, 0, 0, tehtadepth#);
	pickup dot_pen;
	drawdot top(-wd/2,-d-o);
endchar;
beginchar(211, 0, 0, tehtadepth#);
	pickup dot_pen;
	drawdot top(-wide/2,-d-o);
endchar;

beginchar(204, 0, 0, tehtadepth#);
	pickup logo_pen;
	draw top(-gap+1.5stroke,-d-o)--top(-gap-1.5stroke,-d-o);
endchar;
beginchar(205, 0, 0, tehtadepth#);
	pickup logo_pen;
	draw top(-gap,-d-o)--top(-narrow-gap,-d-o);
endchar;
beginchar(206, 0, 0, tehtadepth#);
	pickup logo_pen;
	draw top(-gap,-d-o)--top(-wd-gap,-d-o);
endchar;
beginchar(207, 0, 0, tehtadepth#);
	pickup logo_pen;
	draw top(-gap,-d-o)--top(-wide-gap,-d-o);
endchar;

hatheight# := 0.6pt#; define_pixels(hatheight);

beginchar(200, 0, ht#+hatheight#+tehtadepth#, 0);
	pickup logo_pen;
	draw bot(-gap+1.5stroke,h+o-hatheight)--(-gap,h+o)--bot(-gap-1.5stroke,h+o-hatheight);
endchar;
beginchar(201, 0, ht#+hatheight#+tehtadepth#, 0);
	pickup logo_pen;
	draw bot(-gap,h+o-hatheight)--(-gap-narrow/2,h+o)--bot(-narrow-gap,h+o-hatheight);
endchar;
beginchar(202, 0, ht#+hatheight#+tehtadepth#, 0);
	pickup logo_pen;
	draw bot(-gap,h+o-hatheight)--(-gap-wd/2,h+o)--bot(-wd-gap,h+o-hatheight);
endchar;
beginchar(203, 0, ht#+hatheight#+tehtadepth#, 0);
	pickup logo_pen;
	draw bot(-gap,h+o-hatheight)--(-gap-wide/2,h+o)--bot(-wide-gap,h+o-hatheight);
endchar;

% Slightly more complicated (require decisions beyond just character width)

Mdip = 0.6 ht;

beginrune(74,wd#); % Futhark M
	z0 = bot (gap,h+o);
	x1 = w-gap; y1=y0;
	z2 = (w-gap, y0-Mdip);
	z3 = (gap,y2);
	p0 := z0--z2; p1 := z1--z3;
	leftstem; draw p0; rightstem; draw p1;
	labels(0,1,2,3);
endchar;
beginrune(75,wd#);
	z0 = point 0.5 of p0;
	leftstem; draw p0 shifted (0,h/2-y0); rightstem; draw p1 shifted (0,h/2-y0);
	labels(0);
endchar;
beginrune(234,wd#);
	leftstem; draw p0 flipvert; rightstem; draw p1 flipvert;
endchar;

beginrune(241,wd#); % Letter M
	draw top (gap,-o)--bot(gap,h+o)--(w/2,h/2)--bot(w-gap,h+o)--top (w-gap,-o);
endchar;

beginrune(242,wd#); % Letter M upside down
	t1 := (w/2-gap)/3;
	p1 := bot (gap,h+o)--top(gap+t1,-o)--(w/2,h/2)--top(w-gap-t1,-o)--bot (w-gap,h+o);
	draw p1;
endchar;

beginrune(253,wd#); % Letter M upside down with dots
	draw p1;
	z0 = 0.5[top point 2 of p1, (w/2,h)];
	pickup dot_pen; drawdot z0;
	z1 = top (w/2, 0); drawdot z1;
	labels(0,1);
endchar;

beginrune(100,wd#); % X with a line through it
	draw top(w/2,-o)--bot(w/2,h+o);
	p0:= if curved: bot (gap-ho,h+o){down}.. top (w-gap+ho,-o){down};
		else: bot (gap-ho,h+o)--top (w-gap+ho,-o); fi	
	draw p0;
	draw p0 fliphoriz;
endchar;

beginrune(44,wd#); % Looks like a Y
	p0 := bot(gap-ho,h+o)--(w/2,0.45h)--bot(w-gap,h+o);
	draw p0;
	draw top(w/2,-o)--point 1 of p0;
endchar;
beginrune(46,wd#);
	p1 := p0 flipvert;
	draw p1;
	draw bot(w/2,h+o)--point 1 of p1;
endchar;

beginrune(97,narrow#); % Cirth L
	midstem;
	x0=gap-ho; x1=w-gap+ho; h-y1 = y0;
	if curved:
	y0 = 0.25h;
	p0 := z0{up}..z1{up};
	else:
	y0 = 0.333h;
	p0 := z0--z1;
	fi
	draw p0;
	labels(0,1);
endchar;
beginrune(115,narrow#);
	draw p0 fliphoriz;
	midstem;
endchar;

beginrune(58,wide#); % Erebor LL
	z0=point 0 of p0; z1=point 1 of p0;
	x3 = 0.5[x0,x1];
	x4 = w-x3;
	y3 = y4 = top -o;
	draw z3--bot(x3,h+o);
	draw z4--bot(x4,h+o);
	x2 = w-gap; y2+y0=h;
	t2 := 3;
	if curved:
	draw z0{(x2-x0,t2*(y2-y0))}..z2{(x2-x0,t2*(y2-y0))};
	else:
	draw z0--z2;
	fi
	labels(0,2,3,4);
endchar;

beginrune(59,narrow#); % Moria h/hy, Erebor Y
	z0 = bot(gap,h+o);
	z3 = top(w-gap,-o);
	x1=x0; x2=x3; y1+y2=h;
	y1=0.35h;
	p0:=z0--z1--z2--z3;
	draw p0;
	labels(0,1,2,3);
endchar;
beginrune(65,narrow#);
	draw p0 fliphoriz;
endchar;

% Proposed (unattested) character for Erebor long Y
%beginrune(216,narrow#); % Erebor long Y
%	z0 = bot(gap,h+o);
%	z3 = top(w-gap,-o);
%	x1=x0; x2=x3; y1+y2=h;
%	y1=0.35h;
%	
%	z4 = z1 + (0, doublelinegap/2);
%	z5 = z1 - (0, doublelinegap/2);
%	z6 = z2 + (0, doublelinegap/2);
%	z7 = z2 - (0, doublelinegap/2);
%	
%	draw z0--z5--z7;
%	draw z4--z6--z3;
%	
%	labels(0,1,2,3,4,5,6,7);
%endchar;


beginrune(66,wd#); "Cirth &";
	x0 = gap-ho; x3=w-gap+ho;
	x2=x1=w/2; y1=bot h+o; y2=top -o;
	y0+y3=h;
	y0 = 0.7h;
	p0:=z0--z1--z2--z3;
	draw p0;
	labels(0,1,2,3);
endchar;
beginrune(244,wd#);
	draw p0 fliphoriz;
endchar;

beginrune(106,wd#); % X with a box around it
	draw bot (gap-ho,h+o)--top (w-gap+ho,-o);
	draw bot (w-gap+ho,h+o)--top (gap-ho,-o);
	z.left = (gap-ho,h/2);
	z.right=(w-gap+ho,h/2);
	z.top=bot(w/2,h+o);
	z.bot=top(w/2,-o);
	z.mid=(w/2,h/2);
	
	forsuffixes s=left,right,top,bot:
		z1s = 0.8[z.mid,z.s];
	endfor
	draw z1left--z1top--z1right--z1bot--cycle;
	labels(left,right,top,bot,mid);
endchar;

beginrune(110,wide#); "Cirth OO";
	z0 = top (gap-ho,-o); z2 = z0 + .65(w-2gap+2ho,0); 
	x1 = 0.5[x2,x0]; y1 = bot h+o;
	p0 := z0--z1--z2;
	p1 := p0 shifted (lft top (w+ho-gap,-o)-z2);
	draw p0; draw p1;
	labels(0,1,2);
endchar;
beginrune(43,wide#); "Cirth OO";
	draw p0 flipvert; draw p1 flipvert;
endchar;

beginrune(60,wd#); "Cirth O";
	draw top (gap-ho,-o)--bot(0.5w,h+o)--top(w-gap+ho,-o);
	draw top (w/2,-o)--bot (w/2, 0.5h);
endchar;
beginrune(34,0); "Erebor THE";
	draw top (w/2,0.5h)--bot(w/2,h+o);
endchar;
beginchar(86,2gap#,0.5ht#,0); "Cirth H plus";
	pickup logo_pen;
	draw bot (w/2,h)--top(w/2,-o);
endchar;

beginrune(83,wd#); "Cirth U";
	x0 = 0.2[gap-ho,w/2];
	y0 = top -o;
	z2 = bot (w/2,h+o);
	y4=y0; x4 = w-x0;
	x3 = gap-ho; x1 = w-x3; 
	z1 = whatever[z0,(x1+x1-x2,y2)];
	y3=y1;
	p0:= z0--z1--z2--z3--z4;
	draw p0;
	z5=whatever[z0,z1]; z5=whatever[z3,z4];
	p1:=z5--z1--z2--z3--cycle;
	labels(0,1,2,3,4,5);
endchar;
beginrune(248,wd#); 
	draw p0; pickup dot_pen; 
	z1 = point 1 of p0; z3 = point 3 of p0;
	drawdot 0.5[z1,z3];
	labels(1,3);
endchar;

beginrune(76,wd#);
	x0 = 0.2[gap-ho,w/2];
	y0 = h/7;
	z2 = bot (w/2,h+o);
	y4=y0; x4 = w-x0;
	x3 = gap-ho; x1 = w-x3; 
	z1 = whatever[z0,(x1+x1-x2,y2)];
	y3=y1;
	p0:= z0--z1--z2--z3--z4;
	draw p0;
	draw top (w/2,-o)--z2;
	z5=whatever[z0,z1]; z5=whatever[z3,z4];
	p1:=z5--z1--z2--z3--cycle;
	labels(0,1,2,3,4,5);
endchar;
beginrune(70,wd#); 
	draw p1; z0 = point 0 of p1;
	draw top (w/2,-o)--z0;
	labels(0);
endchar;
beginrune(71,wd#); 
	draw p1; 
	z0 = point 0 of p1; z1 = top (w/2,-o);
	draw z1--z0;
	x2 = x0 - 0.6(y0-y1); x3=w-x2;
	y2 = y3 = y1 + 0.5(x3-x2);
	draw z2--z3;
	labels(0,1,2,3);
endchar;

beginrune(235,wd#);
	x0 = gap-ho;
	y0 = top -o;
	z2 = bot (w/2,h+o);
	y4=y0; x4 = w-x0;
	x3 = gap-ho; x1 = w-x3; 
	z1 = whatever[z0,(x1+x1-x2,y2)];
	y3=y1;
	p0:= z0--z1--z2--z3--z4;
	draw p0;
	z5 = whatever[z0,z1]; z5=whatever[z3,z4];
	draw top (w/2,-o)--z5;
	labels(0,1,2,3,4,5);
endchar;
beginrune(236,wd#); 
	draw p0; midstem;
endchar;

beginrune(232,narrow#); "Hobbit K";
	leftstem;
	z2 = top(w-gap+ho,-o);
	z0 = (gap,0.45h);	
	x1 = 0.8[x0,x2];
	y1 = 0.65h;
	draw z0--z1--z2;
	labels(0,1,2);
endchar;
	
% Things that look like B/P/R

beginrune(54,narrow#); % Looks like a B
	z0 = top (gap,-o); z1 = bot(gap,h+o);
	z2 =(w-gap+ho,0.75[y0,y1]);
	z3=rt rt(gap,0.5[y0,y1]);
	z4=(w-gap+ho,0.25[y0,y1]);
	labels(0,1,2,3,4);
	p0 := z0--z1--z2--z3--z4--cycle;
	draw p0;
endchar;
beginrune(55,narrow#);
	draw p0 fliphoriz;
endchar;

beginrune(53,wd#); 
	z1 = point 3 of p0;
	z.mid = (w/2,y1);
	z.bot = top(w/2,-o);
	z.top = bot(w/2,h+o);
	x.left = gap-ho; x.right=w-gap+ho;
	y.left = y.right= 0.5[y.top,y.mid];
	draw z.bot--z.top; 
	draw z.left--z.top--z.right--z.mid--cycle;
	labels(1,mid,bot,top,left,right);
endchar;

beginrune(49,narrow#); % Looks like a P
	p1 := subpath (0,3) of p0;
	draw p1;
endchar;
beginrune(51,narrow#);
	draw p1 fliphoriz;
endchar;
beginrune(50,narrow#); % Looks like a R
	z0 = point infinity of p1;
	z1 = top (w-gap+ho,-o);
	p2 := p1 & z0--z1;
	draw p2;
	labels(0,1);
endchar;
beginrune(52,narrow#);
	draw p2 fliphoriz;
endchar;
beginrune(246,narrow#);
	draw p2 fliphoriz;
	z2 = point 2 of p2 fliphoriz;
	z3 = point 3 of p2 fliphoriz;
	z4 = point 4 of p2 fliphoriz;
	x1 = lft gap-ho;
	pickup dot_pen; 
	x0 = rt x1;
	z0-z3 = whatever*((1,0) rotated 0.5[angle (z2-z3),angle (z4-z3)]);
	drawdot z0;
	labels(0,1,2,3,4);
endchar;

beginrune(88,narrow#); "Erebor PS";
	z0 = (gap, 0.25h);
	z1 = (w-gap+ho,0.5h);
	z2 = (gap, h-y0);
	p3 := z0--z1--z2;
	leftstem;
	draw p3;
	labels(0,1,2);
endchar;
beginrune(67,narrow#); "Erebor TS";
	rightstem;
	draw p3 fliphoriz;
endchar;

beginrune(220,narrow#);
	draw p1 flipvert;
endchar;
beginrune(222,narrow#);
	draw p1 fliphoriz flipvert;
endchar;
beginrune(221,narrow#);
	draw p2 flipvert;
endchar;
beginrune(223,narrow#);
	draw p2 fliphoriz flipvert;
endchar;

% Dentals (t/d/th/dh)

linedip := 0.25ht;

beginrune(56,narrow#);
	p0 := bot(gap,h+o)--(w-gap,h+o-linedip);
	p1 := top (gap,-o)--bot(gap,h+o) & p0;
	draw p1;
endchar;
beginrune(48,narrow#);
	draw p1 fliphoriz;
endchar;
beginrune(57,narrow#);
	draw p1;
	draw p0 shifted (0,-doublelinegap);
endchar;
beginrune(33,narrow#);
	draw p1 fliphoriz;
	draw p0 fliphoriz shifted (0,-doublelinegap);
endchar;
beginrune(64,wd#);
	z0 = top (w/2,-o);
	z2 = bot (w/2,h+o);
	y1=y3=0.7h;
	x1=gap-ho; x3=w-gap+ho;
	p2:= z0--z2; p3 := z1--z2--z3;
	draw p2; draw p3;
	labels(0,1,2,3);
endchar;
beginrune(230,wd#);
	draw p2; draw p3;
	draw p3 shifted (0,-doublelinegap);
endchar;
beginrune(229,wd#);
	draw p2; draw p3 flipvert;
	draw p3 shifted (0,-doublelinegap) flipvert;
endchar;
beginrune(228,wd#);
	draw p2; draw p3 flipvert;
endchar;

beginrune(224,narrow#);
	draw p1 flipvert;
endchar;
beginrune(226,narrow#);
	draw p1 flipvert fliphoriz;
endchar;
beginrune(225,narrow#);
	draw p1 flipvert;
	draw p0 flipvert shifted (0,doublelinegap);
endchar;
beginrune(227,narrow#);
	draw p1 flipvert fliphoriz;
	draw p0 flipvert fliphoriz shifted (0,doublelinegap);
endchar;

% ch/j/sh/zh

beginrune(35,narrow#);
	leftstem;
	p0 := (gap,0.6h) -- top(w-gap+ho, -o);
	draw p0;
endchar;
beginrune(36,narrow#);
	leftstem;
	draw p0;
	z2=point 0 of p0; z3=point 1 of p0;
	x0 = gap;
	y1 = top -o;
	y0 = 0.55 y2;
	z0-z1 = whatever*(z2-z3);
	p1 := z0--z1;
	draw p1;
	labels(0,1,2,3);
endchar;
beginrune(37,narrow#);
	rightstem;
	draw p0 fliphoriz;
endchar;
beginrune(113,narrow#);
	rightstem;
	draw p0 fliphoriz;
	draw p1 fliphoriz;
endchar;

beginrune(119,wd#);
	midstem;
	draw top(gap-ho,-o)--(w/2,0.6h)--top(w-gap+ho,-o);
endchar;

% k/g/kh/gh/etc

beginrune(114,narrow#);
	leftstem;
	x0=gap; x1 = w-gap+ho;
	y1 = bot h+o;
	t0 := 3;
	y0 = 0.4h;
	if curved:
	p0 := z0{(t0,1)}..z1;
	else:
	p0 := z0--z1;
	fi
	z2 = bot (gap,h+o);
	t1 := 0.5;
	z3 = t1[z0,z2];
	z4 = t1[z1,z2];
	if curved:
	p1 := z3{(t0,1)}..z4;
	else:
	p1 := z3--z4;
	fi
	draw p0; draw p1;
	labels(0,1,2,3,4);
endchar;
beginrune(121,narrow#);
	rightstem;
	draw p0 fliphoriz; draw p1 fliphoriz;
endchar;
beginrune(101,narrow#);
	leftstem;
	draw p0;
endchar;
beginrune(116,narrow#);
	rightstem;
	draw p0 fliphoriz;
endchar;
beginrune(117,wide#);
	midstem;
	z.mid = point 0 of p0;
	x0=w/2; x1 = w-gap+ho;
	y1 = bot h+o;
	y0 = y.mid;
	p0 := z0{(t0,1)}..z1;	
	draw p0; draw p0 fliphoriz;
	labels(0,1,mid);
endchar;

% Letter A and similar things

beginrune(99,narrow#);
	p0 := top (gap,-o)--bot(gap,h+o)--(w-gap,0.7h)--top(w-gap,-o);
	draw p0;
endchar;
beginrune(118,narrow#);
	draw p0;
	p1:= subpath(1,2) of p0 shifted (0,-doublelinegap);
	draw p1;
endchar;
beginrune(42,narrow#);
	draw p0;
	draw p1;
	draw top (w/2,-o)--point 0.5 of p1;
endchar;
beginrune(38,narrow#);
	draw p0;
	draw top (w/2,-o)--point 0.5 of p1;
endchar;
beginrune(237,narrow#);
	draw p0;
	draw top (w/2,-o)--point 1.5 of p0;
endchar;
beginrune(251,narrow#);
	draw p0;
	pickup dot_pen;
	z1 = point 1 of p0; z2 = point 2 of p0;
	x0 = w/2; y0 = 0.5(0.5[y1,y2]);
	drawdot z0;
	labels(0,1,2);
endchar;


beginrune(40,narrow#);
	z2 = bot(w/2,h+o);
	draw top (w/2,-o)--z2;
	z0 = top (gap,-o); z4 = top(w-gap,-o);
	y1=y3; x1 = gap; x3 = w-gap;
	y1 = 0.7h;
	draw z0--z1--z2--z3--z4;	
	labels(0,1,2,3,4);
endchar;

beginrune(122,narrow#); "Cirth E";
	leftstem; rightstem;
	x0=gap; x1=w-gap; y0+y1=1.1h;
	z2=point 1 of p0; z3 = point 2 of p0;
	y0-y1 = y2-y3;
	p1:= z0--z1; draw p1;
	labels(0,1,2,3);
endchar;
beginrune(120,narrow#); "Cirth EE";
	leftstem; rightstem;
	draw p1 shifted (0,-doublelinegap/2);
	draw p1 shifted (0,doublelinegap/2);
endchar;

% The narrow schwa symbols

beginrune(47,0.5narrow#);
	leftstem;
	p0 := (gap,0.6h)--(w-gap,0.6h-0.6(w-2gap));
	draw p0;
endchar;
beginrune(90,0.5narrow#);
	rightstem;
	draw p0 fliphoriz;
endchar;

beginrune(62,0.5narrow#);
	draw p0;
endchar;
beginrune(63,0.5narrow#);
	draw p0 fliphoriz;
endchar;
	

% Complicated things

beginrune(213,wd#); "Alternate hobbit P";
	leftstem;
	
	x0 = x1 = gap;
	x2 = x3 = w - gap - 0.8pt;
	x4 = x5 = w - gap + ho;
	
	h - y1 = y0;
	h - y3 = y2;
	h - y5 = y4;
	
	y4 = 0.2h;
	y2 = 0.4h;
	y0 = 0.3h;
	
	draw z0--z2--z4; draw z1--z3--z5;
	labels(0,1,2,3,4,5);

endchar;

% Bar with zigzags coming out

zigzagdip := 0.35ht;

beginrune(111,wd#);
	leftstem;	
	p0 := bot (gap,h+o) -- rt (0.5w, h+o-zigzagdip) -- bot (w-gap+ho,h+o);
	p1 := p0 shifted (0,-zigzagdip);
	draw p0; draw p1;
endchar;
beginrune(105,wd#);
	p2 := bot (gap,h+o) -- (0.5[0.5w,rt 0.5w], h+o-zigzagdip) -- bot (w-gap+ho,h+o);
	draw p2;
	leftstem;
endchar;
beginrune(231,wd#);
	draw p2 flipvert;
	leftstem;
endchar;
beginrune(112,wd#);
	draw p2 fliphoriz; 
	rightstem;
endchar;
beginrune(81,wd#);
	draw p0 fliphoriz; 
	draw p1 fliphoriz; 
	rightstem;
endchar;

beginrune(87,wide#);
	z2 = bot(w/2,h+o);
	draw top(w/2,-o)--z2;
	z0 = bot(gap-ho,h+o); y0=y4; x4=w-x0;
	x1 = lft 0.5[x0,x2]; x3 = rt 0.5[x2,x4];
	y1 = y3 = y0-zigzagdip*.8;
	draw z0--z1--z2--z3--z4;	
	labels(0,1,2,3,4);
endchar;

beginrune(215,wd#); "Hobbit OA";
	leftstem;
	
	p0 := bot (gap,h+o) -- rt (0.5w, h+o-zigzagdip) -- bot (w-gap+ho,h+o);
	
	draw p0; draw subpath(0,1) of p0 shifted (0,-doublelinegap);
endchar;

% Mirrored zigzags (top and bottom)

zigzagdip := 0.28ht;

beginrune(212,wide#); "ST";
	draw top (w-gap,-o) -- (0.5w, zigzagdip-o) -- top (gap,-o) -- 
	bot (gap,h+o) -- (0.5w, h+o-zigzagdip) -- bot (w-gap,h+o) -- cycle;
endchar;
beginrune(69,wd#); "Cirth NW";
	p0:= top (w-gap+ho,-o) -- (0.5w, zigzagdip-o) -- top (gap,-o) -- 
	bot (gap,h+o) -- (0.5w, h+o-zigzagdip) -- bot (w-gap+ho,h+o);
	draw p0;
endchar;
beginrune(233,wd#); "Cirth NW reversed";
	draw p0 fliphoriz;
endchar;

% Bars
beginrune(61,wd#); "Horizontal bars";
	x0=x2=gap-ho; x1=x3=w-x0; y0=y1; y2=y3;
	y0+y2=h; y2-y0 = doublelinegap;
	draw z0--z1; draw z2--z3;
	labels(0,1,2,3);
endchar;
beginchar(124,2gap#+2stroke#,ht#,0); "Vertical bars";
	pickup logo_pen;
	pickup pensquare scaled stroke;
	draw top (gap,0)--bot(gap,h);
	draw top (w-gap,0)--bot(w-gap,h);
endchar;

beginchar(254, narrow#, ht#+tehtadepth#, tehtadepth#);
	pickup pensquare scaled barstroke;
	draw bot rt (0,h)--bot lft(w,h);
	draw top rt (0,-d)--top lft(w,-d);
endchar;

beginchar(255, narrow#, ht#+2barstroke#+tehtadepth#, tehtadepth#+2barstroke#);
	pickup pensquare scaled barstroke;
	draw bot rt (0,h)--bot lft(w,h);
	draw top rt (0,-d)--top lft(w,-d);
	draw bot rt (0,ht+tehtadepth)--bot lft(w,ht+tehtadepth);
	draw top rt (0,-tehtadepth)--top lft(w,-tehtadepth);
endchar;

% Something I'm not sure about from the Cirth Erebor font
beginrune(245, narrow#);
	x0 = x1 = w/2;
	y0+y1 = h;
	y1 - y0 = 0.5h;
	draw bot (gap,h+o)--z0--bot(w-gap,h+o);
	draw top (gap,-o)--z1--top(w-gap,-o);
	labels(0,1);
endchar;

%input simplekern;
input complexkern;

end

