Skip to content

Commit

Permalink
Merge pull request #1249 from henryso/fix-1007
Browse files Browse the repository at this point in the history
Made high and low clefs influence the additional space calculation.
  • Loading branch information
henryso authored Nov 8, 2016
2 parents 6a84ced + 8600dcc commit 08f91fa
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/).
- A clef change immediately before a line break `(z)` will now typeset the new clef at the beginning of the next line. An explicit custos `(z0)` immediately before such a clef change (or separated by only a bar) will be suppressed. See [#1190](https://github.com/gregorio-project/gregorio/issues/1190).
- Ledger lines are now extended through notes on either side of a ledger line that crosses a stem, as long as the notes are within the same "element." If the algorithm doesn't produce the result you want, you can use `[oll:0]` to suppress an over-the-staff ledger line on a note, `[ull:0]` to suppress an under-the-staff ledger line on a note, `[oll:1]` to force an over-the-line ledger line on a note, or [ull:1] to force an under-the-staff ledger line on a note. Please note that other forms of `[oll:...]` and `[ull:...]` can interfere with these new settings. See [UPGRADE.md](UPGRADE.md) and [#1215](https://github.com/gregorio-project/gregorio/issues/1215) for details.
- The left stem of Dominican plicae on lines has been shortened (see [#1238](https://github.com/gregorio-project/gregorio/issues/1238)).
- Clefs on the top or bottom line adjust the spacing as if there were a note above the top line or below the bottom line, respectively (see [#1007](https://github.com/gregorio-project/gregorio/issues/1007)).

### Added
- More cavum shapes are now available. To use them, simply add `r` in gabc to any note in a glyph. See [#844](https://github.com/gregorio-project/gregorio/issues/844).
Expand Down
13 changes: 12 additions & 1 deletion doc/Command_Index_gregorio.tex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ \section{Gregorio Controls}
\#2 & string & Second line text to place above the initial.\\
\end{argtable}

\macroname{\textbackslash GreBeginScore}{\#1\#2\#3\#4\#5\#6\#7}{gregoriotex-main.tex}
\macroname{\textbackslash GreBeginScore}{\#1\#2\#3\#4\#5\#6\#7\#8}{gregoriotex-main.tex}
Macro to start a score.

\begin{argtable}
Expand All @@ -51,6 +51,8 @@ \section{Gregorio Controls}
& 1 & there is above lines text somewhere in the score\\
\#6 & string & the absolute filename of the gabc file if point-and-click is enabled\\
\#7 & integer & the number of staff lines\\
\#8 & \TeX\ code & macros to run before the score (\eg, setting clef
extrema)\\
\end{argtable}

\macroname{\textbackslash GreEndScore}{}{gregoriotex-main.tex}
Expand Down Expand Up @@ -598,6 +600,15 @@ \section{Gregorio Controls}
\macroname{\textbackslash GreInDominica}{\#1\#2\#3}{gregoriotex-signs.tex}
Same as \verb=\GreDominica= except inside a syllable.

\macroname{\textbackslash GreInitialClefPosition}{\#1\#2}{gregoriotex-signs.tex}
Saves the extrema of the initial clef.

\begin{argtable}
\#1 & integer & the line of the primary clef (1 is the bottom line)\\
\#2 & integer & the line of the secondary clef (1 is the bottom line, 0 means
no secondary clef)\\
\end{argtable}

\macroname{\textbackslash GreInVirgula}{\#1\#2\#3}{gregoriotex-signs.tex}
Same as \verb=\GreVirgula= except inside a syllable.

Expand Down
31 changes: 31 additions & 0 deletions doc/Command_Index_internal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,22 @@ \section{Gregorio\TeX{} Controls}
\macroname{\textbackslash gre@pitch@nominal}{}{gregoriotex-main.tex}
A pitch guaranteed to be in the staff.
\macroname{\textbackslash gre@pitch@cleftop}{}{gregoriotex-spaces.tex}
The pitch of the highest point of the current clef.
\macroname{\textbackslash gre@pitch@clefbottom}{}{gregoriotex-spaces.tex}
The pitch of the lowest point of the current clef.
\macroname{\textbackslash gre@saveclefextrema}{\#1\#2}{gregoriotex-signs.tex}
Computes the pitches of the lowest and highest points of a clef and saves them
into \verb=\gre@pitch@cleftop= and \verb=\gre@pitch@clefbottom=.
\begin{argtable}
\#1 & integer & the line of the primary clef (1 is the bottom line)\\
\#2 & integer & the line of the secondary clef (1 is the bottom line, 0 means
no secondary clef)\\
\end{argtable}
\macroname{\textbackslash gre@pointandclick}{\#1\#2}{gregoriotex-main.tex}
Macro to generate the point-and-click links.
Expand Down Expand Up @@ -1341,6 +1357,21 @@ \section{Gregorio\TeX{} Controls}
\macroname{\textbackslash gre@punctummoraadjustment}{}{gregoriotex-spaces.tex}
Macro to make adjustments to cursor position and \verb=previousenddifference= based on the presence of a punctum mora at the end of the last syllable.
\macroname{\textbackslash gre@num@min}{\#1\#2}{gregoriotex-spaces.tex}
Puts the lower of its two integer arguments into \verb=\gre@count@temp@one=.
\begin{argtable}
\#1 & integer & the first value to compare\\
\#2 & integer & the second value to compare\\
\end{argtable}
\macroname{\textbackslash gre@num@max}{\#1\#2}{gregoriotex-spaces.tex}
Puts the greater of its two integer arguments into \verb=\gre@count@temp@one=.
\begin{argtable}
\#1 & integer & the first value to compare\\
\#2 & integer & the second value to compare\\
\end{argtable}
\subsection{Auxiliary File}
Gregorio\TeX\ creates its own auxiliary file (extension \texttt{gaux}) which it uses to store information between successive typesetting runs. This allows for such features as the dynamic interline spacing. The following functions are used to interact with that auxiliary file.
Expand Down
11 changes: 6 additions & 5 deletions src/gregoriotex/gregoriotex-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -4329,12 +4329,16 @@ void gregoriotex_write_score(FILE *const f, gregorio_score *const score,

write_headers(f, score);

fprintf(f, "\\GreBeginScore{%s}{%d}{%d}{%d}{%d}{%s}{%u}%%\n",
if (score->first_voice_info) {
clef = score->first_voice_info->initial_clef;
}
fprintf(f, "\\GreBeginScore{%s}{%d}{%d}{%d}{%d}{%s}{%u}"
"{\\GreInitialClefPosition{%d}{%d}}%%\n",
digest_to_hex(score->digest), status.top_height,
status.bottom_height, bool_to_int(status.translation),
bool_to_int(status.abovelinestext),
point_and_click_filename? point_and_click_filename : "",
score->staff_lines);
score->staff_lines, clef.line, clef.secondary_line);
if (score->nabc_lines) {
fprintf(f, "\\GreScoreNABCLines{%d}", (int)score->nabc_lines);
}
Expand Down Expand Up @@ -4372,9 +4376,6 @@ void gregoriotex_write_score(FILE *const f, gregorio_score *const score,
gregoriotex_write_voice_info(f, score->first_voice_info);
}
fprintf(f, "}{%%\n"); /* GreScoreOpening#2 */
if (score->first_voice_info) {
clef = score->first_voice_info->initial_clef;
}
fprintf(f, "\\GreSetInitialClef{%c}{%d}{%d}{%c}{%d}{%d}{%d}%%\n",
gregorio_clef_to_char(clef.clef), clef.line,
clef_flat_height(clef.clef, clef.line, clef.flatted),
Expand Down
6 changes: 5 additions & 1 deletion tex/gregoriotex-main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,8 @@
% #5 is if 1 if we have space above the staff
% #6 is the point-and-click filename
% #7 is the number of staff lines
\def\GreBeginScore#1#2#3#4#5#6#7{%
% #8 is to set the initial clef position
\def\GreBeginScore#1#2#3#4#5#6#7#8{%
% scores must be new paragraphs!
\ifhmode\par\fi %
\gre@beginningofscoretrue%
Expand All @@ -1180,6 +1181,8 @@
\gre@resetledgerlineheuristics%
\global\setluatexattribute\gre@attr@glyph@id{0}%
\global\setluatexattribute\gre@attr@syllable@id{0}%
\let\gre@pitch@cleftop\gre@pitch@dummy %
\let\gre@pitch@clefbottom\gre@pitch@dummy %
\xdef\gre@gabcname{#6}%
\gre@setstafflines{#7}%
\ifgre@justifylastline%
Expand All @@ -1197,6 +1200,7 @@
\gre@generatelines %
\noindent%
\gre@calculate@additionalspaces{#2}{#3}{#4}{#5}%
#8%
\directlua{
gregoriotex.atScoreBeginning([[#1]], #2, #3, #4, #5,
\gre@pitch@adjust@top, \gre@pitch@adjust@bottom,
Expand Down
72 changes: 72 additions & 0 deletions tex/gregoriotex-signs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,77 @@
}%
}

\def\gre@saveclefextrema#1#2{%
% compute the clef extrema
\ifcase#1\or % first@1
\global\let\gre@pitch@cleftop\gre@pitch@e %
\global\let\gre@pitch@clefbottom\gre@pitch@c %
\ifcase#2\or\or % second@2
\global\let\gre@pitch@cleftop\gre@pitch@g %
\or % second@3
\global\let\gre@pitch@cleftop\gre@pitch@i %
\or % second@4
\global\let\gre@pitch@cleftop\gre@pitch@k %
\or % second@5
\global\let\gre@pitch@cleftop\gre@pitch@m %
\fi %
\or % first@2
\global\let\gre@pitch@cleftop\gre@pitch@g %
\global\let\gre@pitch@clefbottom\gre@pitch@e %
\ifcase#2\or % second@1
\global\let\gre@pitch@clefbottom\gre@pitch@c %
\or\or % second@3
\global\let\gre@pitch@cleftop\gre@pitch@i %
\or % second@4
\global\let\gre@pitch@cleftop\gre@pitch@k %
\or % second@5
\global\let\gre@pitch@cleftop\gre@pitch@m %
\fi %
\or % first@3
\global\let\gre@pitch@cleftop\gre@pitch@i %
\global\let\gre@pitch@clefbottom\gre@pitch@g %
\ifcase#2\or % second@1
\global\let\gre@pitch@clefbottom\gre@pitch@c %
\or % second@2
\global\let\gre@pitch@clefbottom\gre@pitch@e %
\or\or % second@4
\global\let\gre@pitch@cleftop\gre@pitch@k %
\or % second@5
\global\let\gre@pitch@cleftop\gre@pitch@m %
\fi %
\or % first@4
\global\let\gre@pitch@cleftop\gre@pitch@k %
\global\let\gre@pitch@clefbottom\gre@pitch@i %
\ifcase#2\or % second@1
\global\let\gre@pitch@clefbottom\gre@pitch@c %
\or % second@2
\global\let\gre@pitch@clefbottom\gre@pitch@e %
\or % second@3
\global\let\gre@pitch@clefbottom\gre@pitch@g %
\or\or % second@5
\global\let\gre@pitch@cleftop\gre@pitch@m %
\fi %
\or % first@5
\global\let\gre@pitch@cleftop\gre@pitch@m %
\global\let\gre@pitch@clefbottom\gre@pitch@k %
\ifcase#2\or % second@1
\global\let\gre@pitch@clefbottom\gre@pitch@c %
\or % second@2
\global\let\gre@pitch@clefbottom\gre@pitch@e %
\or % second@3
\global\let\gre@pitch@clefbottom\gre@pitch@g %
\or % second@4
\global\let\gre@pitch@clefbottom\gre@pitch@i %
\fi %
\fi %
}%

\def\GreInitialClefPosition#1#2{%
\ifgre@showclef %
\gre@saveclefextrema{#1}{#2}%
\fi %
}%

% macro that typesets the clef
% arguments are :
%% #1: the type of the clef : c or f
Expand All @@ -230,6 +301,7 @@
%% #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@saveclefextrema{#2}{#7}%
\gre@boxclef{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
\ifcase#3%
\gre@update@clefwidth@current{\wd\gre@box@temp@width}%
Expand Down
30 changes: 26 additions & 4 deletions tex/gregoriotex-spaces.tex
Original file line number Diff line number Diff line change
Expand Up @@ -868,31 +868,53 @@
\newcount\gre@space@count@additionaltopspacenabcthreshold\relax%
\gre@space@count@additionaltopspacenabcthreshold=4

\def\gre@num@min#1#2{%
\ifnum#1 < #2\relax %
\gre@count@temp@one=#1\relax %
\else %
\gre@count@temp@one=#2\relax %
\fi %
}%
\def\gre@num@max#1#2{%
\ifnum#1 > #2\relax %
\gre@count@temp@one=#1\relax %
\else %
\gre@count@temp@one=#2\relax %
\fi %
}%

\let\gre@pitch@cleftop\gre@pitch@dummy %
\let\gre@pitch@clefbottom\gre@pitch@dummy %

% #1 is the high height
% #2 is the low height
% #3 is 1 if there is a translation somewhere
% #4 is if 1 if we have space above the staff
\def\gre@calculate@additionalspaces#1#2#3#4{%
\gre@debugmsg{lineheight}{gre@calculate@additional@spaces called with #1 #2 #3 #4}%
\gre@count@temp@one=\numexpr(#1 - \gre@pitch@adjust@top - \gre@space@count@additionaltopspacethreshold)\relax %
\gre@num@max{#1}{\gre@pitch@cleftop}%
\gre@count@temp@one=\numexpr(\gre@count@temp@one - \gre@pitch@adjust@top - \gre@space@count@additionaltopspacethreshold)\relax %
\ifnum\gre@count@temp@one>0\relax %
\global\gre@dimen@additionaltopspace=\dimexpr(15750 sp * \gre@count@temp@one * \gre@factor)\relax %
\else %
\global\gre@dimen@additionaltopspace=0 sp%
\fi %
\gre@count@temp@one=\numexpr(#1 - \gre@pitch@adjust@top - \gre@space@count@additionaltopspacealtthreshold)\relax %
\gre@num@max{#1}{\gre@pitch@cleftop}%
\gre@count@temp@one=\numexpr(\gre@count@temp@one - \gre@pitch@adjust@top - \gre@space@count@additionaltopspacealtthreshold)\relax %
\ifnum\gre@count@temp@one>0\relax %
\global\gre@dimen@additionaltopspacealt=\dimexpr(15750 sp * \gre@count@temp@one * \gre@factor)\relax %
\else %
\global\gre@dimen@additionaltopspacealt=0 sp%
\fi %
\gre@count@temp@one=\numexpr(#1 - \gre@pitch@adjust@top - \gre@space@count@additionaltopspacenabcthreshold)\relax %
\gre@num@max{#1}{\gre@pitch@cleftop}%
\gre@count@temp@one=\numexpr(\gre@count@temp@one - \gre@pitch@adjust@top - \gre@space@count@additionaltopspacenabcthreshold)\relax %
\ifnum\gre@count@temp@one>0\relax %
\global\gre@dimen@additionaltopspacenabc=\dimexpr(15750 sp * \gre@count@temp@one * \gre@factor)\relax %
\else %
\global\gre@dimen@additionaltopspacenabc=0 sp%
\fi %
\gre@count@temp@one=\numexpr((#2 - \gre@pitch@adjust@bottom) * -1)\relax %
\gre@num@min{#2}{\gre@pitch@clefbottom}%
\gre@count@temp@one=\numexpr((\gre@count@temp@one - \gre@pitch@adjust@bottom) * -1)\relax %
\ifnum\gre@count@temp@one>0\relax %
\global\gre@dimen@additionalbottomspace=\dimexpr(15750 sp * \gre@count@temp@one * \gre@factor)\relax %
\else %
Expand Down

0 comments on commit 08f91fa

Please sign in to comment.