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

Fixes for protruding characters and spurious hyphenation. #1256

Merged
merged 2 commits into from
Nov 25, 2016
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/).
- Horizontal episemata bridge spaces more correctly. As mentioned earlier, you can prevent this by appending `2` to the `_` on the note before the space you do not want bridged. See [#1216](https://github.com/gregorio-project/gregorio/issues/1216).
- A rising note after an oriscus flexus will no longer generate a porrectus (see [#1220](https://github.com/gregorio-project/gregorio/issues/1220)).
- The Scribus external tool script now uses latexmk in order to handle the multi-pass features of Gregorio (see [#1236](https://github.com/gregorio-project/gregorio/issues/1236)).
- Translation text in a syllable with a trailing (forced) hyphen is no longer truncated to its first character (see [#1254](https://github.com/gregorio-project/gregorio/issues/1254)).
- A trailing (forced) hyphen in a syllable no longer generates a forced hyphen in the previous syllable (see [#1255](https://github.com/gregorio-project/gregorio/issues/1255)).

## Changed
- Notes are now left-aligned as if all clefs had the same width as the largest clef in the score. You can get previous behavior back with `\grebolshiftcleftype{current}`, or temporary force alignment until the end of a score with `\grelocalbolshiftcleftype`. See Documentation of these functions and [#1189](https://github.com/gregorio-project/gregorio/issues/1189).
Expand Down
6 changes: 6 additions & 0 deletions doc/Command_Index_internal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,9 @@ \section{Gregorio\TeX{} Controls}
\#2 & integer & the second value to compare\\
\end{argtable}
\macroname{\textbackslash gre@evaluatenextsyllable}{\#1}{gregoriotex-syllable.tex}
Evaluates its first argument as an advance computation against the next syllable. Twiddles the \verb=ifgre@evaluatingnextsyllable= flag around evaluation of the macro argument.
\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 Expand Up @@ -1822,6 +1825,9 @@ \subsection{Flags}
\macroname{\textbackslash ifgre@textcleared}{}{gregoriotex-syllable.tex}
Boolean indicating that the text of this syllable should not overlap any previous syllable.
\macroname{\textbackslash ifgre@evaluatingnextsyllable}{}{gregoriotex-syllable.tex}
Boolean indicating that some aspect of the next syllable is being evaluated in advance.
\subsection{Boxes}
Boxes are used to store elements of the score before they are printed for the purposes of reusing them and/or measuring them in order to determine their appropriate placement.
Expand Down
79 changes: 58 additions & 21 deletions src/gabc/gabc-score-determination.y
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ gregorio_element *current_element;
static char *macros[10];
/* other variables that we will have to use */
static gregorio_character *current_character;
static gregorio_character *suspended_character;
static gregorio_character *first_text_character;
static gregorio_character *first_translation_character;
static gregorio_tr_centering translation_type;
Expand Down Expand Up @@ -159,6 +160,7 @@ static void initialize_variables(bool point_and_click)
number_of_voices = 1;
voice = 0; /* first (and only) voice */
current_character = NULL;
suspended_character = NULL;
first_translation_character = NULL;
first_text_character = NULL;
translation_type = TR_NORMAL;
Expand Down Expand Up @@ -342,9 +344,9 @@ static __inline void save_text(void)
* the translation pointer instead of the text pointer */
static void start_translation(unsigned char asked_translation_type)
{
save_text();
suspended_character = current_character;
/* the middle letters of the translation have no sense */
center_is_determined = CENTER_FULLY_DETERMINED;
/*center_is_determined = CENTER_FULLY_DETERMINED;*/
current_character = NULL;
translation_type = asked_translation_type;
}
Expand All @@ -353,6 +355,7 @@ static void end_translation(void)
{
ready_characters();
first_translation_character = current_character;
current_character = suspended_character;
}

/*
Expand Down Expand Up @@ -542,6 +545,7 @@ static void close_syllable(YYLTYPE *loc)
}
center_is_determined = CENTER_NOT_DETERMINED;
current_character = NULL;
suspended_character = NULL;
first_text_character = NULL;
first_translation_character = NULL;
translation_type = TR_NORMAL;
Expand Down Expand Up @@ -862,23 +866,6 @@ style_beginning:
| SP_BEGIN {
add_style(ST_SPECIAL_CHAR);
}
| ELISION_BEGIN {
add_style(ST_ELISION);
}
| CENTER_BEGIN {
if (center_is_determined) {
gregorio_message(
"syllable already has center; ignoring additional center",
"det_score", VERBOSITY_WARNING, 0);
} else if (has_protrusion) {
gregorio_message(
"center not allowed after protrusion; ignored",
"det_score", VERBOSITY_WARNING, 0);
} else {
add_style(ST_FORCED_CENTER);
center_is_determined = CENTER_HALF_DETERMINED;
}
}
;

style_end:
Expand Down Expand Up @@ -906,7 +893,30 @@ style_end:
| SP_END {
end_style(ST_SPECIAL_CHAR);
}
| ELISION_END {
;

special_style_beginning:
ELISION_BEGIN {
add_style(ST_ELISION);
}
| CENTER_BEGIN {
if (center_is_determined) {
gregorio_message(
"syllable already has center; ignoring additional center",
"det_score", VERBOSITY_WARNING, 0);
} else if (has_protrusion) {
gregorio_message(
"center not allowed after protrusion; ignored",
"det_score", VERBOSITY_WARNING, 0);
} else {
add_style(ST_FORCED_CENTER);
center_is_determined = CENTER_HALF_DETERMINED;
}
}
;

special_style_end:
ELISION_END {
end_style(ST_ELISION);
}
| CENTER_END {
Expand Down Expand Up @@ -955,6 +965,8 @@ character:
}
| style_beginning
| style_end
| special_style_beginning
| special_style_end
| linebreak_area
| euouae
| CLEAR {
Expand All @@ -974,6 +986,25 @@ text:
| text character
;

translation_character:
CHARACTERS {
add_text($1.text);
}
| style_beginning
| style_end
| HYPHEN {
add_text(gregorio_strdup("-"));
}
| PROTRUDING_PUNCTUATION {
add_text($1.text);
}
;

translation_text:
translation_character
| translation_text translation_character
;

translation_beginning:
TRANSLATION_BEGIN {
start_translation(TR_NORMAL);
Expand All @@ -984,11 +1015,12 @@ translation:
translation_beginning TRANSLATION_END {
end_translation();
}
| translation_beginning text TRANSLATION_END {
| translation_beginning translation_text TRANSLATION_END {
end_translation();
}
| TRANSLATION_CENTER_END {
start_translation(TR_WITH_CENTER_END);
end_translation();
}
;

Expand Down Expand Up @@ -1028,26 +1060,31 @@ syllable_with_notes:
close_syllable(&@1);
}
| text translation OPENING_BRACKET notes {
save_text();
close_syllable(&@1);
}
| HYPHEN translation OPENING_BRACKET notes {
add_style(ST_VERBATIM);
add_text(gregorio_strdup("\\GreForceHyphen"));
end_style(ST_VERBATIM);
save_text();
close_syllable(&@1);
}
| text HYPHEN translation OPENING_BRACKET notes {
add_style(ST_VERBATIM);
add_text(gregorio_strdup("\\GreForceHyphen"));
end_style(ST_VERBATIM);
save_text();
close_syllable(&@1);
}
| PROTRUDING_PUNCTUATION translation OPENING_BRACKET notes {
add_auto_protrusion($1.text);
save_text();
close_syllable(&@1);
}
| text PROTRUDING_PUNCTUATION translation OPENING_BRACKET notes {
add_auto_protrusion($2.text);
save_text();
close_syllable(&@1);
}
;
Expand Down
27 changes: 21 additions & 6 deletions tex/gregoriotex-syllable.tex
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
% clivis alignment
\gre@widthof{\gre@endsyllablepart}%
\else%
\gre@widthof{\gre@nextendsyllablepart}%
\gre@widthof{\gre@evaluatenextsyllable{\gre@nextendsyllablepart}}%
\fi%
\gre@debugmsg{ifdim}{ temp@three > clivisalignmentmin}%
\ifdim\gre@dimen@temp@three >\gre@space@dimen@clivisalignmentmin\relax%
Expand Down Expand Up @@ -664,8 +664,23 @@
]%
}%

\newif\ifgre@evaluatingnextsyllable%
\gre@evaluatingnextsyllablefalse%
\def\gre@evaluatenextsyllable#1{%
\gre@evaluatingnextsyllabletrue%
#1%
\gre@evaluatingnextsyllablefalse%
}%

\newif\ifgre@showhyphenafterthissyllable%
\def\GreForceHyphen{\global\gre@showhyphenafterthissyllabletrue\gre@debugmsg{hyphen}{Forcing hyphen in gabc}}
\def\GreForceHyphen{%
\ifgre@evaluatingnextsyllable%
-%
\else%
\global\gre@showhyphenafterthissyllabletrue%
\gre@debugmsg{hyphen}{Forcing hyphen in gabc}%
\fi%
}%
\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
Expand Down Expand Up @@ -880,7 +895,7 @@
% by default, gre@attr@dash will be 2
\gre@attr@dash=2\relax %
#5%
\gre@calculate@nextbegindifference{\gre@emit@endsyllablepartfornextsyllable}{\gre@nextfirstsyllablepart}{\gre@nextmiddlesyllablepart}{\gre@nextendsyllablepart}{#7}%
\gre@calculate@nextbegindifference{\gre@emit@endsyllablepartfornextsyllable}{\gre@evaluatenextsyllable{\gre@nextfirstsyllablepart}}{\gre@evaluatenextsyllable{\gre@nextmiddlesyllablepart}}{\gre@evaluatenextsyllable{\gre@nextendsyllablepart}}{#7}%
\gre@unsetfixednexttextformat %
\ifgre@showlyrics%
\setbox\gre@box@syllabletext=\hbox{\gre@emit@syllabletext{\gre@pointandclick{\gre@firstsyllablepart\gre@middlesyllablepart\gre@emit@endsyllablepart}{#6}}}%
Expand Down Expand Up @@ -936,7 +951,7 @@
\fi%
\fi %
% recomputing end difference and final skip with the final hyphen
\gre@calculate@nextbegindifference{\gre@emit@endsyllablepartfornextsyllable}{\gre@nextfirstsyllablepart}{\gre@nextmiddlesyllablepart}{\gre@nextendsyllablepart}{#7}%
\gre@calculate@nextbegindifference{\gre@emit@endsyllablepartfornextsyllable}{\gre@evaluatenextsyllable{\gre@nextfirstsyllablepart}}{\gre@evaluatenextsyllable{\gre@nextmiddlesyllablepart}}{\gre@evaluatenextsyllable{\gre@nextendsyllablepart}}{#7}%
\gre@calculate@enddifference{\wd\gre@box@syllablenotes}{\wd\gre@box@syllabletext}{\gre@dimen@textaligncenter}{\gre@dimen@notesaligncenter}{0}%
\gre@calculate@syllablefinalskip{#4}{\gre@count@temp@one}%
\else %
Expand Down Expand Up @@ -986,7 +1001,7 @@
\GreNoBreak %
\fi%
% we call end of syllable
\gre@syllable@end{#7}{\gre@nextfirstsyllablepart\gre@nextmiddlesyllablepart\gre@nextendsyllablepart}{#4}%
\gre@syllable@end{#7}{\gre@evaluatenextsyllable{\gre@nextfirstsyllablepart\gre@nextmiddlesyllablepart\gre@nextendsyllablepart}}{#4}%
\gre@push@endsyllable{#6}\relax %
\global\gre@dimen@notesaligncenter=0pt\relax% very important, see flat and natural
\gre@unsetfixedtextformat %
Expand Down Expand Up @@ -1168,7 +1183,7 @@
\gre@dimen@begindifference=\dimexpr(\gre@dimen@notesaligncenter - \gre@dimen@textaligncenter)\relax%
\gre@calculate@enddifference{\wd\gre@box@syllablenotes}{\wd\gre@box@syllabletext}{\gre@dimen@textaligncenter}{\gre@dimen@notesaligncenter}{1}%
#5%
\gre@calculate@nextbegindifference{\gre@emit@endsyllablepartfornextsyllable}{\gre@nextfirstsyllablepart}{\gre@nextmiddlesyllablepart}{\gre@nextendsyllablepart}{#7}%
\gre@calculate@nextbegindifference{\gre@emit@endsyllablepartfornextsyllable}{\gre@evaluatenextsyllable{\gre@nextfirstsyllablepart}}{\gre@evaluatenextsyllable{\gre@nextmiddlesyllablepart}}{\gre@evaluatenextsyllable{\gre@nextendsyllablepart}}{#7}%
\gre@unsetfixednexttextformat %
\gre@debugmsg{barspacing}{previousenddifference: \the\gre@dimen@previousenddifference}%
\gre@debugmsg{barspacing}{begindifference: \the\gre@dimen@begindifference}%
Expand Down