summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/gregoriotex/gregoriotex-signs.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/gregoriotex/gregoriotex-signs.tex')
-rw-r--r--Master/texmf-dist/tex/luatex/gregoriotex/gregoriotex-signs.tex2282
1 files changed, 2282 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/luatex/gregoriotex/gregoriotex-signs.tex b/Master/texmf-dist/tex/luatex/gregoriotex/gregoriotex-signs.tex
new file mode 100644
index 00000000000..36ffb0a23ac
--- /dev/null
+++ b/Master/texmf-dist/tex/luatex/gregoriotex/gregoriotex-signs.tex
@@ -0,0 +1,2282 @@
+%GregorioTeX file.
+%
+% Copyright (C) 2007-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 definitions of signs (bar, episema, punctum, alterations)
+
+\def\grebarbracewidth{.58879}%
+
+\gre@debugmsg{general}{Loading gregoriotex-signs.tex}%
+\gre@declarefileversion{gregoriotex-signs.tex}{4.1.1}% GREGORIO_VERSION
+
+\def\gre@usestylecommon{%
+ \ifgre@usestylefont\else %
+ \gre@usestylefonttrue%
+ \gre@setstylefont %
+ \fi %
+ \relax %
+}%
+
+\gresetglyphstyle{default}%
+
+% Possibility to disable some signs:
+\newif\ifgre@disablevepisema
+\gre@disablevepisemafalse
+\newif\ifgre@disablehepisema
+\gre@disablehepisemafalse
+\newif\ifgre@disablemora
+\gre@disablemorafalse
+
+\def\greprintsigns#1#2{%
+ \IfStrEqCase{#2}{%
+ {enable}%
+ {%
+ \IfStrEqCase{#1}{%
+ {vepisema}%
+ {\global\gre@disablevepisemafalse}%
+ {hepisema}%
+ {\global\gre@disablehepisemafalse}%
+ {mora}%
+ {\global\gre@disablemorafalse}%
+ {all}%
+ {\global\gre@disablemorafalse\global\gre@disablevepisemafalse\global\gre@disablehepisemafalse}%
+ }[% all other cases
+ \gre@error{Unrecognized first argument for \protect\greprintsigns}%
+ ]%
+ }%
+ {disable}%
+ {%
+ \IfStrEqCase{#1}{%
+ {vepisema}%
+ {\global\gre@disablevepisematrue}%
+ {hepisema}%
+ {\global\gre@disablehepisematrue}%
+ {mora}%
+ {\global\gre@disablemoratrue}%
+ {all}%
+ {\global\gre@disablemoratrue\global\gre@disablevepisematrue\global\gre@disablehepisematrue}%
+ }[% all other cases
+ \gre@error{Unrecognized first argument for \protect\greprintsigns}%
+ ]%
+ }%
+ }[% all other cases
+ \gre@error{Unrecognized second argument for \protect\greprintsigns}%
+ ]%
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% macros for discretionaries
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% In order to avoid clef change at beginning or end of line, we use discretionaries
+% for clef change, or even with more complex data (z0::c3 for instance). The problem
+% with discretionaries is that:
+% - you cannot use \hskip (but you can use kern)
+% - you cannot use \penalty (which is useless indeed)
+%
+% To remedy that, we define \gre@hskip to be \hskip outside a discretionary, and
+% \kern inside a discretionary. This is what these macros do:
+
+\def\gre@falsepenalty#1{}%
+\def\gre@truepenalty#1{\penalty#1}%
+
+\let\gre@hskip\hskip%
+\let\gre@penalty\gre@truepenalty%
+\xdef\gre@insidediscretionary{\number 0}%
+
+% #1 is the type of discretionary, for penalty assignment. Recognized types:
+% - 0: clef change
+\def\GreDiscretionary#1#2#3{%
+ \global\let\gre@hskip\kern %
+ \global\let\gre@penalty\gre@falsepenalty %
+ \global\xdef\gre@insidediscretionary{\number 1}%
+ \discretionary{%
+ \global\gre@lastoflinecount=1\relax % (a good magic trick)
+ \gre@debugmsg{bolshift}{discretionary pre lastoflinecount: \the\gre@lastoflinecount}%
+ #2%
+ }{%
+ \global\gre@lastoflinecount=2\relax % (a good magic trick)
+ \gre@debugmsg{bolshift}{discretionary post lastoflinecount: \the\gre@lastoflinecount}%
+ }{%
+ \gre@debugmsg{bolshift}{discretionary no lastoflinecount: \the\gre@lastoflinecount}%
+ #3%
+ }%
+ \global\xdef\gre@insidediscretionary{\number 0}%
+ \global\let\gre@hskip\hskip %
+ \global\let\gre@penalty\gre@truepenalty %
+ \relax %
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% macros for the typesetting of the clefs of the beginning of lines and custos
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% flag for showing the clef
+\newif\ifgre@showclef%
+\gre@showcleftrue
+
+\def\gresetclef#1{%
+ \IfStrEqCase{#1}{%
+ {visible}%
+ {\gre@showcleftrue}%
+ {invisible}%
+ {\gre@showcleffalse}%
+ }[% all other cases
+ \gre@error{Unrecognized option "#1" for \protect\gresetclef\MessageBreak Possible options are: 'visible' and 'invisible'}%
+ ]%
+}%
+
+
+\def\greremoveclef{% OBSOLETE
+ \gre@obsolete{\protect\greremoveclef}{\protect\gresetclef{invisible}}%
+}%
+
+\def\grenormalclef{% OBSOLETE
+ \gre@obsolete{\protect\grenormalclef}{\protect\gresetclef{visible}}%
+}%
+
+%% marcro to define the clef that will appear at the beginning of the lines
+% the first argument is the type : f or c, and the second is the height
+% the third argument is whether we must type a space after or not (0 if not, 1 if yes)
+% if the fourth argument is 3, it means that we must not put a flat after the key, otherwise it's the height of the flat
+\def\GreSetLinesClef#1#2#3#4#5#6#7{%
+ \gre@localleftbox{%
+ \gre@skip@temp@four = \gre@dimen@additionalleftspace\relax%
+ \kern\gre@skip@temp@four %
+ \copy\gre@box@lines% draws the lines
+ \unkern %
+ \ifgre@showclef%
+ \gre@skip@temp@four = \gre@space@skip@afterclefnospace\relax%
+ \hbox{\gre@typeclef{#1}{#2}{0}{#3}{#4}{#5}{#6}{#7}\hskip\gre@skip@temp@four}%
+ \else %
+ \gre@skip@temp@four = \gre@space@dimen@noclefspace\relax%
+ \hbox{\kern\gre@skip@temp@four}%
+ \fi %
+ }%
+ \xdef\gre@clefflatheight{#4}%
+ \xdef\gre@cleftwoflatheight{#7}%
+ \relax%
+}%
+
+\def\gre@save@clef#1#2#3#4#5#6{%
+ \global\let\gre@clef=#1\relax%
+ \xdef\gre@clefheight{#2}%
+ \xdef\gre@clefflatheight{#3}%
+ \global\let\gre@cleftwo=#4\relax%
+ \xdef\gre@cleftwoheight{#5}%
+ \xdef\gre@cleftwoflatheight{#6}%
+}%
+
+%% macro redrawing a key from clefnum, useful for vertical space changes
+\def\gre@updatelinesclef{%
+ \GreSetLinesClef{\gre@clef}{\gre@clefheight}{1}{\gre@clefflatheight}%
+ {\gre@cleftwo}{\gre@cleftwoheight}{\gre@cleftwoflatheight}\relax %
+}%
+
+\newbox\gre@box@temp@clef%
+\newbox\gre@box@temp@cleftwo%
+% macro that typesets the clef
+% arguments are :
+%% #1: the type of the clef : c or f
+%% #2: the line of the clef (1 is the lowest)
+%% #3: if we must use small clef characters (inside a line) or not 0: if not inside, 1 if inside
+%% #4: if we must type a space after or not
+%% #5: if 3, it means that we must not put a flat after the clef, otherwise it's the height of the flat
+%% #6: the type of the secondary clef : c or f
+%% #7: the line of the secondary clef (1 is the lowest)
+%% #8: if 3, it means that we must not put a flat after the secondary clef, otherwise it's the height of the flat
+\def\gre@typeclef#1#2#3#4#5#6#7#8{%
+ \setbox\gre@box@temp@width=\hbox{%
+ \ifcase#7%
+ \gre@typesingleclef{#1}{#2}{#3}{#5}%
+ \else %
+ \ifnum\numexpr (#7 - #2) * (#7 - #2) > 1 \relax %
+ \setbox\gre@box@temp@clef=\hbox{\gre@typesingleclef{#1}{#2}{#3}{#5}}%
+ \setbox\gre@box@temp@cleftwo=\hbox{\gre@typesingleclef{#6}{#7}{#3}{#8}}%
+ \ifdim\wd\gre@box@temp@clef>\wd\gre@box@temp@cleftwo%
+ \hbox to 0pt{\copy\gre@box@temp@cleftwo}\copy\gre@box@temp@clef%
+ \else %
+ \hbox to 0pt{\copy\gre@box@temp@clef}\copy\gre@box@temp@cleftwo%
+ \fi %
+ \else %
+ \gre@typesingleclef{#1}{#2}{#3}{#5}%
+ \gre@skip@temp@two=\gre@space@skip@clefflatspace\relax%
+ \gre@hskip\gre@skip@temp@two %
+ \gre@typesingleclef{#6}{#7}{#3}{#8}%
+ \fi %
+ \fi %
+ }%
+ \ifcase#3%
+ \global\gre@dimen@clefwidth=\wd\gre@box@temp@width %
+ \fi %
+ \copy\gre@box@temp@width %
+ \gre@skip@temp@two=\gre@space@skip@spaceafterlineclef\relax%
+ \ifnum#4=0\relax %
+ \gre@skip@temp@two=\gre@space@skip@afterclefnospace\relax%
+ \fi %
+ \gre@hskip\gre@skip@temp@two %
+}%
+
+% macro that typesets one clef
+% arguments are :
+%% #1: the type of the key : c or f
+%% #2: the line of the key (1 is the lowest)
+%% #3: if we must use small key characters (inside a line) or not 0: if not inside, 1 if inside
+%% #4: if 3, it means that we must not put a flat after the key, otherwise it's the height of the flat
+\def\gre@typesingleclef#1#2#3#4{%
+ \ifcase#2 %
+ \or%
+ \gre@calculate@glyphraisevalue{\gre@pitch@c}{0}{}%
+ \or%
+ \gre@calculate@glyphraisevalue{\gre@pitch@e}{0}{}%
+ \or%
+ \gre@calculate@glyphraisevalue{\gre@pitch@g}{0}{}%
+ \or%
+ \gre@calculate@glyphraisevalue{\gre@pitch@i}{0}{}%
+ \or%
+ \gre@calculate@glyphraisevalue{\gre@pitch@k}{0}{}%
+ \fi%
+ \ifx c#1% we check if it is a c key
+ \ifcase#3%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@fontchar@cclef}{}{}%
+ \or%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@fontchar@incclef}{}{}%
+ \fi%
+ \else % we consider that it is a f key
+ \ifcase#3%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@fontchar@fclef}{}{}%
+ \or%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@fontchar@infclef}{}{}%
+ \fi%
+ \fi%
+ \ifnum#4=3%
+ \else %
+ \gre@skip@temp@four = \gre@space@skip@clefflatspace\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreFlat{#4}{1}{}{}{}%
+ \fi %
+ \relax %
+}%
+
+% macro that writes the initial key, and sets the next keys to the same value
+% if #3 is 3, it means that we must not put a flat after the key, otherwise it's the height
+% of the flat
+\def\GreSetInitialClef#1#2#3#4#5#6{%
+ \gre@save@clef{#1}{#2}{#3}{#4}{#5}{#6}%
+ \ifgre@showclef%
+ \gre@typeclef{#1}{#2}{0}{1}{#3}{#4}{#5}{#6}%
+ \else%
+ \gre@skip@temp@four = \gre@space@dimen@noclefspace\relax%
+ \hbox{\kern\gre@skip@temp@four}%
+ \fi %
+ \GreSetLinesClef{#1}{#2}{1}{#3}{#4}{#5}{#6}%
+ % if the initial is big, then we adjust the second line
+ \ifnum\gre@biginitial=0\relax %
+ \else %
+ \gre@adjustsecondline %
+ \fi %
+ \relax%
+}%
+
+% macro called when the key changes
+% #1 and #2 are the type and line of the clef
+% #3 is 1 or 0 according to the need of a space before the clef. Useful for clefs after bars for example
+% if #4 is 3, it means that we must not put a flat after the key, otherwise it's the height
+% of the flat
+\def\GreChangeClef#1#2#3#4#5#6#7{%
+ % it makes no sense to change the clef when there is no clef...
+ \gresetclef{visible}%
+ \gre@save@clef{#1}{#2}{#4}{#5}{#6}{#7}%
+ \ifnum\gre@insidediscretionary=0\relax %
+ \GreSetLinesClef{#1}{#2}{1}{#4}{#5}{#6}{#7}%
+ \fi %
+ \ifnum#3=1\relax %
+ \gre@skip@temp@four = \gre@space@skip@clefchangespace\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \else %
+ % here it means that there is a bar before the clef, so we skip the difference between the normal space and the space around bars with clef changes
+ \gre@skip@temp@four = -\gre@space@skip@spacearoundclefbars\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \gre@typeclef{#1}{#2}{1}{0}{#4}{#5}{#6}{#7}%
+ \gre@skip@temp@four = \gre@space@skip@clefchangespace\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \relax%
+}%
+
+% custos just typesets a custos, useful for before the key changes for example
+% #1 is the height
+% #2 is indicating if the custo ends the line
+\def\GreCustos#1{%
+ \ifdim\gre@skip@bar@lastskip=0pt\else % we're after a bar:
+ \kern-\gre@skip@bar@lastskip %
+ \fi %
+ \gre@skip@temp@four = \gre@space@skip@spacebeforeinlinecustos\relax%
+ \kern\gre@skip@temp@four%
+ \gre@calculate@glyphraisevalue{#1}{0}{}%
+ %here we need some tricks to draw the line before the custos (for the color)
+ \setbox\gre@box@temp@width=\hbox{\gre@pickcustos{#1}}%
+ \gre@dimen@temp@three=\wd\gre@box@temp@width %
+ \ifgre@showlines %
+ \ifnum#1<\gre@pitch@belowstaff\relax %
+ \gre@additionalbottomcustoslinemiddle %
+ \else\ifnum#1>\gre@pitch@abovestaff\relax %
+ \gre@additionaltopcustoslinemiddle %
+ \fi\fi %
+ \fi %
+ \raise \gre@dimen@glyphraisevalue\relax%
+ \copy\gre@box@temp@width %
+ \ifdim\gre@skip@bar@lastskip=0pt\relax %
+ % for now we consider we always have a bar after the custos
+ % we don't want to end the line here
+ \GreNoBreak %
+ \gre@skip@temp@four = -\gre@space@skip@spacearoundclefbars\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \else %
+ \GreNoBreak %
+ \kern\gre@skip@bar@lastskip %
+ \GreNoBreak %
+ \fi %
+ \relax %
+}%
+
+% typesets a custos for the end of the score
+\def\GreFinalCustos#1{%
+ \GreNoBreak%
+ \gre@dimen@temp@four = \glueexpr(\gre@space@skip@spacebeforeeolcustos)\relax%
+ \kern\gre@dimen@temp@four %
+ \GreNoBreak%
+ \GreCustos{#1}%
+ \gre@endofglyphcommon %
+}
+
+% the argument is the height
+\edef\gre@nextcustos{\gre@pitch@dummy}%
+\def\GreNextCustos#1{%
+ \gre@debugmsg{custos}{nextcustos = #1}%
+ \ifnum\gre@insidediscretionary=0\relax %
+ \gre@debugmsg{custos}{not discretionary}%
+ \edef\gre@nextcustos{#1}%
+ \ifgre@blockeolcustos\else%
+ \gre@debugmsg{custos}{not blocked}%
+ \gre@calculate@glyphraisevalue{#1}{0}{}%
+ %here we need some tricks to draw the line before the custos (for the color)
+ \setbox\gre@box@temp@width=\hbox{%
+ % we type a hskip and the we type the custos
+ \gre@hskip\gre@space@skip@spacebeforeeolcustos\relax %
+ \gre@pickcustos{#1}\relax %
+ }%
+ \gre@dimen@temp@three=\wd\gre@box@temp@width %
+ % we make \wd\gre@box@temp@sign contain the width of a custos
+ \setbox\gre@box@temp@sign=\hbox{%
+ \gre@pickcustos{#1}\relax %
+ }%
+ \gre@localrightbox{%
+ \ifgre@showlines %
+ \ifnum#1<\gre@pitch@belowstaff\relax %
+ \gre@additionalbottomcustoslineend %
+ \else\ifnum#1>\gre@pitch@abovestaff\relax %
+ \gre@additionaltopcustoslineend %
+ \fi\fi %
+ \fi %
+ \raise \gre@dimen@glyphraisevalue\relax%
+ \copy\gre@box@temp@width %
+ }%
+ \fi %
+ \fi %
+ \relax%
+}%
+
+% macro that typesets an additional line at the top for custos at end of line
+
+\def\gre@additionaltopcustoslineend{%
+ \gre@dimen@temp@five=\dimexpr(\gre@dimen@staffheight %
+ + \gre@space@dimen@spacebeneathtext %
+ + \gre@space@dimen@spacelinestext %
+ + \gre@dimen@interstafflinespace %
+ + \gre@dimen@additionalbottomspace %
+ + \gre@dimen@currenttranslationheight)\relax %
+ \raise\gre@dimen@temp@five %
+ \hbox to 0pt{%
+ \gre@style@additionalstafflines %
+ \ifx\gre@empty@additionalstafflinesformat\greadditionalstafflinesformat% OBSOLETE
+ \else % OBSOLETE
+ \gre@obsolete{\protect\greadditionalstafflinesformat}{\protect\grechangestyle{additionalstafflinesformat}}% OBSOLETE
+ \fi% OBSOLETE
+ \kern\gre@dimen@temp@three %
+ \gre@dimen@temp@five=\dimexpr(\wd\gre@box@temp@sign + \gre@space@dimen@additionalcustoslineswidth)\relax%
+ \kern-\gre@dimen@temp@five %
+ \vrule width \gre@dimen@temp@five height \gre@dimen@stafflineheight\relax%
+ \hss %
+ \endgre@style@additionalstafflines%
+ }%
+ \relax %
+}%
+
+\def\gre@additionalbottomcustoslineend{%
+ \gre@dimen@temp@five=\dimexpr(\gre@space@dimen@spacebeneathtext %
+ + \gre@space@dimen@spacelinestext %
+ + \gre@dimen@additionalbottomspace %
+ + \gre@dimen@currenttranslationheight %
+ - \gre@dimen@interstafflinespace %
+ - \gre@dimen@stafflineheight)\relax %
+ \raise\gre@dimen@temp@five %
+ \hbox to 0pt{%
+ \gre@style@additionalstafflines %
+ \ifx\gre@empty@additionalstafflinesformat\greadditionalstafflinesformat% OBSOLETE
+ \else % OBSOLETE
+ \gre@obsolete{\protect\greadditionalstafflinesformat}{\protect\grechangestyle{additionalstafflinesformat}}% OBSOLETE
+ \fi% OBSOLETE
+ \kern\gre@dimen@temp@three %
+ \gre@dimen@temp@five=\dimexpr(\wd\gre@box@temp@sign+\gre@space@dimen@additionalcustoslineswidth)\relax%
+ \kern-\gre@dimen@temp@five %
+ \vrule width \gre@dimen@temp@five height \gre@dimen@stafflineheight\relax%
+ \hss %
+ \endgre@style@additionalstafflines%
+ }%
+ \relax %
+}%
+
+% same macros, but for a custos in the middle
+
+\def\gre@additionaltopcustoslinemiddle{%
+ \gre@dimen@temp@five=\dimexpr(\gre@dimen@staffheight %
+ + \gre@space@dimen@spacebeneathtext %
+ + \gre@space@dimen@spacelinestext %
+ + \gre@dimen@interstafflinespace %
+ + \gre@dimen@additionalbottomspace %
+ + \gre@dimen@currenttranslationheight)\relax%
+ \raise\gre@dimen@temp@five %
+ \hbox to 0pt{%
+ \gre@style@additionalstafflines %
+ \ifx\gre@empty@additionalstafflinesformat\greadditionalstafflinesformat% OBSOLETE
+ \else % OBSOLETE
+ \gre@obsolete{\protect\greadditionalstafflinesformat}{\protect\grechangestyle{additionalstafflinesformat}}% OBSOLETE
+ \fi% OBSOLETE
+ \hss %
+ \kern\gre@dimen@temp@three %
+ \gre@dimen@temp@five=\dimexpr((\gre@space@dimen@additionalcustoslineswidth*2)+\wd\gre@box@temp@sign)\relax %
+ \vrule width \gre@dimen@temp@five height \gre@dimen@stafflineheight\relax%
+ \hss %
+ \endgre@style@additionalstafflines%
+ }%
+ \relax %
+}%
+
+\def\gre@additionalbottomcustoslinemiddle{%
+ \gre@dimen@temp@five=\dimexpr(\gre@space@dimen@spacebeneathtext %
+ + \gre@space@dimen@spacelinestext %
+ + \gre@dimen@additionalbottomspace %
+ + \gre@dimen@currenttranslationheight %
+ - \gre@dimen@interstafflinespace %
+ - \gre@dimen@stafflineheight)\relax%
+ \raise\gre@dimen@temp@five %
+ \hbox to 0pt{%
+ \gre@style@additionalstafflines %
+ \ifx\gre@empty@additionalstafflinesformat\greadditionalstafflinesformat% OBSOLETE
+ \else % OBSOLETE
+ \gre@obsolete{\protect\greadditionalstafflinesformat}{\protect\grechangestyle{additionalstafflinesformat}}% OBSOLETE
+ \fi% OBSOLETE
+ \hss %
+ \kern\gre@dimen@temp@three %
+ \gre@dimen@temp@five=\dimexpr((\gre@space@dimen@additionalcustoslineswidth*2)+\wd\gre@box@temp@sign)\relax %
+ \vrule width \gre@dimen@temp@five height \gre@dimen@stafflineheight\relax%
+ \hss %
+ \endgre@style@additionalstafflines%
+ }%
+ \relax %
+}%
+
+\def\gre@pickcustos#1{%
+ \ifcase#1%
+ \or\or%
+ \or\gre@fontchar@custostopmiddle %
+ \or\gre@fontchar@custostoplong %
+ \or\gre@fontchar@custostopshort %
+ \or\gre@fontchar@custostoplong %
+ \or\gre@fontchar@custostopshort %
+ \or %
+ \ifgre@haslinethree %
+ \gre@fontchar@custostoplong %
+ \else %
+ \gre@fontchar@custosbottomlong %
+ \fi %
+ \or %
+ \ifgre@haslinethree %
+ \gre@fontchar@custostopshort %
+ \else %
+ \gre@fontchar@custosbottomshort %
+ \fi %
+ \or %
+ \ifgre@haslinefour %
+ \gre@fontchar@custostoplong %
+ \else %
+ \gre@fontchar@custosbottomlong %
+ \fi %
+ \or %
+ \ifgre@haslinefour %
+ \gre@fontchar@custostopshort %
+ \else %
+ \ifgre@haslinethree %
+ \gre@fontchar@custosbottomshort %
+ \else %
+ \gre@fontchar@custosbottommiddle %
+ \fi %
+ \fi %
+ \or %
+ \ifgre@haslinefive %
+ \gre@fontchar@custostoplong %
+ \else %
+ \gre@fontchar@custosbottomlong %
+ \fi %
+ \or %
+ \ifgre@haslinefive %
+ \gre@fontchar@custostopshort %
+ \else %
+ \ifgre@haslinefour %
+ \gre@fontchar@custosbottomshort %
+ \else %
+ \gre@fontchar@custosbottommiddle %
+ \fi %
+ \fi %
+ \or\gre@fontchar@custosbottomlong %
+ \or %
+ \ifgre@haslinefive %
+ \gre@fontchar@custosbottomshort %
+ \else %
+ \gre@fontchar@custosbottommiddle %
+ \fi %
+ \or\gre@fontchar@custosbottomlong %
+ \or\gre@fontchar@custosbottommiddle %
+ \fi%
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% macros for the typesetting of braces and other things above the score
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newif\ifgre@metapost@brace\gre@metapost@bracetrue %
+\newif\ifgre@metapost@underbrace\gre@metapost@underbracetrue %
+\newif\ifgre@metapost@curlybrace\gre@metapost@curlybracetrue %
+\newif\ifgre@metapost@barbrace\gre@metapost@barbracetrue %
+\def\gresetbracerendering{%
+ \@ifnextchar[{\gre@setbracerendering}{\gre@setallbracerendering}%
+}%
+\def\gre@setallbracerendering#1{%
+ \gre@@setbracerendering{brace}{#1}%
+ \gre@@setbracerendering{underbrace}{#1}%
+ \gre@@setbracerendering{curlybrace}{#1}%
+ \gre@@setbracerendering{barbrace}{#1}%
+}%
+\def\gre@setbracerendering[#1]#2{%
+ \IfStrEqCase{#1}{%
+ {brace}{\gre@@setbracerendering{#1}{#2}}%
+ {underbrace}{\gre@@setbracerendering{#1}{#2}}%
+ {curlybrace}{\gre@@setbracerendering{#1}{#2}}%
+ {barbrace}{\gre@@setbracerendering{#1}{#2}}%
+ }[\gre@error{Unrecognized option "#1" for \protect\gresetbracerendering\MessageBreak Possible options are: 'brace', 'underbrace', 'curlybrace', and 'barbrace'}]%
+}%
+\def\gre@@setbracerendering#1#2{%
+ \IfStrEqCase{#2}{%
+ {font}{\csname gre@metapost@#1false\endcsname}%
+ {metapost}{\csname gre@metapost@#1true\endcsname}%
+ }[\gre@error{Unrecognized option "#2" for \protect\gresetbracerendering\MessageBreak Possible options are: 'font' and 'metapost'}]%
+}%
+
+\gdef\gre@fontchar@curlybrace{\gre@font@music\GreCPCurlyBrace}%
+\gdef\gre@fontchar@brace{\gre@font@music\GreCPRoundBrace}%
+\gdef\gre@fontchar@underbrace{\gre@font@music\GreCPRoundBraceDown}%
+
+% the command to resize a box, \resizebox is provided by graphicx
+\global\let\gre@resizebox\resizebox %
+
+% #1: the width
+% #2: a vertical shift
+% #3: a horizontal shift
+% #4: 1 if we shift to the beginning of the last glyph, 0 otherwise
+% #5: 1 if we put an accentus above or not
+\def\GreOverCurlyBrace#1#2#3#4#5{%
+ \ifgre@boxing\else %
+ \gre@brace@common{#1}{#2}{#3}{#4}{#5}{\gre@pitch@overbraceglyph}{\gre@fontchar@curlybrace}%
+ \fi %
+}%
+
+% #1: the width
+% #2: a vertical shift
+% #3: a horizontal shift
+% #4: 1 if we shift to the beginning of the last glyph, 0 otherwise
+\def\GreOverBrace#1#2#3#4{%
+ \ifgre@boxing\else %
+ \gre@brace@common{#1}{#2}{#3}{#4}{0}{\gre@pitch@overbraceglyph}{\gre@fontchar@brace}%
+ \fi %
+}%
+
+% #1: the width
+% #2: a vertical shift
+% #3: a horizontal shift
+% #4: 1 if we shift to the beginning of the last glyph, 0 otherwise
+\def\GreUnderBrace#1#2#3#4{%
+ \ifgre@boxing\else %
+ \gre@brace@common{#1}{#2}{#3}{#4}{0}{\gre@pitch@underbrace}{\gre@fontchar@underbrace}%
+ \fi %
+}%
+
+% #1: the width
+% #2: a vertical shift
+% #3: a horizontal shift
+% #4: 1 if we shift to the beginning of the last glyph, 0 otherwise
+% #5: 1 if we put an accentus above, 0 if not
+% #6: the pitch at which to compute the height
+% #7: the brace character
+\def\gre@brace@common#1#2#3#4#5#6#7{%
+ \ifnum#4=1\relax %
+ \setbox\gre@box@temp@sign=\hbox{\gre@fontchar@punctum}%
+ \gre@dimen@temp@five=\wd\gre@box@temp@sign %
+ \kern-\gre@dimen@temp@five %
+ \fi %
+ \gre@calculate@glyphraisevalue{#6}{13}{}%
+ \advance\gre@dimen@glyphraisevalue by #2\relax %
+ \hbox to 0pt{%
+ \gre@skip@temp@four = #3\relax %
+ \kern\gre@skip@temp@four %
+ \raise\gre@dimen@glyphraisevalue\hbox{%
+ \ifx#7\gre@fontchar@curlybrace %
+ \ifgre@metapost@curlybrace %
+ \gre@draw@curlybrace{#1}%
+ \else %
+ \gre@draw@fontbrace{#1}{#7}%
+ \fi %
+ \else %
+ \ifx#7\gre@fontchar@brace %
+ \ifgre@metapost@brace %
+ \gre@draw@brace{#1}%
+ \else %
+ \gre@draw@fontbrace{#1}{#7}%
+ \fi %
+ \else %
+ \ifx#7\gre@fontchar@underbrace %
+ \ifgre@metapost@underbrace %
+ \gre@draw@underbrace{#1}%
+ \else %
+ \gre@draw@fontbrace{#1}{#7}%
+ \fi %
+ \fi %
+ \fi %
+ \fi %
+ }%
+ \hss %
+ \ifnum#5=1\relax %
+ \gre@calculate@glyphraisevalue{\gre@pitch@overbrace}{13}{}%
+ \advance\gre@dimen@glyphraisevalue by \gre@space@dimen@curlybraceaccentusshift\relax%
+ \raise\gre@dimen@glyphraisevalue\hbox{%
+ \gre@font@music\GreCPAccentus\relax %
+ }%
+ \hss %
+ \fi %
+ }%
+ \ifnum#4=1\relax %
+ \kern\gre@dimen@temp@five %
+ \fi %
+ \relax %
+}%
+% #1 : the width
+% #2 : the brace character
+\def\gre@draw@fontbrace#1#2{%
+ \setbox\gre@box@temp@sign=\hbox{#2}%
+ \gre@resizebox{#1}{\ht\gre@box@temp@sign}{#2}%
+}%
+
+% #1: the width, or * for the bar brace width
+% this can't have @ in the name because of the metapost catcode settings
+\def\grebracemetapostpreamble#1{%
+ % multiplier to convert gre@factor to em-size in bp
+ % (100000 sp) * (72 bp/in) / (65536 sp/pt) / 72.27 (pt/in)
+ factor = 1.5201782378;
+ scale = \the\gre@factor * factor;
+ % assuming #1 is in bp, we convert it back into the internal unit of the
+ % calculation, ems
+ width = \directlua{gregoriotex.width_to_bp([[#1]], "\grebarbracewidth * scale")} / scale;
+}%
+
+% #1: the width
+\def\gre@draw@curlybrace#1{%
+ \gre@debugmsg{general}{curly brace width = #1}%
+ \gre@metapost{
+ \grebracemetapostpreamble{#1}
+ transform t;
+ t = identity scaled scale;
+ p := (width - 0.1416) / 2;
+ q := (width - 0.08626) / 2;
+ if (p < 0.1005) or (q < 0.12817):
+ t := t xscaled (width / 0.34261);
+ p := 0.1005;
+ q := 0.12817;
+ fi;
+ f := 1 + (p / 4);
+ beginfig(0);
+ fill
+ ( (0,0)
+ -- (0.00651,0)
+ .. controls (((0.03239**f)*p)+0.00651,0.01763) and (((0.08502**f)*p)+0.00651,0.03065) .. (((0.15789**f)*p)+0.00651,0.03906)
+ .. controls (((0.23347**f)*p)+0.00651,0.04801) and (((0.32659**f)*p)+0.00651,0.05249) .. (((0.43725**f)*p)+0.00651,0.05249)
+ .. controls (((0.49663**f)*p)+0.00651,0.05249) and (((0.59109**f)*p)+0.00651,0.05086) .. (((0.72065**f)*p)+0.00651,0.04761)
+ .. controls (((0.82861**f)*p)+0.00651,0.04408) and (((0.92173**f)*p)+0.00651,0.04232) .. (p+0.00651,0.04232)
+ .. controls (p+0.0198,0.04232) and (p+0.03242,0.04842) .. (p+0.04435,0.06063)
+ .. controls (p+0.05602,0.07365) and (p+0.06483,0.0906) .. (p+0.0708,0.11149)
+ .. controls (p+0.07677,0.0906) and (p+0.08558,0.07365) .. (p+0.09725,0.06063)
+ .. controls (p+0.10918,0.04842) and (p+0.1218,0.04232) .. (p+0.13509,0.04232)
+ .. controls (p+((1-(0.92173**f))*p)+0.13509,0.04232) and (p+((1-(0.82861**f))*p)+0.13509,0.04408) .. (p+((1-(0.72065**f))*p)+0.13509,0.04761)
+ .. controls (p+((1-(0.59109**f))*p)+0.13509,0.05086) and (p+((1-(0.49663**f))*p)+0.13509,0.05249) .. (p+((1-(0.43725**f))*p)+0.13509,0.05249)
+ .. controls (p+((1-(0.32659**f))*p)+0.13509,0.05249) and (p+((1-(0.23347**f))*p)+0.13509,0.04801) .. (p+((1-(0.15789**f))*p)+0.13509,0.03906)
+ .. controls (p+((1-(0.08502**f))*p)+0.13509,0.03065) and (p+((1-(0.03239**f))*p)+0.13509,0.01763) .. (p+p+0.13509,0)
+ -- (p+p+0.13509,0) -- (q+q+0.08626,0) -- (q+q+0.08626,0)
+ .. controls (q+((1-(0.02117**f))*q)+0.08626,0.02658) and (q+((1-(0.08466**f))*q)+0.08626,0.04774) .. (q+((1-(0.19048**f))*q)+0.08626,0.06348)
+ .. controls (q+((1-(0.29418**f))*q)+0.08626,0.07975) and (q+((1-(0.42434**f))*q)+0.08626,0.08789) .. (q+((1-(0.58095**f))*q)+0.08626,0.08789)
+ .. controls (q+((1-(0.63386**f))*q)+0.08626,0.08789) and (q+((1-(0.70159**f))*q)+0.08626,0.08626) .. (q+((1-(0.78413**f))*q)+0.08626,0.08301)
+ .. controls (q+((1-(0.87937**f))*q)+0.08626,0.07894) and (q+((1-(0.95132**f))*q)+0.08626,0.0769) .. (q+0.08626,0.0769)
+ .. controls (q+0.06219,0.0769) and (q+0.05013,0.10644) .. (q+0.04679,0.13102)
+ -- (q+0.04679,0.13102) -- (q+0.03947,0.13102) -- (q+0.03947,0.13102)
+ .. controls (q+0.03614,0.10644) and (q+0.02407,0.0769) .. (q+0,0.0769)
+ .. controls (((0.95132**f)*q)+0,0.0769) and (((0.87937**f)*q)+0,0.07894) .. (((0.78413**f)*q)+0,0.08301)
+ .. controls (((0.70159**f)*q)+0,0.08626) and (((0.63386**f)*q)+0,0.08789) .. (((0.58095**f)*q)+0,0.08789)
+ .. controls (((0.42434**f)*q)+0,0.08789) and (((0.29418**f)*q)+0,0.07975) .. (((0.19048**f)*q)+0,0.06348)
+ .. controls (((0.08466**f)*q)+0,0.04774) and (((0.02117**f)*q)+0,0.02658) .. (0,0)
+ -- cycle
+ ) transformed t;
+ setbounds currentpicture to
+ ( (0,-0.67980) -- (q+q+0.08626,-0.67980) -- (q+q+0.08626,0.13102) -- (0,0.13102) -- cycle )
+ transformed t;
+ endfig;
+ }%
+}%
+
+% #1: the width
+\def\gre@draw@brace#1{%
+ \gre@draw@roundbrace{#1}{.89500}{
+ (-.00192,.70347) % start the top
+ .. controls (-.00192,.70525) and (-.00134,.70740)
+ .. (.00000,.71000) -- (.00000,.71000){curl c}
+ .. (p/2,.89500) % top of the center
+ .. {curl c}(p,.71000) -- (p,.71000)
+ .. controls (p+.00134,.70740) and (p+.00192,.70525)
+ .. (p+.00192,.70347) % end the top
+ .. controls (p+.00192,.69508) and (p-.01103,.69500)
+ .. (p-.01856,.69500) % start the bottom
+ .. controls (p-.01856,.69500) and (p-.01900,.69500)
+ .. (p-.01900,.69500) -- (p-.01900,.69500){curl c}
+ .. (p/2,.86400) % bottom of the center
+ .. {curl c}(.01900,.69500) -- (.01900,.69500)
+ .. controls (.01900,.69500) and (.01856,.69500)
+ .. (.01856,.69500) % end the bottom
+ .. controls (.01103,.69500) and (-.00192,.69508)
+ .. (-.00192,.70347) -- cycle
+ }%
+}%
+
+% #1: the width
+\def\gre@draw@underbrace#1{%
+ \gre@draw@roundbrace{#1}{.25500}{
+ (-.00192,.24653) % start the bottom
+ .. controls (-.00192,.24475) and (-.00134,.24260)
+ .. (.00000,.24000) -- (.00000,.24000){curl c}
+ .. (p/2,.05500) % bottom of the center
+ .. {curl c}(p,.24000) -- (p,.24000)
+ .. controls (p+.00134,.24260) and (p+.00192,.24475)
+ .. (p+.00192,.24653) % end the bottom
+ .. controls (p+.00192,.25492) and (p-.01103,.25500)
+ .. (p-.01856,.25500) % start the top
+ .. controls (p-.01856,.25500) and (p-.01900,.25500)
+ .. (p-.01900,.25500) -- (p-.01900,.25500){curl c}
+ .. (p/2,.08600) % top to the center
+ .. {curl c}(.01900,.25500) -- (.01900,.25500)
+ .. controls (.01900,.25500) and (.01856,.25500)
+ .. (.01856,.25500) % end the top
+ .. controls (.01103,.25500) and (-.00192,.25492)
+ .. (-.00192,.24653) -- cycle
+ }%
+}%
+
+% #1: the width
+% #2: height of the bounding box
+% #3: metapost commands to draw the outline
+\def\gre@draw@roundbrace#1#2#3{%
+ \gre@debugmsg{general}{round brace width = #1}%
+ \gre@metapost{
+ \grebracemetapostpreamble{#1}
+ p = width;
+ transform t;
+ t = identity scaled scale;
+ c = 1;
+ if p < 0.200:
+ c := 0;
+ t := t xscaled (p/0.200);
+ p := 0.200;
+ elseif p < 0.350:
+ c := (p - 0.200) / 0.350;
+ fi;
+ beginfig(0);
+ fill ( #3 ) transformed t;
+ setbounds currentpicture to
+ ( (0,0) -- (p,0) -- (p,#2) -- (0,#2) -- cycle )
+ transformed t;
+ endfig;
+ }%
+}%
+
+% #1 : x-distance
+% #2 : y-distance
+% #3 : -1 for below, 1 for above
+\def\gre@draw@slur#1#2#3{%
+ \gre@metapost{
+ \grebracemetapostpreamble{\directlua{gregoriotex.hypotenuse([[#1]],[[#2]])}}
+ transform t;
+ t = identity scaled scale;
+ t := t xscaled width;
+ t := t rotated \directlua{gregoriotex.rotation([[#1]],[[#2]])};
+ beginfig(0);
+ fill
+ ( (0,0)
+ .. controls (0.3,#3*0.20) and (0.7,#3*0.20)
+ .. (1,0)
+ -- (1,0)
+ .. controls (0.7,#3*0.22) and (0.3,#3*0.22)
+ .. (0,0)
+ -- cycle
+ ) transformed t withpen pencircle scaled 0.3;
+ endfig;
+ }%
+}%
+
+\newdimen\greslurheight
+% #1 : height
+% #2 : -1 for below, 1 for above
+% #3 : 0 = no left-shift, 1 = left-shift 1 punctum, 2 = left shift 1/2 punctum
+% #4 : x-distance
+% #5 : y-distance
+% #6 : end height if #6 not given
+\def\GreSlur#1#2#3#4#5#6{%
+ \ifgre@boxing\else %
+ \ifnum\number#2 > 0\relax %
+ \gre@calculate@glyphraisevalue{#1}{15}{}%
+ \else %
+ \gre@calculate@glyphraisevalue{#1}{16}{}%
+ \fi %
+ \hbox to 0pt{\raise\gre@dimen@glyphraisevalue\hbox{%
+ \ifcase#3 % 0
+ \or % 1
+ \setbox\gre@box@temp@sign=\hbox{\gre@fontchar@punctum}%
+ \kern-\wd\gre@box@temp@sign %
+ \or % 2
+ \setbox\gre@box@temp@sign=\hbox{\gre@fontchar@punctum}%
+ \kern-.5\wd\gre@box@temp@sign %
+ \fi %
+ \if\relax\detokenize{#5}\relax %
+ \gre@dimen@temp@five=\gre@dimen@glyphraisevalue\relax %
+ \ifnum\number#2 > 0\relax %
+ \gre@calculate@glyphraisevalue{#6}{15}{}%
+ \else %
+ \gre@calculate@glyphraisevalue{#6}{16}{}%
+ \fi %
+ \greslurheight = \dimexpr(\gre@dimen@glyphraisevalue - \gre@dimen@temp@five)\relax %
+ \else %
+ \greslurheight = #5\relax %
+ \fi %
+ \gre@draw@slur{#4}{\the\greslurheight}{#2}%
+ }}%
+ \fi %
+ \relax %
+}%
+
+% #1: id of the variable length brace within the score
+\def\GreVarBraceLength#1{%
+ \ifgre@boxing\else %
+ \directlua{gregoriotex.var_brace_len(#1)}%
+ \fi %
+}%
+
+% #1: id of the variable length brace within the score
+% #2: 0 = no left-shift, 1 = left-shift 1 punctum, 2 = left shift 1/2 punctum
+% #3: 1 if the start, 2 if the end
+\def\GreVarBraceSavePos#1#2#3{%
+ \ifgre@boxing\else %
+ \ifcase#2 % 0
+ \gre@debugmsg{general}{save case 0}%
+ \pdfsavepos %
+ \or % 1
+ \setbox\gre@box@temp@sign=\hbox{\gre@fontchar@punctum}%
+ \kern-\wd\gre@box@temp@sign %
+ \pdfsavepos %
+ \kern\wd\gre@box@temp@sign %
+ \or % 2
+ \gre@debugmsg{general}{save case 2}%
+ \setbox\gre@box@temp@sign=\hbox{\gre@fontchar@punctum}%
+ \gre@dimen@temp@five=\wd\gre@box@temp@sign %
+ \kern-.5\wd\gre@box@temp@sign %
+ \pdfsavepos %
+ \kern.5\wd\gre@box@temp@sign %
+ \fi %
+ \directlua{gregoriotex.var_brace_note_pos(#1, #3)}%
+ \fi %
+ \relax %
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% macros for the typesetting of punctum mora, auctum duplex and choral signs
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% a function to typeset a punctum mora,
+% #1 is the letter of the height of the punctum mora
+% #2 is
+% - 0 in the general case
+% - 1 if we make the punctum mora 0-width (e.g!hv)
+% - 2 if we shift the width of one punctum to the left (g.e)
+% - 3 same as 2 but with ambitus of one (g.f)
+% #3 is 1 in case of a punctommora in the note before the last note of a podatus, porrectus or torculus resupinus, 0 otherwise.
+% #4 is 1 if we are at a punctum inclinatum, 0 otherwise
+\def\gre@punctum@mora#1#2#3#4{%
+ \GreNoBreak %
+ \ifcase#2\relax %
+ \gre@skip@temp@four = \gre@space@skip@spacebeforesigns\relax%
+ \hskip\gre@skip@temp@four%
+ \or %
+ \gre@skip@temp@four = \gre@space@skip@spacebeforesigns\relax%
+ \kern\gre@skip@temp@four %
+ \or %
+ % to get the widht of a punctum minus a line, we calculate the width of a flexus (with ambitus of two) minus the width of a punctum
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPPesQuadratumLongqueueThreeNothing}%
+ \gre@dimen@temp@five=\wd\gre@box@temp@width %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPPunctum}%
+ \advance\gre@dimen@temp@five by -\wd\gre@box@temp@width %
+ \kern-\gre@dimen@temp@five %
+ \gre@skip@temp@four = \gre@space@skip@spacebeforesigns\relax%
+ \kern\gre@skip@temp@four %
+ \or %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPPunctum}%
+ \gre@dimen@temp@five=\wd\gre@box@temp@width %
+ \kern-\gre@dimen@temp@five %
+ \gre@skip@temp@four = \gre@space@skip@spacebeforesigns\relax%
+ \kern\gre@skip@temp@four %
+ \fi %
+ \ifnum#2=0\relax %
+ \global\gre@lastendswithmoratrue%
+ \fi %
+ \ifcase#3\relax % 0
+ \gre@calculate@glyphraisevalue{#1}{4}{}%
+ \or% 1
+ \gre@calculate@glyphraisevalue{#1}{8}{}%
+ \or% 2
+ \gre@calculate@glyphraisevalue{#1}{14}{}%
+ \fi %
+ % here we shift a bit left in the case where we have a punctum inclinatum on a line
+ \ifnum#4=1\relax %
+ \ifgre@isonaline %
+ \gre@dimen@temp@three=\dimexpr(3700sp * \gre@factor)\relax %
+ \kern-\gre@dimen@temp@three %
+ \gre@dimen@temp@three=\dimexpr(4500sp * \gre@factor)\relax%
+ \advance\gre@dimen@glyphraisevalue by -\gre@dimen@temp@three %
+ \else %
+ \gre@dimen@temp@three=\dimexpr(2500sp * \gre@factor)\relax %
+ \advance\gre@dimen@glyphraisevalue by -\gre@dimen@temp@three %
+ \fi %
+ \fi %
+ \GreNoBreak %
+ \raise \gre@dimen@glyphraisevalue \hbox{\gre@fontchar@punctummora}%
+ \GreNoBreak %
+ \ifcase#2\relax\or %
+ \setbox\gre@box@temp@width=\hbox{\gre@fontchar@punctummora}%
+ \gre@skip@temp@four = -\wd\gre@box@temp@width %
+ \kern\gre@skip@temp@four%
+ \gre@skip@temp@four = -\gre@space@skip@spacebeforesigns\relax%
+ \kern\gre@skip@temp@four %
+ \or %
+ \setbox\gre@box@temp@width=\hbox{\gre@fontchar@punctummora}%
+ \gre@skip@temp@four = -\wd\gre@box@temp@width %
+ \kern\gre@skip@temp@four%
+ \gre@skip@temp@four = -\gre@space@skip@spacebeforesigns\relax%
+ \kern\gre@skip@temp@four %
+ \kern\gre@dimen@temp@five %
+ \or %
+ \setbox\gre@box@temp@width=\hbox{\gre@fontchar@punctummora}%
+ \gre@skip@temp@four = -\wd\gre@box@temp@width %
+ \kern\gre@skip@temp@four%
+ \gre@skip@temp@four = -\gre@space@skip@spacebeforesigns\relax%
+ \kern\gre@skip@temp@four %
+ \kern\gre@dimen@temp@five %
+ \fi %
+ \GreNoBreak %
+ \relax%
+}%
+
+\def\GrePunctumMora#1#2#3#4{%
+ \ifgre@disablemora\else %
+ \gre@punctum@mora{#1}{#2}{#3}{#4}%
+ \fi %
+ \relax %
+}
+
+% a function to typeset an augmentum duplex, easy enough to be understood...
+\def\GreAugmentumDuplex#1#2#3{%
+ \ifgre@boxing\else %
+ \GrePunctumMora{#1}{1}{#3}{0}%
+ \fi %
+ \GrePunctumMora{#2}{0}{0}{0}%
+ \relax %
+}%
+
+\gdef\grelowchoralsignstyle#1{\relax}% OBSOLETE
+\let\gre@empty@lowchoralsignstyle\grelowchoralsignstyle%
+\gdef\grehighchoralsignstyle#1{\relax}% OBSOLETE
+\let\gre@empty@highchoralsignstyle\grehighchoralsignstyle%
+
+% quite simple function: #1 is the height, #2 is the string, #3 is #2 of punctum mora, #4 is #3 of punctum mora
+% #3 is 1 if it must be a bit higher
+\def\GreLowChoralSign#1#2#3{%
+ \GreNoBreak %
+ \gre@skip@temp@four = \gre@space@skip@beforelowchoralsignspace\relax%
+ \hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \ifnum#3=1\relax %
+ \gre@calculate@glyphraisevalue{#1}{12}{}%
+ \else %
+ \gre@calculate@glyphraisevalue{#1}{10}{}%
+ \fi %
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@style@lowchoralsign#2\endgre@style@lowchoralsign}%
+ \ifx\gre@empty@lowchoralsignstyle\grelowchoralsignstyle% OBSOLETE
+ \else% OBSOLETE
+ \gre@obsolete{\protect\grelowchoralsignstyle}{\protect\grechangestyle{lowchoralsign}}% OBSOLETE
+ \fi% OBSOLETE
+ \relax %
+}%
+
+\def\GreHighChoralSign#1#2#3{%
+ \GreNoBreak %
+ \gre@vepisemaorrare{#1}{#3}{}{3}{\gre@style@highchoralsign#2\endgre@style@highchoralsign}%
+ \ifx\gre@empty@highchoralsignstyle\grehighchoralsignstyle% OBSOLETE
+ \else% OBSOLETE
+ \gre@obsolete{\protect\grehighchoralsignstyle}{\protect\grechangestyle{highchoralsign}}% OBSOLETE
+ \fi% OBSOLETE
+ \relax %
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% macros for the typesetting of linea
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\def\GreLinea#1#2#3#4#5#6{%
+ \GreGlyph{\GreCPLinea}{#1}{#2}{#3}{#4}{#5}{#6}%
+ \relax %
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% macros for the typesetting of vertical episema
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newbox\gre@box@temp@sign%
+
+% a macro to help typesetting vertical episema.
+% #1 is an offset glyph (see #3 below)
+% #2 represents the glyph upon which the sign is to be centered
+% #3 is a case number
+% 0 : go back to the beginning of the previous glyph and then forward half
+% the width of #2; this puts the sign at the beginning of the previous
+% glyph, whose first note is the size of #2
+% 1 : go back half the width of #2; this puts the sign at the end of the
+% previous glyph, whose last note is the size of #2
+% 2 : go back the width of #1 and then foward half the width of #2; this
+% puts the sign at the glyph from the end that starts at #1's width from
+% the end
+% 3 : go back to the beginning of the previous glyph and then forward the
+% width of #1 and then back half the width of #2; this puts the sign at
+% the glyph from the start that ends at #1's width from the start
+% #4 is a shift that we want to get applied, useful for punctum inclinatum for example
+% #5 is the glyph number.
+% #6 is the type of sign (1: vertical episema, 2: rare sign, 3: choral sign)
+% #7 is the choral sign if relevant
+\def\gre@vepisemaorrareaux#1#2#3#4#5#6#7{%
+ % first we set \gre@dimen@temp@three to the width of the last glyph
+ \gre@dimen@temp@three=\gre@dimen@lastglyphwidth\relax%
+ \setbox\gre@box@temp@sign=\hbox{\gre@font@music #2}%
+ \gre@dimen@temp@two=\dimexpr(\wd\gre@box@temp@sign / 2)\relax %
+ \ifcase#3%
+ % tempwidth is the width of the last glyph
+ \advance\gre@dimen@temp@three by -\gre@dimen@temp@two %
+ \or%
+ \gre@dimen@temp@three=\gre@dimen@temp@two %
+ \or%
+ \setbox\gre@box@temp@sign=\hbox{\gre@font@music #1}%
+ \gre@dimen@temp@three=\dimexpr(\wd\gre@box@temp@sign - \gre@dimen@temp@two)\relax %
+ \or %
+ \setbox\gre@box@temp@sign=\hbox{\gre@font@music #1}%
+ \advance\gre@dimen@temp@three by \dimexpr(-\wd\gre@box@temp@sign + \gre@dimen@temp@two)\relax %
+ \fi%
+ \kern-\gre@dimen@temp@three % we do it here because of the now-removed ictus (chironomy)
+ % then we draw the sign
+ \ifcase#6\or %
+ % vertical episema
+ \setbox\gre@box@temp@sign=\hbox{\gre@fontchar@verticalepisema}%
+ \or % rare sign
+ \setbox\gre@box@temp@sign=\hbox{\gre@font@music#5}%
+ \or % choral sign
+ \setbox\gre@box@temp@sign=\hbox{#7}%
+ \or % brace above bar
+ \setbox\gre@box@temp@sign=\hbox{\gre@render@barbrace}%
+ \fi %
+ % we set tempwidth to half a punctum malus half the sign width, so that the centers are aligned
+ \gre@dimen@temp@two=\dimexpr(\wd\gre@box@temp@sign / 2)\relax %
+ \advance\gre@dimen@temp@three by \gre@dimen@temp@two %
+ \kern-\gre@dimen@temp@two%
+ \gre@skip@temp@four = #4sp%
+ \kern \gre@skip@temp@four%
+ \raise \gre@dimen@glyphraisevalue \copy\gre@box@temp@sign %
+ \kern -\gre@skip@temp@four%
+ % and finally we go back to the end of the glyph, where we were first
+ \advance\gre@dimen@temp@three by -2\gre@dimen@temp@two %
+ \kern\gre@dimen@temp@three%
+ \relax%
+}%
+
+\directlua{gregoriotex.emit_offset_macros()}%
+
+% a function to typeset a vertical episema or a rare accent (like accentus,
+% circulus, etc.). This function must be called after a call to \GreGlyph.
+% #1 is the letter of the height of the episema (not the height of the note
+% it corresponds to.
+% #2 is note position case as in the table above
+% #3 is the sign glyph
+% #4 is type (1: vertical episema, 2: rare sign, 3: choral sign, 4: brace above the bar)
+% #5 is the choral sign if relevant
+\def\gre@vepisemaorrare#1#2#3#4#5{%
+ \ifgre@boxing\else %
+ \ifcase#4\or %
+ % if it is a vertical episema, we call the normal calculateglyphvalue
+ \gre@calculate@glyphraisevalue{#1}{3}{}%
+ \or %
+ % if it is not, we call it with 6 as second argument, it will give us the height of the rare signs (accentus, etc.) the first argument is m if the pitch is < k, otherwise it's n.
+ \ifnum#1<\gre@pitch@raresign\relax %
+ \gre@calculate@glyphraisevalue{\gre@pitch@raresign}{6}{}%
+ \else %
+ {%
+ \gre@count@temp@three=\numexpr(#1 + 1)\relax %
+ \gre@calculate@glyphraisevalue{\gre@count@temp@three}{6}{}%
+ }%
+ \fi %
+ \or % if it's a choral sign
+ \gre@calculate@glyphraisevalue{#1}{11}{}%
+ \or % if it's the brace above the bar
+ \gre@calculate@glyphraisevalue{#1}{13}{}%
+ \fi %
+ \gre@v@case{#2}{#3}{#4}{#5}%
+ \fi %
+ \relax%
+}%
+
+\def\GreVEpisema#1#2{%
+ \ifgre@disablevepisema\else %
+ \gre@vepisemaorrare{#1}{#2}{\GreCPVEpisema}{1}{}%
+ \fi %
+ \relax %
+}%
+
+\def\GreBarBrace#1{%
+ \gre@vepisemaorrare{\gre@pitch@overbraceglyph}{#1}{%
+ \gre@render@barbrace%
+ }{4}{}%
+ \relax %
+}%
+\def\gre@render@barbrace{%
+ \hbox{%
+ \ifgre@metapost@barbrace %
+ \gre@draw@brace{*}%
+ \else %
+ \gre@fontchar@abovebarbrace %
+ \fi %
+ }%
+}%
+
+\def\GreBarVEpisema#1{%
+ \gre@vepisemaorrare{\gre@pitch@barvepisema}{#1}{\GreCPVEpisema}{1}{}%
+ \relax %
+}%
+
+\def\GreAccentus#1#2{%
+ \gre@vepisemaorrare{#1}{#2}{\GreCPAccentus}{2}{}%
+ \relax %
+}%
+
+\def\GreSemicirculus#1#2{%
+ \gre@vepisemaorrare{#1}{#2}{\GreCPSemicirculus}{2}{}%
+ \relax %
+}%
+
+\def\GreCirculus#1#2{%
+ \gre@vepisemaorrare{#1}{#2}{\GreCPCirculus}{2}{}%
+ \relax %
+}%
+
+\def\GreReversedAccentus#1#2{%
+ \gre@vepisemaorrare{#1}{#2}{\GreCPAccentusReversus}{2}{}%
+ \relax %
+}%
+
+\def\GreReversedSemicirculus#1#2{%
+ \gre@vepisemaorrare{#1}{#2}{\GreCPSemicirculusReversus}{2}{}%
+ \relax %
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% macros for the typesetting horizontal episema
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+% a macro that will help in the typesetting of a horizontal episema and additional lines,
+% #1 is an offset glyph (see #3, below)
+% #2 is the episema glyph
+% #3 is a case number, similar in nature to #3 in gre@vepisemaorrareaux
+% 0 : go back to the beginning of the previous glyph; this starts the
+% episema at the beginning of the previous glyph
+% 1 : stay at the end of the glyph; doesn't make much sense to use this
+% 2 : go back the width of #1; this starts the episema at the glyph from
+% the end that starts at #1's width from the end
+% 3 : go back to the beginning of the previous glyph and then forward the
+% width of #1; this starts the episema at the glyph from the start that
+% starts just after #1's width from the start
+% 4 : go back to the beginning of the previous glyph and then forward the
+% width of #1, then back the width of #2; this ends the episema at the
+% end of #1
+% #4 argument is the same as in hepisorline
+\def\gre@hepisorlineaux#1#2#3#4{%
+ \ifcase#3% case 0
+ % first we set \gre@dimen@temp@three to the width of the last glyph
+ \gre@dimen@temp@three=\gre@dimen@lastglyphwidth\relax%
+ \or % case 1
+ \gre@dimen@temp@three=0 pt\relax %
+ \or % case 2
+ \setbox\gre@box@temp@sign=\hbox{\gre@font@music #1}%
+ \gre@dimen@temp@three=\wd\gre@box@temp@sign%
+ \or % case 3
+ \setbox\gre@box@temp@sign=\hbox{\gre@font@music #1}%
+ \gre@dimen@temp@three=\dimexpr(\gre@dimen@lastglyphwidth - \wd\gre@box@temp@sign)\relax %
+ \or % case 4
+ \setbox\gre@box@temp@sign=\hbox{\gre@font@music #1}%
+ \gre@dimen@temp@three=\dimexpr(\gre@dimen@lastglyphwidth - \wd\gre@box@temp@sign)\relax %
+ \setbox\gre@box@temp@sign=\hbox{\gre@font@music #2}%
+ \advance\gre@dimen@temp@three by \wd\gre@box@temp@sign %
+ \fi%
+ \kern-\gre@dimen@temp@three %
+ % then we draw the sign, and go back to the beginning of the sign
+ \setbox\gre@box@temp@sign=\hbox{\gre@font@music#2}%
+ % we set tempwidth to half a punctum malus half the sign width, so that the centers are aligned
+ \gre@dimen@temp@two=\wd\gre@box@temp@sign %
+ \ifcase#4%
+ %case of hepisema
+ \raise \gre@dimen@glyphraisevalue \copy\gre@box@temp@sign %
+ \or %
+ %case of hepisema at the bottom
+ \raise \gre@dimen@glyphraisevalue \copy\gre@box@temp@sign %
+ \or % case of a line at the top
+ \ifnum\gre@count@lastglyphiscavum=2\relax %
+ \gre@drawadditionalline{0}{\gre@dimen@temp@two}{0}{}{1}{}%
+ \else %
+ \gre@drawadditionalline{0}{\gre@dimen@temp@two}{1}{}{1}{}%
+ \fi %
+ \gre@dimen@temp@two=0pt\relax %
+ \or % case of a line at the bottom
+ \ifnum\gre@count@lastglyphiscavum=2\relax %
+ \gre@drawadditionalline{1}{\gre@dimen@temp@two}{0}{}{1}{}%
+ \else %
+ \gre@drawadditionalline{1}{\gre@dimen@temp@two}{1}{}{1}{}%
+ \fi %
+ \gre@dimen@temp@two=0pt\relax %
+ \or %
+ %case of choral sign
+ \raise \gre@dimen@glyphraisevalue \copy\gre@box@temp@sign %
+ \or %
+ \fi %
+ % and finally we go back to the end of the glyph, where we were first
+ \advance\gre@dimen@temp@three by -\gre@dimen@temp@two %
+ \kern\gre@dimen@temp@three %
+ \relax%
+}%
+
+% another dumb top function
+\def\GreAdditionalLine#1#2#3{%
+ \ifgre@showlines %
+ \ifgre@boxing\else %
+ \xdef\gre@dimen@savedglyphraise{\the\gre@dimen@glyphraisevalue}%
+ \gre@style@additionalstafflines %
+ \ifx\gre@empty@additionalstafflinesformat\greadditionalstafflinesformat% OBSOLETE
+ \else % OBSOLETE
+ \gre@obsolete{\protect\greadditionalstafflinesformat}{\protect\grechangestyle{additionalstafflinesformat}}% OBSOLETE
+ \fi% OBSOLETE
+ \gre@hepisorline{\gre@pitch@dummy}{#1}{#2}{#3}{f}{}{}%
+ \endgre@style@additionalstafflines%
+ \gre@dimen@glyphraisevalue=\gre@dimen@savedglyphraise\relax%
+ \fi %
+ \fi %
+ \relax %
+}%
+
+% #1 0 for over staff,
+% 1 for under staff
+% #2 length of line
+% #3 0 for no space before,
+% 1 for \gre@space@dimen@additionallineswidth before,
+% 2 for #4 space before
+% #4 custom space before, used if #2 is 2
+% #5 0 for no space after,
+% 1 for \gre@space@dimen@additionallineswidth after,
+% 2 for #6 space after
+% #6 custom space after, used if #4 is 2
+\def\GreDrawAdditionalLine#1#2#3#4#5#6{%
+ \ifgre@showlines %
+ \xdef\gre@dimen@savedglyphraise{\the\gre@dimen@glyphraisevalue}%
+ \gre@style@additionalstafflines %
+ \ifx\gre@empty@additionalstafflinesformat\greadditionalstafflinesformat% OBSOLETE
+ \else % OBSOLETE
+ \gre@obsolete{\protect\greadditionalstafflinesformat}{\protect\grechangestyle{additionalstafflinesformat}}% OBSOLETE
+ \fi% OBSOLETE
+ \gre@drawadditionalline{#1}{#2}{#3}{#4}{#5}{#6}%
+ \endgre@style@additionalstafflines%
+ \gre@dimen@glyphraisevalue=\gre@dimen@savedglyphraise\relax%
+ \fi %
+ \relax %
+}
+\def\gre@drawadditionalline#1#2#3#4#5#6{%
+ \ifcase#3 % 0
+ \gre@dimen@temp@five=0pt\relax %
+ \or % 1
+ \gre@dimen@temp@five=\gre@space@dimen@additionallineswidth\relax %
+ \or % 2
+ \gre@dimen@temp@five=#4\relax %
+ \fi %
+ \ifcase#5 % 0
+ \gre@dimen@temp@four=0pt\relax %
+ \or % 1
+ \gre@dimen@temp@four=\gre@space@dimen@additionallineswidth\relax %
+ \or % 2
+ \gre@dimen@temp@four=#6\relax %
+ \fi %
+ \gre@dimen@temp@two=%
+ \dimexpr(#2 %
+ + \gre@dimen@temp@five %
+ + \gre@dimen@temp@four)\relax %
+ \ifcase#1 % 0
+ \gre@dimen@glyphraisevalue=%
+ \dimexpr(\gre@dimen@additionalbottomspace %
+ + \gre@space@dimen@spacebeneathtext %
+ + \gre@space@dimen@spacelinestext %
+ + \gre@dimen@currenttranslationheight %
+ + \gre@stafflines\gre@dimen@interstafflinespace %
+ + \gre@stafflines\gre@dimen@stafflineheight)\relax%
+ \or % 1
+ \gre@dimen@glyphraisevalue=%
+ \dimexpr(\gre@dimen@additionalbottomspace %
+ + \gre@space@dimen@spacebeneathtext %
+ + \gre@space@dimen@spacelinestext %
+ + \gre@dimen@currenttranslationheight %
+ - \gre@dimen@interstafflinespace %
+ - \gre@dimen@stafflineheight)\relax%
+ \fi %
+ \raise\gre@dimen@glyphraisevalue\hbox to 0pt{%
+ \kern-\gre@dimen@temp@five %
+ \vrule height \gre@dimen@stafflineheight %
+ width \gre@dimen@temp@two %
+ }%
+}
+
+% a function to typeset a horizontal line (additional line or episema).
+% This function must be called after a call to \GreGlyph.
+% #1 is the letter of the height of the episema (not the height of the note
+% it corresponds to.
+% #2 is note position case as in the table above
+% #3 is the ambitus for a two note episema at the diagonal stroke of a
+% porrectus, porrectus flexus, orculus resupinus, or torculus resupinus
+% flexus
+% #4 is 0 for an horizontal episema, 1 for an horizontal episema under a
+% note, 3 for a line at the bottom, 2 for a line at the top
+% #5 is f for a normal episema, l for a small episema aligned left,
+% c for a small episema aligned center, or r for a small episema
+% aligned right
+% #6 is the vertical nudge
+% #7 is horizontal episema interline position case
+%% 0 : auto
+%% 1 : middle
+%% 2 : low in space above note
+%% 3 : high in space above note
+%% 4 : low in space below note
+%% 5 : high in space below note
+\def\gre@hepisorline#1#2#3#4#5#6#7{{%
+ \ifcase#4 % 0
+ \gre@calculate@glyphraisevalue{#1}{9}{#7}%
+ \or % 1
+ \gre@calculate@glyphraisevalue{#1}{5}{#7}%
+ \or % 2
+ % the glyphraisevalue is ignored anyway... but it's just in case...
+ \gre@calculate@glyphraisevalue{\gre@pitch@ledger@above}{0}{}%
+ \or % 3
+ \gre@calculate@glyphraisevalue{\gre@pitch@ledger@below}{0}{}%
+ \fi %
+ \global\gre@dimen@glyphraisevalue=\dimexpr\gre@dimen@glyphraisevalue#6\relax %
+ \gre@h@case{#2}{#3}{#4}{#5}%
+ \relax%
+}}%
+
+% dumb top function
+% #6 is a trick for bridges: if we must use a different height because of a
+% bridge, use #6, otherwise use #1
+% #7 is used for setting heuristics
+% #8 is the vertical nudge
+% #9 is horizontal episema interline position case
+%% 0 : auto
+%% 1 : middle
+%% 2 : low in space above note
+%% 3 : high in space above note
+%% 4 : low in space below note
+%% 5 : high in space below note
+\def\GreHEpisema#1#2#3#4#5#6#7#8#9{%
+ \ifgre@boxing\else\ifgre@disablehepisema\else %
+ \gre@prephepisemaledgerlineheuristics%
+ #7%
+ \ifgre@hepisemabridge%
+ \gre@hepisorline{#6}{#2}{#3}{#4}{#5}{#8}{#9}%
+ \else %
+ \gre@hepisorline{#1}{#2}{#3}{#4}{#5}{#8}{#9}%
+ \fi %
+ \gre@resetledgerlineheuristics%
+ \fi\fi %
+ \relax %
+}%
+
+\newif\ifgre@hepisemabridge
+\gre@hepisemabridgetrue
+
+\def\AddHEpisemusBridges{%OBSOLETE
+ \gre@obsolete{\protect\AddHEpisemusBridges}{\protect\gresethepisema{bridge}}%
+}%
+
+\def\RemoveHEpisemusBridges{%OBSOLETE
+ \gre@obsolete{\protect\RemoveHEpisemusBridges}{\protect\gresethepisema{break}}%
+}%
+
+\def\gresethepisema#1{%
+ \IfStrEqCase{#1}{%
+ {bridge}%
+ {\gre@hepisemabridgetrue}%
+ {break}%
+ {\gre@hepisemabridgefalse}%
+ }[% all other cases
+ \gre@error{Unrecognized option, #1, for \protect\gresethepisema\MessageBreak Possible options are: 'bridge' and 'break'}%
+ ]%
+}%
+
+% same but for a "bridge episema" after the last note of a glyph (element, syllable) if the next episema is at the same height
+% #1 is the height
+% #2 is 0 for episema above, 1 for episema below
+% #3 is the "space case" for the following note, if a punctum inclinatum
+% #4 is for setting heuristics
+% #5 is the vertical nudge
+% #6 is horizontal episema interline position case
+%% 0 : auto
+%% 1 : middle
+%% 2 : low in space above note
+%% 3 : high in space above note
+%% 4 : low in space below note
+%% 5 : high in space below note
+\def\GreHEpisemaBridge#1#2#3#4#5#6{%
+ \ifgre@hepisemabridge%
+ \ifgre@boxing\else %
+ \gre@prephepisemaledgerlineheuristics%
+ #4%
+ \ifcase#2 %
+ \gre@calculate@glyphraisevalue{#1}{9}{#6}%
+ \or %
+ \gre@calculate@glyphraisevalue{#1}{5}{#6}%
+ \fi %
+ \global\gre@dimen@glyphraisevalue=\dimexpr\gre@dimen@glyphraisevalue#5\relax %
+ \IfStrEq{-1}{#3}{%
+ \raise\gre@dimen@glyphraisevalue\hbox to 0pt{\gre@font@music\gre@char@he@punctum{f}\hss}%
+ }{%
+ % special handling for punctum inclinatum
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPHEpisemaPunctumReduced}%
+ \gre@dimen@temp@four = \wd\gre@box@temp@width\relax %
+ \gre@get@spaceskip{#3}%
+ % convert rubber length to dimension... not perfect but works in the usual case
+ \gre@dimen@temp@three = 1\gre@skip@temp@four\relax %
+ \raise\gre@dimen@glyphraisevalue\hbox to 0pt{%
+ \loop\ifdim\gre@dimen@temp@three > 0pt\relax%
+ \advance\gre@dimen@temp@three by -\gre@dimen@temp@four\relax %
+ {\gre@font@music\GreCPHEpisemaPunctumReduced}%
+ \repeat %
+ \kern\gre@dimen@temp@three{\gre@font@music\GreCPHEpisemaPunctumReduced}%
+ \hss %
+ }%
+ }%
+ \gre@resetledgerlineheuristics%
+ \fi %
+ \fi %
+ \relax %
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% macros for the typesetting of bars
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% we define two types of macro for each four bar : when it is inside a syllable, and when it is not
+
+\def\GreInVirgula#1#2{%
+ \gre@writebar{0}{1}{#1}{#2}%
+ \relax%
+}%
+
+\def\GreVirgula#1#2{%
+ \gre@writebar{0}{0}{#1}{#2}%
+ \relax%
+}%
+
+\def\GreInDivisioMinima#1#2{%
+ \gre@writebar{1}{1}{#1}{#2}%
+ \relax%
+}%
+
+\def\GreDivisioMinima#1#2{%
+ \gre@writebar{1}{0}{#1}{#2}%
+ \relax%
+}%
+
+\def\GreInDivisioMinor#1#2{%
+ \gre@writebar{2}{1}{#1}{#2}%
+ \relax%
+}%
+
+\def\GreDivisioMinor#1#2{%
+ \gre@writebar{2}{0}{#1}{#2}%
+ \relax%
+}%
+
+\def\GreInDivisioMaior#1#2{%
+ \gre@writebar{3}{1}{#1}{#2}%
+ \relax%
+}%
+
+\def\GreDivisioMaior#1#2{%
+ \gre@writebar{3}{0}{#1}{#2}%
+ \relax%
+}%
+
+\def\GreDominica#1#2#3{%
+ \ifcase#1\or %
+ \gre@writebar{6}{0}{#2}{#3}%
+ \or %
+ \gre@writebar{7}{0}{#2}{#3}%
+ \or %
+ \gre@writebar{8}{0}{#2}{#3}%
+ \or %
+ \gre@writebar{9}{0}{#2}{#3}%
+ \or %
+ \gre@writebar{10}{0}{#2}{#3}%
+ \or %
+ \gre@writebar{11}{0}{#2}{#3}%
+ \or %
+ \gre@writebar{12}{0}{#2}{#3}%
+ \or %
+ \gre@writebar{13}{0}{#2}{#3}%
+ \fi %
+ \relax%
+}%
+
+\def\GreInDominica#1#2#3{%
+ \ifcase#1\or %
+ \gre@writebar{6}{1}{#2}{#3}%
+ \or %
+ \gre@writebar{7}{1}{#2}{#3}%
+ \or %
+ \gre@writebar{8}{1}{#2}{#3}%
+ \or %
+ \gre@writebar{9}{1}{#2}{#3}%
+ \or %
+ \gre@writebar{10}{1}{#2}{#3}%
+ \or %
+ \gre@writebar{11}{1}{#2}{#3}%
+ \or %
+ \gre@writebar{12}{1}{#2}{#3}%
+ \or %
+ \gre@writebar{13}{1}{#2}{#3}%
+ \fi %
+ \relax%
+}%
+
+\def\GreInDivisioFinalis#1#2{%
+ \ifgre@endofscore %
+ \gre@writebar{5}{1}{#1}{#2}%
+ \else %
+ \gre@writebar{4}{1}{#1}{#2}%
+ \fi %
+ \relax%
+}%
+
+\def\GreDivisioFinalis#1#2{%
+ \ifgre@endofscore %
+ \gre@writebar{5}{0}{#1}{#2}%
+ \else %
+ \gre@writebar{4}{0}{#1}{#2}%
+ \fi %
+ \relax%
+}%
+
+% #1 is #2 of gre@writebar
+% #2 is #3 of gre@writebar
+% emits the suffix of the space
+\def\gre@bar@space@suffix#1#2{%
+ \ifcase#1\ifgre@newbarspacing %
+ \ifcase#2 @standalone@notext\or @standalone@text\fi %
+ \fi\fi %
+}%
+
+\newcount\gre@count@shiftaftermora
+\gre@count@shiftaftermora=5
+
+\def\gresetshiftaftermora#1{%
+ \IfStrEqCase{#1}{%
+ {always}%
+ {\gre@count@shiftaftermora=5}%
+ {notesonly}%
+ {\gre@count@shiftaftermora=4}%
+ {barsonly}%
+ {\gre@count@shiftaftermora=3}%
+ {barsnotextonly}%
+ {\gre@count@shiftaftermora=2}%
+ {barsinsideonly}%
+ {\gre@count@shiftaftermora=1}%
+ {never}%
+ {\gre@count@shiftaftermora=0}%
+ }[% all other cases
+ \gre@error{Unrecognized option "#1" in gresetshiftaftermora\MessageBreak Possible options are: 'always', 'barsonly', 'notesonly', 'barsnotextonly', 'barsinsideonly' and 'never'}%
+ ]%
+}%
+
+% width of a punctum mora, reinitalized at each score
+\newdimen\gre@dimen@morawidth
+
+% sets gre@skip@punctummorashift to the (usually negative) shift to apply before
+% a syllable following a punctum mora, to cancel its taking into account into
+% horizontal placement.
+% First argument is:
+% - 1 for the general case
+% - 2 when the punctum mora is before a bar
+\def\gre@get@unkern@aftermora#1{%
+ \ifdim\gre@dimen@morawidth=0pt\relax %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\gre@fontchar@punctummora}%
+ \global\gre@dimen@morawidth=\wd\gre@box@temp@width %
+ \fi %
+ \ifnum #1=1%
+ \global\gre@skip@punctummorashift=\glueexpr - \gre@dimen@morawidth - \gre@space@skip@spacebeforesigns + \gre@space@skip@moraadjustment\relax %
+ \else %
+ \global\gre@skip@punctummorashift=\glueexpr - \gre@dimen@morawidth - \gre@space@skip@spacebeforesigns + \gre@space@skip@moraadjustmentbar\relax %
+ \fi %
+ \relax %
+}
+
+\def\gre@unkern@bar@aftermora{%
+ \ifgre@newbarspacing%
+ % don't apply a negative kern on the first glyph
+ % while boxing, otherwise the box width will be wrong
+ \ifgre@firstglyph %
+ \ifgre@boxing\else %
+ \gre@get@unkern@aftermora{2}%
+ \kern\gre@skip@punctummorashift %
+ \fi %
+ \else %
+ \gre@get@unkern@aftermora{2}%
+ \kern\gre@skip@punctummorashift %
+ \fi %
+ \else%
+ \gre@get@unkern@aftermora{2}%
+ \kern\gre@skip@punctummorashift %
+ \fi%
+ \relax %
+}
+
+\newskip\gre@skip@bar@lastskip% skip after last bar
+
+%a macro to write a bar
+%% 1: the type of the bar : 0 for virgula, 1 for minima 2 for minor, 3 for major, 4 for finalis and 5 for the last finalis, 6 to 13 for dominican bars
+%% 2: is 0 if it is in a syllable containing only this bar, 1 otherwise
+%% 3: is 0 if there's no text under the bar or 1 if there is text under the bar
+%% 4: macros that may happen before the skip after the bar (typically GreVEpisema)
+\def\gre@writebar#1#2#3#4{%
+ % first, for the bar to be really centered, if the last glyph has a punctum
+ % mora, we kern of the corresponding space. We do it only in the case
+ % of a bar in the middle of other notes.
+ \ifgre@lastendswithmora %
+ \ifgre@newbarspacing %
+ \ifnum\gre@count@shiftaftermora=0\else\ifnum\gre@count@shiftaftermora=4\else %
+ % new bar spacing takes care of punctum mora on its own, but only when
+ % bar has its own syllable
+ \ifcase #2\or %
+ \gre@unkern@bar@aftermora %
+ \fi %
+ \fi\fi %
+ \else %
+ \ifcase\gre@count@shiftaftermora\or %
+ % barsinsideonly
+ \ifcase #2\or %
+ \gre@unkern@bar@aftermora %
+ \fi %
+ \or %
+ % barsnotextonly
+ \ifcase #3\relax %
+ \gre@unkern@bar@aftermora %
+ \fi %
+ \or %
+ % barsonly
+ \gre@unkern@bar@aftermora %
+ \or\or %
+ % always
+ \gre@unkern@bar@aftermora %
+ \fi %
+ \fi %
+ \fi %
+ \gre@newglyphcommon %
+ \gre@calculate@glyphraisevalue{\gre@pitch@bar}{0}{}% bar glyphs are made to be at this height
+ \GreNoBreak %
+ % count indicating if we have to output space or not:
+ \gre@count@temp@one=0\relax %
+ \ifnum#2=1\relax %
+ \gre@count@temp@one=1\relax %
+ \else %
+ \ifgre@newbarspacing %
+ \gre@count@temp@one=1\relax %
+ \fi %
+ \fi %
+ \gre@skip@temp@four=0pt\relax %
+ \ifcase#1 % 0 : virgula
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@virgula\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPVirgula}%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPVirgula}%
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@virgula\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 1 : minima
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@minima\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioMinima}%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPDivisioMinima}%
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@minima\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 2 : minor
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@minor\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioMinor}%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPDivisioMinor}%
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@minor\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 3 : maior
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@maior\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioMaior}%
+ \gre@fontchar@divisiomaior %
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@maior\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 4 : finalis
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@finalis\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@fontchar@divisiofinalis}%
+ #4\relax %
+ \gre@fontchar@divisiofinalis%
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@finalis\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 5 : final finalis
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@finalfinalis\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@fontchar@divisiofinalis}%
+ #4\relax %
+ \gre@fontchar@divisiofinalis%
+ \ifgre@newbarspacing %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@finalfinalis\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \or % 6 : dominican bar 1
+ \gre@calculate@glyphraisevalue{\gre@pitch@e}{0}{}%
+ % we need to adjust the height of the bar a little so that it is perfectly aligned with the bottom (or the top for some bars) of the staff line, which is not the case by default if \gre@stafflinefactor is not 10.
+ \advance\gre@dimen@glyphraisevalue by -\gre@dimen@stafflinediff\relax%
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioDominican}%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPDivisioDominican}%
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 7 : dominican bar 2
+ \gre@calculate@glyphraisevalue{\gre@pitch@e}{0}{}%
+ \advance\gre@dimen@glyphraisevalue by \gre@dimen@stafflinediff\relax%
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioDominicanAlt}%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPDivisioDominicanAlt}%
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 8 : dominican bar 3
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \advance\gre@dimen@glyphraisevalue by -\gre@dimen@stafflinediff\relax%
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioDominican}%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPDivisioDominican}%
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 9 : dominican bar 4
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \advance\gre@dimen@glyphraisevalue by \gre@dimen@stafflinediff\relax%
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioDominicanAlt}%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPDivisioDominicanAlt}%
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 10 : dominican bar 5
+ \gre@calculate@glyphraisevalue{\gre@pitch@i}{0}{}%
+ \advance\gre@dimen@glyphraisevalue by -\gre@dimen@stafflinediff\relax%
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioDominican}%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPDivisioDominican}%
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 11 : dominican bar 6
+ \gre@calculate@glyphraisevalue{\gre@pitch@i}{0}{}%
+ \advance\gre@dimen@glyphraisevalue by \gre@dimen@stafflinediff\relax%
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioDominicanAlt}%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPDivisioDominicanAlt}%
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 12 : dominican bar 7
+ \gre@calculate@glyphraisevalue{\gre@pitch@k}{0}{}%
+ \advance\gre@dimen@glyphraisevalue by -\gre@dimen@stafflinediff\relax%
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioDominican}%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPDivisioDominican}%
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \or % 13 : dominican bar 8
+ \gre@calculate@glyphraisevalue{\gre@pitch@k}{0}{}%
+ \advance\gre@dimen@glyphraisevalue by \gre@dimen@stafflinediff\relax%
+ \ifnum\gre@count@temp@one=1\relax %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \GreNoBreak %
+ \fi %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioDominicanAlt}%
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPDivisioDominicanAlt}%
+ #4\relax %
+ \ifnum\gre@count@temp@one=1\relax %
+ \GreNoBreak %
+ \gre@skip@temp@four = \csname gre@space@skip@bar@dominican\gre@bar@space@suffix{#2}{#3}\endcsname\relax%
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \fi %
+ \global\gre@skip@bar@lastskip=\gre@skip@temp@four %
+ \gre@debugmsg{spacing}{Width of bar just printed: \the\wd\gre@box@temp@width}%
+ \gre@debugmsg{spacing}{Last bar space: \the\gre@skip@temp@four}%
+ \global\gre@dimen@lastglyphwidth=\wd\gre@box@temp@width %
+ \directlua{gregoriotex.adjust_line_height(\gre@insidediscretionary)}%
+ \relax%
+}%
+
+\def\gre@fontchar@divisiomaior{%
+ \ifnum\gre@stafflinefactor=17\relax %
+ %\gre@calculate@glyphraisevalue{\gre@pitch@bar}{0}{}% bar glyphs are made to be at this height
+ \raise\gre@dimen@glyphraisevalue\hbox{\gre@font@music\GreCPDivisioMaior}%
+ \else %
+ \setbox\gre@box@temp@width=\hbox{\gre@font@music\GreCPDivisioMaior}%
+ % we calculate the raise of the bar
+ \gre@dimen@temp@five=\dimexpr(\gre@dimen@additionalbottomspace %
+ + \gre@space@dimen@spacebeneathtext %
+ + \gre@space@dimen@spacelinestext %
+ + \gre@dimen@currenttranslationheight)\relax%
+ % we calculate the height of the bar
+ \raise\gre@dimen@temp@five\hbox{\vrule height \gre@dimen@staffheight width \wd\gre@box@temp@width}%
+ \fi %
+ \relax %
+}%
+
+\def\gre@fontchar@divisiofinalis{%
+ \gre@calculate@glyphraisevalue{\gre@pitch@bar}{0}{}% bar glyphs are made to be at this height
+ \gre@fontchar@divisiomaior %
+ \kern\gre@space@dimen@divisiofinalissep %
+ \GreNoBreak %
+ \gre@fontchar@divisiomaior %
+}%
+
+% Flag to tell if we have to keep the localrightbox until the end
+\newif\ifgre@keeprightbox%
+
+%macro to end a line with a divisio finalis
+\def\GreFinalDivisioFinalis#1{%
+ \GreBarSyllable{\GreSetThisSyllable{}{}{}{}{}}{}{}{1}{\GreSetNextSyllable{}{}{}{}{}\GreLastOfLine}{}{16}{}{%
+ \ifgre@newbarspacing\else %
+ \gre@hskip\gre@space@skip@bar@finalfinalis %
+ \GreNoBreak %
+ \fi %
+ \GreLastOfScore %
+ \GreDivisioFinalis{0}{}%
+ #1%
+ }%
+ \relax%
+}%
+
+%macro to end a line with a divisio maior
+\def\GreFinalDivisioMaior#1{%
+ \GreBarSyllable{\GreSetThisSyllable{}{}{}{}{}}{}{}{1}{\GreSetNextSyllable{}{}{}{}{}\GreLastOfLine}{}{16}{}{%
+ \GreLastOfScore %
+ \GreDivisioMaior{0}{}%
+ #1%
+ }%
+ \relax%
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% macros for filling holes of empty notes
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% flag to indicate that lines behind a punctum cavum should be hidden
+\newif\ifgre@hidepclines
+% default state is to not hide them
+\gre@hidepclinesfalse
+
+% macro for manipulating above flag
+\def\gresetlinesbehindpunctumcavum#1{%
+ \IfStrEqCase{#1}{%
+ {visible}%
+ {\gre@hidepclinesfalse}%
+ {invisible}%
+ {\gre@hidepclinestrue}%
+ }[% all other cases
+ \gre@error{Unrecognized option "#1" for \protect\gresetlinesbehindpunctumcavum\MessageBreak Possible options are: 'visible' and 'invisible'}%
+ ]%
+}%
+
+\def\GreHidePCLines{%OBSOLETE
+ \gre@obsolete{\protect\GreHidePCLines}{\protect\gresetlinesbehindpunctumcavum{invisible}}%
+}%
+
+\def\GreDontHidePCLines{%OBSOLETE
+ \gre@obsolete{\protect\GreDontHidePCLines}{\protect\gresetlinesbehindpunctumcavum{visible}}%
+}%
+
+% flag to indicate that lines behind an alteration should be hidden
+\newif\ifgre@hidealtlines
+% default state is to not hide them
+\gre@hidealtlinesfalse
+
+% macro for manipulating above flag
+\def\gresetlinesbehindalteration#1{%
+ \IfStrEqCase{#1}{%
+ {visible}%
+ {\gre@hidealtlinesfalse}%
+ {invisible}%
+ {\gre@hidealtlinestrue}%
+ }[% all other cases
+ \gre@error{Unrecognized option "#1" for \protect\gresetlinesbehindalteration\MessageBreak Possible options are: 'visible' and 'invisible'}%
+ ]%
+}%
+
+\def\GreHideAltLines{%OBSOLETE
+ \gre@obsolete{\protect\GreHideAltLines}{\protect\gresetlinesbehindalteration{invisible}}%
+}%
+
+\def\GreDontHideAltLines{%OBSOLETE
+ \gre@obsolete{\protect\GreDontHideAltLines}{\protect\gresetlinesbehindalteration{visible}}%
+}%
+
+% is last glyph a cavum?
+\newcount\gre@count@lastglyphiscavum
+% 0 if no
+% 1 if current glyph is a cavum (set once the cavum is filled)
+% 2 if previous glyph is a cavum (which is the most interesting information)
+\gre@count@lastglyphiscavum=0
+
+% the argument is the character with which we fill the hole, and we suppose that
+% isonaline and glyphraisevalue are correctly set.
+\def\gre@fillhole#1{%
+ \ifgre@boxing\else %
+ \global\gre@count@lastglyphiscavum=1\relax %
+ \setbox\gre@box@temp@sign=\hbox{#1}%
+ \hbox to 0pt{%
+ {%
+ \color{grebackgroundcolor}%
+ \raise \gre@dimen@glyphraisevalue\relax%
+ \copy\gre@box@temp@sign %
+ }%
+ %\pdfliteral{}% this is a ugly hack for old versions of LuaTeX to work
+ \hss %
+ }%
+ \GreNoBreak %
+ \fi %
+ \relax %
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% macros for typesetting alterations
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% the top level macro:
+% #1 is the height
+% #2 is the char of the alteration
+% #3 is the char of the alteration hole
+% #4 is 1 if the alteration is the flat in a clef
+% #5 are the signs to typeset before the glyph (typically additional bars, as they must be "behind" the glyph)
+% #6 are the signs to typeset after the glyph (almost all signs)
+% #7 is the line:char:column for a textedit link
+\def\gre@alteration#1#2#3#4#5#6#7{%
+ \setbox\gre@box@temp@width=\hbox{\gre@pointandclick{#2}{#7}}%
+ \ifnum#4=0\relax %
+ \gre@newglyphcommon %
+ \fi %
+ \global\gre@dimen@lastglyphwidth=\wd\gre@box@temp@width %
+ % the three next lines are a trick to get the additional lines below the glyphs
+ \gre@skip@temp@one = \gre@dimen@lastglyphwidth\relax%
+ \kern\gre@skip@temp@one %
+ #5\relax %
+ \kern-\gre@skip@temp@one %
+ \gre@calculate@glyphraisevalue{#1}{0}{}%
+ \ifgre@hidealtlines %
+ \gre@fillhole{#3}%
+ \fi %
+ \raise \gre@dimen@glyphraisevalue\relax%
+ \copy\gre@box@temp@width%
+ #6\relax %
+ \ifnum#4=0\relax %
+ % we try to avoid line breaking after a flat or a natural
+ \GreNoBreak %
+ \gre@skip@temp@four = \gre@space@dimen@alterationspace\relax%
+ \ifgre@firstglyph%
+ \gre@debugmsg{bolshift}{making adjustments for leading alteration}%
+ \global\advance\gre@dimen@notesaligncenter by %
+ \dimexpr(\wd\gre@box@temp@width + \dimexpr\gre@skip@temp@four)\relax %
+ \kern\gre@skip@temp@four %
+ \global\gre@dimen@bolextra = \dimexpr(\wd\gre@box@temp@width + \dimexpr\gre@skip@temp@four)\relax%
+ \gre@debugmsg{bolshift}{bolextra: \the\gre@dimen@bolextra}%
+ \else %
+ \gre@hskip\gre@skip@temp@four %
+ \fi %
+ \GreNoBreak %
+ \directlua{gregoriotex.adjust_line_height(\gre@insidediscretionary)}%
+ \fi %
+ \relax %
+}%
+
+% This macro typesets a flat on the height provided by #1.
+% #2 is 1 if the flat is part of a clef.
+
+\def\GreFlat#1#2#3#4#5{%
+ \gre@alteration{#1}{\gre@fontchar@flat}{\gre@fontchar@flathole}{#2}{#3}{#4}{#5}%
+ \relax%
+}%
+
+% Same as the one before, but for naturals.
+
+\def\GreNatural#1#2#3#4#5{%
+ \gre@alteration{#1}{\gre@fontchar@natural}{\gre@fontchar@naturalhole}{#2}{#3}{#4}{#5}%
+ \relax%
+}%
+
+% Same as the one before, but for sharps.
+
+\def\GreSharp#1#2#3#4#5{%
+ \gre@alteration{#1}{\gre@fontchar@sharp}{\gre@fontchar@sharphole}{#2}{#3}{#4}{#5}%
+ \relax%
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% macros for typesetting punctum cavum
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\def\gre@fontchar@punctumcavum{\gre@font@music\GreCPPunctumCavum}%
+\def\gre@fontchar@lineapunctumcavum{\gre@font@music\GreCPLineaPunctumCavum}%
+\def\gre@fontchar@punctumcavumhole{\gre@font@music\GreCPPunctumCavumHole}%
+\def\gre@fontchar@lineapunctumcavumhole{\gre@font@music\GreCPLineaPunctumCavumHole}%
+
+\def\gresetpunctumcavum#1{%
+ \IfStrEqCase{#1}{%
+ {alternate}%
+ {%
+ \grechangeglyph{PunctumCavum}{greciliae}{.caeciliae}%
+ \grechangeglyph{LineaPunctumCavum}{greciliae}{.caeciliae}%
+ \grechangeglyph{PunctumCavumHole}{greciliae}{.caeciliae}%
+ \grechangeglyph{LineaPunctumCavumHole}{greciliae}{.caeciliae}%
+ }%
+ {normal}%
+ {%
+ \greresetglyph{PunctumCavum}%
+ \greresetglyph{LineaPunctumCavum}%
+ \greresetglyph{PunctumCavumHole}%
+ \greresetglyph{LineaPunctumCavumHole}%
+ }%
+ }[% all other cases
+ \gre@error{Unrecognized option "#1" for \protect\gresetpunctumcavum\MessageBreak Possible options are: 'alternate' and 'normal'}%
+ ]%
+}%
+
+
+\def\UseAlternatePunctumCavum{%OBSOLETE
+ \gre@obsolete{\protect\UseAlternatePunctumCavum}{\protect\gresetpunctumcavum{alternate}}%
+}%
+
+\def\UseNormalPunctumCavum{%OBSOLETE
+ \gre@obsolete{\protect\UseNormalPunctumCavum}{\protect\gresetpunctumcavum{normal}}%
+}%
+
+\def\gre@char@cavum#1#2#3#4#5#6#7#8{%
+ \setbox\gre@box@temp@width=\hbox{#7}%
+ \global\gre@dimen@lastglyphwidth=\wd\gre@box@temp@width %
+ \gre@skip@temp@four = \gre@dimen@lastglyphwidth\relax%
+ \kern\gre@skip@temp@four %
+ #4\relax %
+ \kern-\gre@skip@temp@four %
+ \gre@calculate@glyphraisevalue{#1}{0}{}%
+ \ifgre@hidepclines%
+ \gre@fillhole{#8}%
+ \fi %
+ \GreGlyph{#7}{#1}{#2}{#3}{}{#5}{#6}%
+ %\relax %
+}%
+
+\def\GrePunctumCavum#1#2#3#4#5#6{%
+ \gre@char@cavum{#1}{#2}{#3}{#4}{#5}{#6}%
+ {\gre@fontchar@punctumcavum}{\gre@fontchar@punctumcavumhole}%
+}%
+
+\def\GreLineaPunctumCavum#1#2#3#4#5#6{%
+ \gre@char@cavum{#1}{#2}{#3}{#4}{#5}{#6}%
+ {\gre@fontchar@lineapunctumcavum}{\gre@fontchar@lineapunctumcavumhole}%
+}%
+
+\def\GrePunctumCavumInclinatum#1#2#3#4#5#6{%
+ \gre@char@cavum{#1}{#2}{#3}{#4}{#5}{#6}%
+ {\gre@font@music\GreCPPunctumCavumInclinatum}{\gre@font@music\GreCPPunctumCavumInclinatumHole}%
+}%
+
+\def\GrePunctumCavumInclinatumAuctus#1#2#3#4#5#6{%
+ \gre@char@cavum{#1}{#2}{#3}{#4}{#5}{#6}%
+ {\gre@font@music\GreCPPunctumCavumInclinatumAuctus}{\gre@font@music\GreCPPunctumCavumInclinatumAuctusHole}%
+}%
+
+\def\GreOriscusCavum#1#2#3#4#5#6{%
+ \gre@char@cavum{#1}{#2}{#3}{#4}{#5}{#6}%
+ {\gre@font@music\GreCPOriscusCavum}{\gre@font@music\GreCPOriscusCavumHole}%
+}%
+
+\def\GreOriscusCavumAuctus#1#2#3#4#5#6{%
+ \gre@char@cavum{#1}{#2}{#3}{#4}{#5}{#6}%
+ {\gre@font@music\GreCPOriscusCavumReversus}{\gre@font@music\GreCPOriscusCavumReversusHole}%
+}%
+
+\def\GreOriscusCavumDeminutus#1#2#3#4#5#6{%
+ \gre@char@cavum{#1}{#2}{#3}{#4}{#5}{#6}%
+ {\gre@font@music\GreCPOriscusCavumDeminutus}{\gre@font@music\GreCPOriscusCavumDeminutusHole}%
+}%