% fetdefs.tex
% encapsulating tex backend for auto-generated font-en-tja definitions

\def\fetsixteendefs{
        \font\fontentja=feta16
        \font\vetfont=feta-beams16
        \font\fetanummer=feta-nummer8
}
\def\fettwentydefs{
        \font\fontentja=feta20
        \font\vetfont=feta-beams20
        \font\fetanummer=feta-nummer10
}

% \def\fetdef#1#2{\def#1{\fetchar{#2}}}
% ugh, linewidth, ugh, tablexx.ly balldims not used!
\def\fetdef#1#2{%
        % what the fuck is this?
        \def#1{\lower.3884\staffrulethickness
        \hbox{\fetchar{#2}}}}

\def\fetchar#1{\fontentja\char#1}

%\input feta16
\input feta20

\def\beamslope#1#2{{\count0=#2\advance\count0 by#1
        \advance\count0by128
        {\vetfont\char\count0}}}

% stacked numbers; overrules def in lilyponddefs
% oeps: \meter 12/8;
\def\generalmeter#1#2{%
        \vbox to 0pt{\vss%
        \hbox to0.42\balkheight{\hss\fetanummer #1\hss}%
        \nointerlineskip%
        \hbox to0.42\balkheight{\hss\fetanummer #2\hss}%
        \vss}}

\newcount\embedcount\embedcount=0
\newwrite\checkexists
\newwrite\embedfile
\def\inputifexists#1{%
        \openin\checkexists #1
        \ifeof\checkexists
                 \closein\checkexists
                 \relax
        \else
                \closein\checkexists
                \input #1
        \fi
}
\def\embedcountid{feta-embed}
\inputifexists{\embedcountid.aux}
%
% let's not overwrite -- and be sure to create new
\def\storeembedcount{%
        \immediate\openout\embedfile=\embedcountid.aux
        \immediate\write\embedfile{\embedcount=\the\embedcount}
        \immediate\closeout\embedfile
}
\def\turnOnExperimentalFeatures{
% 
% yeah.  By far not finished yet. 
% Don't do this by default.  gs takes a long time to start in xdvi 
%
\special{ps: /drawslur {
        currentpoint  /texoriginy exch def
        /texoriginx exch def    
        /dir exch def
        /lift 30 def
        /desty exch def
        /destx exch def
        /slurfactor .4 def
        destx slurfactor mul
        texoriginx add 
        desty slurfactor mul
        texoriginy add 
        lift dir mul add
        destx 1 slurfactor sub mul
        texoriginx add 
        desty 1 slurfactor sub mul
        texoriginy add 
        lift dir mul add
        destx
        texoriginx add 
        desty
        texoriginy add 
        curveto
        stroke
} def
}
}

\def\embeddedps#1{
        \special{ps: #1}
}
\def\embeddedmf#1{
        \edef\embedid{feta-sleur-\number\embedcount}
        \immediate\openout\embedfile=\embedid.mf
        \global\advance\embedcount by 1
        \immediate\write\embedfile{#1}
        \immediate\closeout\embedfile
        \font\expandafter\embedid\expandafter=\embedid
        \hbox{\embedid\char0}
}

\def\nopostscript{\def\embeddedps##1{}}
\def\nometafont{\def\embeddedmf##1{}}

\nometafont

\def\EndLilyPondOutput{
        \storeembedcount
        \csname bye\endcsname
}


