Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored hyphen macros. #1161

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions doc/Command_Index_User.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions doc/Command_Index_gregorio.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
27 changes: 22 additions & 5 deletions doc/Command_Index_internal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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.

Expand Down
46 changes: 0 additions & 46 deletions tex/gregoriotex-main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}}%
Expand Down
2 changes: 1 addition & 1 deletion tex/gregoriotex-spaces.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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 %
Expand Down
81 changes: 74 additions & 7 deletions tex/gregoriotex-syllable.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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{%
Expand All @@ -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}%
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -893,37 +960,37 @@
\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 %
\fi% ficase#4
\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%
Expand Down