Skip to content

Commit

Permalink
#1189: TeX part
Browse files Browse the repository at this point in the history
  • Loading branch information
eroux committed Jul 30, 2016
1 parent d9b013b commit 7e53de9
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 18 deletions.
1 change: 1 addition & 0 deletions tex/gregoriotex-main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,7 @@
\unsetluatexattribute{\gre@attr@glyph@top}%
\unsetluatexattribute{\gre@attr@glyph@bottom}%
\unsetluatexattribute{\gre@attr@dash}%
\xdef\gre@bolshiftcleftypelocal{\gre@bolshiftcleftypeglobal}%
\ifgre@justifylastline%
\parfillskip=\gre@save@parfillskip\relax%
\fi %
Expand Down
38 changes: 24 additions & 14 deletions tex/gregoriotex-signs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
]%
}%


%% 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)
Expand All @@ -166,6 +165,12 @@
\relax%
}%

\def\GreSetLargestClef#1#2#3#4#5#6#7{%
\gre@boxclef{#1}{#2}{0}{#3}{#4}{#5}{#6}{#7}%
\gre@update@clefwidth@max{\wd\gre@box@temp@width}%
\relax%
}%

\def\gre@save@clef#1#2#3#4#5#6{%
\global\let\gre@clef=#1\relax%
\xdef\gre@clefheight{#2}%
Expand All @@ -183,18 +188,9 @@

\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: 0: no space after, 1: normal space after, 2: short space after
%% #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{%

\def\gre@boxclef#1#2#3#4#5#6#7#8{%
\global\setbox\gre@box@temp@width=\hbox{%
\ifcase#7%
\gre@typesingleclef{#1}{#2}{#3}{#5}%
\else %
Expand All @@ -214,8 +210,22 @@
\fi %
\fi %
}%
}

% 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: 0: no space after, 1: normal space after, 2: short space after
%% #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{%
\gre@boxclef{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
\ifcase#3%
\global\gre@dimen@clefwidth=\wd\gre@box@temp@width %
\gre@update@clefwidth@current{\wd\gre@box@temp@width}%
\fi %
\copy\gre@box@temp@width %
\ifcase#4 %
Expand Down
75 changes: 71 additions & 4 deletions tex/gregoriotex-spaces.tex
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@
\else%
\global\advance\gre@skip@temp@three by \gre@dimen@bolextra\relax%
\fi%
\gre@debugmsg{bolshift}{ clefwidthcurrent = \the\gre@dimen@clefwidth@current}%
\gre@debugmsg{bolshift}{ clefwidthbol = \the\gre@dimen@clefwidth@bol}%
\global\advance\gre@skip@temp@three by \dimexpr(\gre@dimen@clefwidth@current-\gre@dimen@clefwidth@bol)\relax %
\ifdim#1>0pt\relax%
% no additional shift is needed if the notes start before the text
\global\gre@dimen@bolshift = \gre@skip@temp@three\relax%
Expand All @@ -407,7 +410,7 @@
% we don't want to kern more than clefwidth + spaceafterlineclef - minimalspaceatlinebeginning
% violating this would mean that either the notes are closer than (clefwidth + spaceafterlineclef)
% or that the lyrics are closer than minimalspaceatlinebeginning
\gre@skip@temp@one = \glueexpr(\gre@dimen@clefwidth %
\gre@skip@temp@one = \glueexpr(\gre@dimen@clefwidth@bol %
+ \gre@space@skip@spaceafterlineclef %
- \gre@space@dimen@minimalspaceatlinebeginning)\relax %
\ifdim\gre@skip@temp@three < \gre@skip@temp@one %
Expand All @@ -420,6 +423,73 @@
\relax %
}

% the width of the current
\newdimen\gre@dimen@clefwidth@current\relax%
% the width of the max clef
\newdimen\gre@dimen@clefwidth@max\relax%
% the width to compute bolshift with
\newdimen\gre@dimen@clefwidth@bol\relax%

\def\gre@update@clefwidth@current#1{%
\gre@debugmsg{bolshift}{ updating clefwidthcurrent to \the\gre@dimen@clefwidth@current}%
\global\gre@dimen@clefwidth@current=#1\relax %
\ifnum\gre@bolshiftcleftypelocal=2\relax %
\global\gre@dimen@clefwidth@bol=#1\relax %
\fi %
\relax %
}

\def\gre@update@clefwidth@max#1{%
\global\gre@dimen@clefwidth@max=#1\relax %
\ifnum\gre@bolshiftcleftypelocal=1\relax %
\global\gre@dimen@clefwidth@bol=#1\relax %
\fi %
}

\def\gre@update@clefwidth@forced#1{%
\global\gre@dimen@clefwidth@bol=#1\relax %
}

% 1 for max, 2 for current and 3 for forced
\xdef\gre@bolshiftcleftypeglobal{1}
\xdef\gre@bolshiftcleftypelocal{1}

\def\grebolshiftcleftype#1{
\IfStrEqCase{#1}{%
{max}%
{\xdef\gre@bolshiftcleftypeglobal{1}\xdef\gre@bolshiftcleftypelocal{1}}%
{current}%
{\xdef\gre@bolshiftcleftypeglobal{2}\xdef\gre@bolshiftcleftypelocal{2}}%
}[% all other cases
\gre@error{Unrecognized option "#1" for \protect\grebolshiftcleftype\MessageBreak Possible options are: 'max' and 'current'.}%
]%
}

\def\grelocalbolshiftcleftype#1{
\IfStrEqCase{#1}{%
{max}%
{\xdef\gre@bolshiftcleftypelocal{1}%
\global\gre@dimen@clefwidth@bol=\gre@dimen@clefwidth@max\relax }%
{current}%
{\xdef\gre@bolshiftcleftypelocal{2}%
\global\gre@dimen@clefwidth@bol=\gre@dimen@clefwidth@current\relax }%
{c}%
{\gre@boxclef{c}{4}{0}{3}{c}{0}{3}{1}%
\xdef\gre@bolshiftcleftypelocal{3}%
\gre@update@clefwidth@forced{\wd\gre@box@temp@width}}%
{f}%
{\gre@boxclef{f}{3}{0}{1}{3}{c}{0}{3}%
\xdef\gre@bolshiftcleftypelocal{3}%
\gre@update@clefwidth@forced{\wd\gre@box@temp@width}}%
{cb}%
{\global\let\GreHyph\gre@char@zerohyph}%
{fb}%
{\global\let\GreHyph\gre@char@zerohyph}%
}[% all other cases
\gre@error{Unrecognized option "#1" for \protect\grelocalbolshiftcleftype\MessageBreak Possible options are: 'max', 'current', 'c', 'f', 'cb' and 'fb'.}%
]%
}

% dimen keeping the shift computed with next function
\newdimen\gre@dimen@eolshift
\newcount\gre@count@protrusion@hyphen@eol %
Expand Down Expand Up @@ -1212,9 +1282,6 @@
% begindifference is the difference between the beginning of the text and the beginning of the notes. Warning : it can be negative.
\newdimen\gre@dimen@begindifference\relax%

% the width of the clef
\newdimen\gre@dimen@clefwidth\relax%

% the width of the last glyph
\newdimen\gre@dimen@lastglyphwidth\relax%

Expand Down

0 comments on commit 7e53de9

Please sign in to comment.