%GregorioTeX file.
%
% Copyright (C) 2014-2015 The Gregorio Project (see CONTRIBUTORS.md)
%
% This file is part of Gregorio.
%
% Gregorio is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Gregorio is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Gregorio.  If not, see <http://www.gnu.org/licenses/>.

% this file contains macros for St. Gall ancient neume support

\gre@debugmsg{general}{Loading gregoriotex-nabc.tex}%
\gre@declarefileversion{gregoriotex-nabc.tex}{4.1.1}% GREGORIO_VERSION


\xdef\gre@nabcfontname{gregall}
\xdef\gre@nabcfontsize{8}

\def\gresetnabcfont#1#2{%
  \xdef\gre@nabcfontname{#1}%
  \xdef\gre@nabcfontsize{#2}%
  \global\font\gre@font@nabc={name:#1} at #2 pt\relax %
  {%
    \gre@font@nabc %
    \directlua{gregoriotex.init_nabc_font("\luatexluaescapestring{#1}")}%
  }%
  \gre@nabcfontloadedtrue%
}

\def\grenabccharno#1#2#3{{\directlua{
  gregoriotex.print_nabc(gregoriotex.parse_nabc("#1", "\luatexluaescapestring{#2}", #3))
}}}

\def\GreNABCChar#1{{%
  %\catcode`\~=12{}%
  %\catcode`\@=11{}%
  \gre@font@nabc %
  \gre@style@nabc %
  \grenabccharno{#1}{\gre@nabcfontname}{1}%
  \endgre@style@nabc%
}}

\def\GreNABCNeumes#1#2{%
  \GreSetTextAboveLines{\GreNABCChar{#2}}%
}

\newif\ifgre@nabcfontloaded%
\gre@nabcfontloadedfalse%

\def\GreScoreNABCLines#1{%
  \ifgre@nabcfontloaded\else%
    \gresetnabcfont{\gre@nabcfontname}{\gre@nabcfontsize}%
  \fi %
}
