diff --git a/CHANGELOG.md b/CHANGELOG.md index 5955d25f3..ff6e93b75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/). - Staff lines after a two-line initial should now be sized correctly in a more consistent way (see [#1141](https://github.com/gregorio-project/gregorio/issues/1141)). - Space at the end of line was not always correct when a line is cut in the middle of a word (see [#1155](https://github.com/gregorio-project/gregorio/issues/1155)). - In rare cases, the very last bar or glyph of a score could appear alone at the beginning of the final line (see [#1152](https://github.com/gregorio-project/gregorio/issues/1152)). +- Hyphens in the middle of a syllable no longer overlap the text after the hyphen when `\greseteolhyphen{zero}` is used (see [#1140](https://github.com/gregorio-project/gregorio/issues/1140)). ## [4.2.0-rc1] - 2016-05-31 ### Fixed diff --git a/doc/Command_Index_User.tex b/doc/Command_Index_User.tex index 36d63dc7e..6425e61df 100644 --- a/doc/Command_Index_User.tex +++ b/doc/Command_Index_User.tex @@ -1042,7 +1042,7 @@ \subsubsection{Sign printing} \subsubsection{Hyphenation} -\macroname{\textbackslash gresethyphen}{\{\#1\}}{gregoriotex-main.tex} +\macroname{\textbackslash gresethyphen}{\{\#1\}}{gregoriotex-syllable.tex} Tells Gregorio\TeX\ how to place a hyphen between syllables in polysyllabic words in a score. \begin{argtable} @@ -1058,7 +1058,7 @@ \subsubsection{Hyphenation} & \texttt{auto} & A hyphen will appear after an empty first syllable based on the setting of \texttt{maximumspacewithoutdash} \end{argtable} -\macroname{\textbackslash greseteolhyphen}{\{\#1\}}{gregoriotex-main.tex} +\macroname{\textbackslash greseteolhyphen}{\{\#1\}}{gregoriotex-syllable.tex} Marco to determine how much space the hyphen at the end of a line occupies for the purposes of spacing calculations (the visible appearance of the hyphen is unchanged). \begin{argtable} diff --git a/doc/Command_Index_gregorio.tex b/doc/Command_Index_gregorio.tex index cee16bb4d..5abe892db 100644 --- a/doc/Command_Index_gregorio.tex +++ b/doc/Command_Index_gregorio.tex @@ -532,8 +532,8 @@ \section{Gregorio Controls} & \texttt{1} & Choral sign occurs before last note of podatus, porrectus, or torculus resupinus.\\ \end{argtable} -\macroname{\textbackslash GreHyph}{}{gregoriotex-main.tex} -Macro used for end of line hyphens. Defaults to \verb=\gre@char@normalhyph=. +\macroname{\textbackslash GreHyph}{}{gregoriotex-syllable.tex} +Macro used for hyphens entered in gabc that are not at the end of a syllable. \macroname{\textbackslash GreInDivisioFinalis}{\#1\#2}{gregoriotex-signs.tex} Same as \verb=\GreDivisioFinalis= except inside a syllable. diff --git a/doc/Command_Index_internal.tex b/doc/Command_Index_internal.tex index c3e874c68..4b7c8c788 100644 --- a/doc/Command_Index_internal.tex +++ b/doc/Command_Index_internal.tex @@ -590,6 +590,20 @@ \section{Gregorio\TeX{} Controls} \macroname{\textbackslash gre@opening@syllabletext}{}{gregoriotex-syllable.tex} Macro that stores the computed \TeX\ code for rendering the text of the first syllable. +\macroname{\textbackslash gre@hyphen}{\#1\#2}{gregoriotex-syllable.tex} +Macro that typesets a hyphen. + +\begin{argtable} + \#1 & \texttt{0} & Typeset a hyphen at the end of a syllable, but not at the end of a line\\ + & \texttt{1} & Typeset a hyphen at the end of a line\\ + & \texttt{2} & Typeset a hyphen not at the end of a syllable\\ + \#2 & skip & The amount of space between the syllable text on either side; only meaningful when \#1 is \texttt{0}\\ +\end{argtable} + +\macroname{\textbackslash gre@eolhyphen}{}{gregoriotex-syllable.tex} +Control sequence aliased to the appropriate end-of-line hyphen macro. +Manipulated by \verb=\greseteolhyphen=. + \macroname{\textbackslash gre@exhyphencharsave}{}{gregoriotex-main.tex} Macro for saving the ex hyphen character so that it can be restored at the end of the score. @@ -1430,13 +1444,13 @@ \subsection{Character Reference Aliases} \macroname{\textbackslash gre@fontchar@divisiomaior}{}{gregoriotex-signs.tex} The divisio maior. -\macroname{\textbackslash gre@char@normalhyphen}{}{gregoriotex-main.tex} +\macroname{\textbackslash gre@char@normalhyphen}{}{gregoriotex-syllable.tex} A normal hyphen in the text font. -\macroname{\textbackslash gre@char@zerohyph}{}{gregoriotex-main.tex} +\macroname{\textbackslash gre@char@zerohyph}{}{gregoriotex-syllable.tex} Macro to typeset a zero-width hyphen (the hyphen is visible, it is only -treated as if it had 0 width when calculating spaces). Used for fine tuning spacing -(especially at line endings). +treated as if it had 0 width when calculating spaces). Used for fine tuning +spacing at line endings. \macroname{\textbackslash gre@char@fuse@debilis}{}{gregoriotex-chars.tex} A fused character consisting of a leading punctum initio debilis (of ambitus one) and a regular punctum. @@ -1478,7 +1492,7 @@ \subsection{Flags} \macroname{\textbackslash gre@count@annotationvalign}{}{gregoriotex-main.tex} Count used to indicate which part of the annotation control line should be initially aligned with the top line of the staff. Values: \texttt{0}, top; \texttt{1}, baseline; or \texttt{2}, bottom. -\macroname{\textbackslash ifgre@forcehyphen}{}{gregoriotex-main.tex} +\macroname{\textbackslash ifgre@forcehyphen}{}{gregoriotex-syllable.tex} Boolean used to indicate if hyphens should be forced between all syllables in a polysyllabic word. \macroname{\textbackslash ifgre@checklength}{}{gregoriotex-spaces.tex} @@ -1897,6 +1911,9 @@ \subsection{Distances} \macroname{\textbackslash gre@skip@temp@...}{}{gregoriotex-spaces.tex} Temporary skips used in calculations. There are currently four of these. +\macroname{\textbackslash gre@skip@intersyllablespace}{}{gregoriotex-syllable.tex} +Holds the amount of space between syllable texts in the middle of a line. + \macroname{\textbackslash gre@dimen@savedglyphraise}{}{gregoriotex-signs.tex} Macro to hold the value of the glyph raise so that it can be restored after some calculations which may change it are performed. diff --git a/tex/gregoriotex-main.tex b/tex/gregoriotex-main.tex index beb5db350..a462b4ce0 100644 --- a/tex/gregoriotex-main.tex +++ b/tex/gregoriotex-main.tex @@ -1908,52 +1908,6 @@ %%% \gre@gabcsnipper@option is DEPRECATED for removal in 5.0 \def\gabcsnippet{\@ifnextchar[{\gre@gabcsnippet@option}{\gre@gabcsnippet}}% -%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% some hyphen definitions -%%%%%%%%%%%%%%%%%%%%%%%%%%% - -% a zero-width hyphen, useful for fine tuning line endings. To input in gabc verb for example. -\def\gre@char@zerohyph{% - \hbox to 0pt{% - \char\the\hyphenchar\font % - \hss % - }% -}% - -% a normal hyphen -\def\gre@char@normalhyphen{% - %- - \char\the\hyphenchar\font % -}% - -% the definition that will be always used for end of lines hyphens in gregorio, except if one of the two before is explicitely used -\let\GreHyph\gre@char@normalhyphen % - -% macro to change the definition of the hyphen: -\def\greseteolhyphen#1{% - \IfStrEqCase{#1}{% - {normal}% - {\global\let\GreHyph\gre@char@normalhyphen}% - {zero}% - {\global\let\GreHyph\gre@char@zerohyph}% - }[% all other cases - \gre@error{Unrecognized option "#1" for \protect\greseteolhyphen\MessageBreak Possible options are: 'normal' and 'zero'}% - ]% -}% - -% macro to force hyphenation of all syllables. -\newif\ifgre@forcehyphen\gre@forcehyphenfalse% -\def\gresethyphen#1{% - \IfStrEqCase{#1}{% - {force}% - {\gre@forcehyphentrue}% - {auto}% - {\gre@forcehyphenfalse}% - }[% all other cases - \gre@error{Unrecognized option "#1" in \protect\gresethyphen\MessageBreak Possible options are: 'force' and 'auto'}% - ]% -}% - % macro called before the headers of a given inclusion \def\GreBeginHeaders{}% \long\def\grebeforeheaders#1{\def\GreBeginHeaders{#1}}% diff --git a/tex/gregoriotex-spaces.tex b/tex/gregoriotex-spaces.tex index a97f9d39c..750d62259 100644 --- a/tex/gregoriotex-spaces.tex +++ b/tex/gregoriotex-spaces.tex @@ -445,7 +445,7 @@ \gre@dimen@temp@three=0pt\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}% + \setbox\gre@box@temp@width=\hbox{\gre@eolhyphen}% \gre@dimen@temp@three=\dimexpr(\wd\gre@box@temp@width * ((100 - \gre@count@protrusion@hyphen@eol) / 100))\relax% \gre@debugmsg{eolshift}{widthof the potential hyphen: \the\gre@dimen@temp@three}% \fi % diff --git a/tex/gregoriotex-syllable.tex b/tex/gregoriotex-syllable.tex index ad5f7c6a8..561f8d5d3 100644 --- a/tex/gregoriotex-syllable.tex +++ b/tex/gregoriotex-syllable.tex @@ -651,6 +651,52 @@ }% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% some hyphen definitions +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% a zero-width hyphen, useful for fine tuning line endings. To input in gabc verb for example. +\def\gre@char@zerohyph{% + \hbox to 0pt{% + \char\the\hyphenchar\font % + \hss % + }% +}% + +% a normal hyphen +\def\gre@char@normalhyphen{% + %- + \char\the\hyphenchar\font % +}% + +% the definition that will be always used for end of lines hyphens in gregorio, except if one of the two before is explicitely used +\let\gre@eolhyphen\gre@char@normalhyphen % + +% macro to change the definition of the hyphen: +\def\greseteolhyphen#1{% + \IfStrEqCase{#1}{% + {normal}% + {\global\let\gre@eolhyphen\gre@char@normalhyphen}% + {zero}% + {\global\let\gre@eolhyphen\gre@char@zerohyph}% + }[% all other cases + \gre@error{Unrecognized option "#1" for \protect\greseteolhyphen\MessageBreak Possible options are: 'normal' and 'zero'}% + ]% +}% + +% macro to force hyphenation of all syllables. +\newif\ifgre@forcehyphen\gre@forcehyphenfalse% +\def\gresethyphen#1{% + \IfStrEqCase{#1}{% + {force}% + {\gre@forcehyphentrue}% + {auto}% + {\gre@forcehyphenfalse}% + }[% all other cases + \gre@error{Unrecognized option "#1" in \protect\gresethyphen\MessageBreak Possible options are: 'force' and 'auto'}% + ]% +}% + \newif\ifgre@forceemptyfirstsyllablehyphen% \gre@forceemptyfirstsyllablehyphentrue% \def\gresetemptyfirstsyllablehyphen#1{% @@ -664,6 +710,25 @@ ]% }% +% #1 is the type of hyphen: +% 0 for a hyphen at the end of a syllable, but not at the end of a line +% 1 for a hyphen at the end of a line (implying it's at the end of a syllable) +% 2 for a hyphen not at the end of a syllable +% #2 is the available space between the syllable text on either side (only +% applicable when #1 is 0) +\def\gre@hyphen#1#2{% + \ifcase#1\relax % 0 + \char\the\hyphenchar\font % + \or % 1 + \gre@eolhyphen % + \or % 2 + \char\the\hyphenchar\font % + \fi % +}% + +% forced hyphen within a syllable (from gabc) +\def\GreHyph{\gre@hyphen{2}{}}% + \newif\ifgre@showhyphenafterthissyllable% \def\GreForceHyphen{\global\gre@showhyphenafterthissyllabletrue\gre@debugmsg{hyphen}{Forcing hyphen in gabc}} \def\GreEmptyFirstSyllableHyphen{\ifgre@forceemptyfirstsyllablehyphen\GreForceHyphen\fi}% @@ -783,6 +848,8 @@ \relax % }% +\newskip\gre@skip@intersyllablespace + %% general macro : it will typeset the syllable : arguments are : % #1 : macro setting the letters of this syllable % #2 : reserved (unused) @@ -893,20 +960,20 @@ \gre@calculate@syllablefinalskip{#4}{\gre@count@temp@one}% \ifcase#4 % % we enter here if the end of word is 0, so we must determine if we need to type a dash here - \gre@skip@temp@one = \gre@skip@syllablefinalskip\relax% + \gre@skip@intersyllablespace = \gre@skip@syllablefinalskip\relax% \gre@debugmsg{ifdim}{ enddifference > 0pt}% \ifdim\gre@dimen@enddifference >0pt\relax% - \advance\gre@skip@temp@one by \gre@dimen@enddifference\relax% + \advance\gre@skip@intersyllablespace by \gre@dimen@enddifference\relax% \fi % \gre@debugmsg{ifdim}{ nextbegindifference > 0pt}% \ifdim\gre@skip@nextbegindifference >0pt\relax% - \advance\gre@skip@temp@one by \gre@skip@nextbegindifference\relax% + \advance\gre@skip@intersyllablespace by \gre@skip@nextbegindifference\relax% \fi % % % then we compare it with \gre@space@dimen@maximumspacewithoutdash, if it is larger, we add a dash % \gre@debugmsg{ifdim}{ temp@skip@one > maximumspacewithoutdash}% - \ifdim\gre@skip@temp@one > \gre@space@dimen@maximumspacewithoutdash\relax% + \ifdim\gre@skip@intersyllablespace > \gre@space@dimen@maximumspacewithoutdash\relax% \gre@debugmsg{hyphen}{spacing requires hyphen}% \gre@showhyphenafterthissyllabletrue% \fi % @@ -914,16 +981,16 @@ \ifgre@showhyphenafterthissyllable\relax% \global\gre@possibleluahyphenafterthissyllablefalse % \gre@debugmsg{hyphen}{Showing the hyphen}% - % if it's the last syllable of line, the hyphen will be \GreHyph + % if it's the last syllable of line, the hyphen will be type 2 \ifnum\gre@lastoflinecount=1\relax % \ifgre@showlyrics% - \setbox\gre@box@syllabletext=\hbox{\gre@emit@syllabletext{\gre@pointandclick{\gre@firstsyllablepart\gre@middlesyllablepart\gre@emit@endsyllablepart#3{\GreHyph}\relax}{#6}}}% + \setbox\gre@box@syllabletext=\hbox{\gre@emit@syllabletext{\gre@pointandclick{\gre@firstsyllablepart\gre@middlesyllablepart\gre@emit@endsyllablepart#3{\gre@hyphen{1}{}}\relax}{#6}}}% \else% \setbox\gre@box@syllabletext=\box\voidb@x% \fi% \else % \ifgre@showlyrics% - \setbox\gre@box@syllabletext=\hbox{\gre@emit@syllabletext{\gre@pointandclick{\gre@firstsyllablepart\gre@middlesyllablepart\gre@emit@endsyllablepart#3{-}}{#6}}}% + \setbox\gre@box@syllabletext=\hbox{\gre@emit@syllabletext{\gre@pointandclick{\gre@firstsyllablepart\gre@middlesyllablepart\gre@emit@endsyllablepart#3{\gre@hyphen{0}{\gre@skip@intersyllablespace}}}{#6}}}% \else% \setbox\gre@box@syllabletext=\box\voidb@x% \fi%