Skip to content

Commit

Permalink
first attempt at fixing #845
Browse files Browse the repository at this point in the history
  • Loading branch information
eroux committed Feb 21, 2016
1 parent 8463776 commit d51ce56
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ All notable changes to this project will be documented in this file.
As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/). It follows [some conventions](http://keepachangelog.com/).

## [Unreleased][unreleased]

### Fixed
- hyphens now cannot go right of the staff lines. A protrusion factor can now be applied for hyphens at end of lines (50% by default), it can be changed through `\gresethyphenprotrusion` (see GregorioRef and [#845](https://github.com/gregorio-project/gregorio/issues/845)).

## [4.1.0-rc1] - 2016-02-18
### Fixed
Expand Down
9 changes: 9 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ 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.

### Protrusion of hyphens at end of line

The default protrusion factor for hyphens at end of lines is 50, meaning that 50% of the hyphen is ignored by horizontal spacing algorithm at end of line. This should:

- prevent hyphens from going too far right, especially no further than end of line
- stretch some lines a little bit

If you prefer the old behavior, `\gresethyphenprotrusion{100}` should restore it (or at least differences should be small). The value 100 may be suprising, but many hyphens were not taken into account at all at end of lines previously, while they are now, hence the value.

### 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 @@ -962,6 +962,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, over 100
\end{argtable}

Note that a proper interface for setting protrusion factor of punctuation signs might appear in the next version, deprecating this one.

\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 @@ -1513,7 +1513,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, and used by \verb=\gre@calculate@eolshift= for protrusion calculation.
\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 @@ -1595,6 +1598,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
17 changes: 17 additions & 0 deletions tex/gregoriotex-spaces.tex
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,13 @@

% dimen keeping the shift computed with next function
\newdimen\gre@dimen@eolshift
\newcount\gre@count@protrusion@hyphen@eol %
\gre@count@protrusion@hyphen@eol = 50
%
\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
Expand All @@ -401,6 +408,16 @@
\else%
% The basic value for the eol shift is -enddifference
\global\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}%
\global\advance\gre@skip@temp@two by -\dimexpr(\wd\gre@box@temp@width * ((100 - \gre@count@protrusion@hyphen@eol) / 100))\relax%
\fi %
% if there is an automatic hyphen, we apply the protrusion factor
\ifgre@showhyphenafterthissyllable %
\setbox\gre@box@temp@width=\hbox{\GreHyph}%
\global\advance\gre@skip@temp@two by \dimexpr(\wd\gre@box@temp@width * (\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
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 @@ -873,7 +882,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 d51ce56

Please sign in to comment.