Skip to content

Commit

Permalink
Merge pull request #945 from gregorio-project/fix-845
Browse files Browse the repository at this point in the history
Fix #845
  • Loading branch information
eroux committed Feb 22, 2016
2 parents 3135dc6 + 2ef9157 commit 3aab191
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased][unreleased]
### Fixed
- hyphens now shouldn't go right of the staff lines (see [#845](https://github.com/gregorio-project/gregorio/issues/845)).
- Offset limit calculations now function better in both directions for new bar spacing algorithm.

### Added
- It is now possible to turn off rythmic signs (separately or all together) with `\greprintsigns`, see GregorioRef for details (and [#936](https://github.com/gregorio-project/gregorio/issues/936) for request).
- Added `maxbaroffsettextright@nobar` and `maxbaroffsettextleft@nobar` which function identically to the normal version except that they are used then the "bar" is empty (i.e. something like `*()` in gabc).


## [4.1.0-rc1] - 2016-02-18
### Fixed
- New bar spacing algorithm now accounts for translations (and other below lyrics stuff).
Expand Down
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ The following spaces have been added:

By default, these are sized one half millimeter larger than their "non-text" counterparts. This may cause minor spacing changes in your existing scores. Adjust them as necessary to get the look you want.

### Hyphens going right of staff lines

Hyphens should now not go right of staff lines. If you prefer the old behavior, `\gresethyphenprotrusion{100}` should restore it.

### Oriscus orientation

The oriscus orientation (whether it points up or down) is now dependent on the note the follows, even if the note is not directly connected to the oriscus (as it would be in a salicus or a pressus). Appending a `1` to an unconnected oriscus in gabc will force the oriscus to point upwards and `0` will force the oriscus to point downwards.
Expand Down
8 changes: 8 additions & 0 deletions doc/Command_Index_User.tex
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,14 @@ \subsubsection{Hyphenation}
& \texttt{zero} & The hyphen is considered to take up no space
\end{argtable}

\macroname{\textbackslash gresethyphenprotrusion}{\{\#1\}}{gregoriotex-spaces.tex}
Sets the protrusion factor of hyphens at end of lines. The default value is 50, a good compromise in the tested scores.

\begin{argtable}
\#1 & \texttt{number} & The protrusion factor, percent
\end{argtable}

Note that a proper interface for setting protrusion factor of punctuation signs might appear in the next version, deprecating this one. Also, this protrusion factor does not apply to all hyphens (only those inserted by the Lua pass), so use it with caution.

\subsubsection{Clef Visibility}

Expand Down
11 changes: 10 additions & 1 deletion doc/Command_Index_internal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,10 @@ \subsection{Flags}
Boolean which indicates that a hyphen after an empty first syllable should be forced.
\macroname{\textbackslash ifgre@showhyphenafterthissyllable}{}{gregoriotex-syllable.tex}
Boolean used by \verb=\GreSyllable= to decide if a hyphen should be shown after the syllable.
Boolean set and used by \verb=\GreSyllable= to decide if a hyphen should be shown after the syllable.
\macroname{\textbackslash ifgre@possibleluahyphenafterthissyllable}{}{gregoriotex-syllable.tex}
Boolean set by \verb=\GreSyllable= indicating if the Lua pass may add an hyphen after the syllable, used by \verb=\gre@calculate@eolshift= for protrusion calculation.
\macroname{\textbackslash ifgre@thirdlineadjustmentnecessary}{}{gregoriotex-syllable.tex}
Boolean which indicates that a third-line adjustment to staff line width is necessary.
Expand Down Expand Up @@ -1597,6 +1600,12 @@ \subsection{Boxes}
Box holding the horizontal episema.
\subsection{Protrusion factors}
Protrusion factors are counts representing a protrusion factor over 100.
\macroname{\textbackslash gre@count@protrusion@hyphen@eol}{}{gregoriotex-spaces.tex}
Protrusion factor applied to hyphens at end of lines.
\subsection{Distances}
All of the distances listed in \nameref{distances} have an internal associated
Expand Down
24 changes: 18 additions & 6 deletions tex/gregoriotex-spaces.tex
Original file line number Diff line number Diff line change
Expand Up @@ -384,29 +384,41 @@

% dimen keeping the shift computed with next function
\newdimen\gre@dimen@eolshift
\newcount\gre@count@protrusion@hyphen@eol %

% protrusion for hyphens inerted by Lua
\gre@count@protrusion@hyphen@eol = 50\relax

\def\gresethyphenprotrusion#1{%
\gre@count@protrusion@hyphen@eol = #1\relax %
\relax %
}

%% @desc Macro used in \GreSyllable. Sets \gre@dimen@eolshift to the right kern
%% that should appear before an end of line. When active this prevents
%% text from going under the custos.
%%
%% @arg#1 The \gre@dimen@enddifference of the corresponding syllable
\def\gre@calculate@eolshift#1{%
\global\gre@skip@temp@three=0pt\relax%
\global\gre@skip@temp@two=0pt\relax%
\gre@skip@temp@two=0pt\relax%
% we only need a shift if the lyrics are longer than the notes
\ifdim#1 <0pt\relax%
% we only need to shift if there is a custos being printed
\ifgre@blockeolcustos%
\global\gre@dimen@eolshift=0pt\relax%
\gre@dimen@eolshift=0pt\relax%
\else%
% The basic value for the eol shift is -enddifference
\global\gre@skip@temp@two=-#1\relax%
\gre@skip@temp@two=-#1\relax%
% if there is a possible hyphen (added afterwards in lua), we keep some room for it
\ifgre@possibleluahyphenafterthissyllable %
\setbox\gre@box@temp@width=\hbox{\GreHyph}%
\advance\gre@skip@temp@two by -\dimexpr(\wd\gre@box@temp@width * ((100 - \gre@count@protrusion@hyphen@eol) / 100))\relax%
\fi %
% The maximum value is wd(custos) + spacebeforeeolcustos
% Were the eolshift larger than this the lyrics would stick out
% into the margin
\setbox\gre@box@temp@width=\hbox{\gre@pickcustos{\gre@pitch@g}}%
\global\advance\gre@skip@temp@three by %
\glueexpr(\wd\gre@box@temp@width+\gre@space@skip@spacebeforeeolcustos)\relax%
\gre@skip@temp@three = \glueexpr(\wd\gre@box@temp@width+\gre@space@skip@spacebeforeeolcustos)\relax%
% pick the smaller of the two values calculated above
\ifdim\gre@skip@temp@two>\gre@skip@temp@three%
\gre@debugmsg{eolshift}{imposing limit}%
Expand Down
11 changes: 10 additions & 1 deletion tex/gregoriotex-syllable.tex
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,11 @@
\def\GreForceHyphen{\global\gre@showhyphenafterthissyllabletrue\gre@debugmsg{hyphen}{Forcing hyphen in gabc}}
\def\GreEmptyFirstSyllableHyphen{\ifgre@forceemptyfirstsyllablehyphen\GreForceHyphen\fi}%

% if an hyphen maybe be added by lua for this syllable. When syllable is not end of word and
% no hyphen is added by TeX.
\newif\ifgre@possibleluahyphenafterthissyllable
\gre@possibleluahyphenafterthissyllablefalse

%% general macro : it will typeset the syllable : arguments are :
% #1 : macro setting the letters of this syllable
% #2 : reserved (unused)
Expand All @@ -576,6 +581,7 @@
\gre@debugmsg{general}{}%
\gre@debugmsg{general}{New syllable: \expandafter\unexpanded{#1}}%
\gre@debugmsg{general}{}%
\global\gre@possibleluahyphenafterthissyllablefalse %
\gre@showhyphenafterthissyllablefalse%
\ifcase#4\ifgre@forcehyphen%
\gre@debugmsg{hyphen}{Forcing hyphen}%
Expand Down Expand Up @@ -684,6 +690,7 @@
\gre@attr@dash=1\relax % in this particular case where it is not the end of a word and we haven't put a dash, we set potentital dash to 1
% we rebuild this box, in order it to have the attribute
\setbox\gre@box@syllabletext=\hbox{\gre@fixedtextformat{\gre@pointandclick{\gre@firstsyllablepart\gre@middlesyllablepart\gre@endsyllablepart}{#6}}}%
\global\gre@possibleluahyphenafterthissyllabletrue %
\fi %
\fi%
% then we reuse temp, we assign to it the \gre@dimen@begindifference, but only if it is positive, else it is 0
Expand Down Expand Up @@ -836,6 +843,8 @@
%a macro to typeset a syllable with only a bar inside
\def\GreBarSyllable#1#2#3#4#5#6#7#8#9{%
\gre@debugmsg{general}{New bar syllable}%
\gre@possibleluahyphenafterthissyllablefalse %
\gre@showhyphenafterthissyllablefalse %
% the algorithm of this function is *extremely* complex, and has been much painful to write... good luck to understand.
% the main goal is, when there is no text under the bar, to put the bar in the middle of the space between the last note of the previous syllable and the first note of the next syllable. But there are limits : a bar can't go very far above text. For example if there is "nuncncncncn" with a punctum on the u, the bar can't go above the fourth n, the most far position is the position where the end of the bar is above the end of the word. The same limitation applies for the syllable after the bar.
% there are two different cases that have almost nothing in common : the case where there is something written under the bar, and the case where there is nothing.
Expand Down Expand Up @@ -876,7 +885,7 @@
\GreNoBreak %
% all that extra stuff (translations and the like)
#8%
\GreNoBreak %
\GreNoBreak %
%print the text, the raise is in case of a translation
\raise\gre@dimen@textlower \copy\gre@box@syllabletext%
%and the code which handles translation centering
Expand Down

0 comments on commit 3aab191

Please sign in to comment.