From 7e53de92a5f04d33773f61e72eb3dd3daceb347e Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sat, 30 Jul 2016 15:07:12 +0200 Subject: [PATCH] #1189: TeX part --- tex/gregoriotex-main.tex | 1 + tex/gregoriotex-signs.tex | 38 ++++++++++++------- tex/gregoriotex-spaces.tex | 75 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 96 insertions(+), 18 deletions(-) diff --git a/tex/gregoriotex-main.tex b/tex/gregoriotex-main.tex index c6dddb4d9..be87d683b 100644 --- a/tex/gregoriotex-main.tex +++ b/tex/gregoriotex-main.tex @@ -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 % diff --git a/tex/gregoriotex-signs.tex b/tex/gregoriotex-signs.tex index 1f99ef394..e002c319c 100644 --- a/tex/gregoriotex-signs.tex +++ b/tex/gregoriotex-signs.tex @@ -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) @@ -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}% @@ -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 % @@ -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 % diff --git a/tex/gregoriotex-spaces.tex b/tex/gregoriotex-spaces.tex index 503257145..7c78e736c 100644 --- a/tex/gregoriotex-spaces.tex +++ b/tex/gregoriotex-spaces.tex @@ -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% @@ -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 % @@ -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 % @@ -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%