Skip to content

Commit

Permalink
Fixed incorrect suppression of forced hyphens at the end of words.
Browse files Browse the repository at this point in the history
  • Loading branch information
henryso committed Jan 21, 2016
1 parent 8b32523 commit ab86ab7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/).
- Sign positioning on the first note of quadratum figures is now correct (see [#752](https://github.com/gregorio-project/gregorio/issues/752)).
- Interlinear spacing of annotations when font size was smaller than normal. You should now see just the spacing specified by `annotationseparation`.
- Spacing is now correct and ledger lines are now typeset for flats, sharps, and naturals above and below the staff (see [#790](https://github.com/gregorio-project/gregorio/issues/790)).
- Forced hyphens at the end of words are no longer suppressed (see [#804](https://github.com/gregorio-project/gregorio/issues/804)).

### Changed
- Initial handling has been simplified. The initial style should now be specified from TeX by using the `\gresetinitiallines` command, rather than from a gabc header. Big initials and normal initials are now governed by a single `initial` style, meant to be changed between scores as appropriate. See [UPGRADE.md](UPGRADE.md) and GregorioRef for details (for the change request, see [#632](https://github.com/gregorio-project/gregorio/issues/632)). Deprecations for this change are listed in the Deprecation section, below.
Expand Down
3 changes: 3 additions & 0 deletions doc/Command_Index_gregorio.tex
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ \section{Gregorio Controls}
\#6 & distance & The distance to end the line after \#2 from this point if \#3 is \texttt{2}. \\
\end{argtable}

\macroname{\textbackslash GreEmptyFirstSyllableHyphen}{}{gregoriotex-syllable.tex}
Macro that indicates the position of an empty-first-syllable hyphen, should one be desired.

\macroname{\textbackslash GreEndEUOUAE}{\#1}{gregoriotex-main.tex}
Macro to mark the end of a EUOUAE block.

Expand Down
32 changes: 17 additions & 15 deletions src/gregoriotex/gregoriotex-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -3096,17 +3096,18 @@ static __inline void write_syllable_point_and_click(FILE *const f,
}

static void write_syllable_text(FILE *f, const char *const syllable_type,
const gregorio_character *text)
const gregorio_character *text, bool ignored)
{
if (syllable_type != NULL) {
ignored = false; /* to avoid the warning */
fprintf(f, "%s{\\GreSetThisSyllable", syllable_type);
write_text(f, text);
fprintf(f, "}");
}
}

static void write_first_syllable_text(FILE *f, const char *const syllable_type,
const gregorio_character *const text)
const gregorio_character *const text, bool end_of_word)
{
if (syllable_type == NULL || text == NULL) {
fprintf(f, "}{}{\\GreSetNoFirstSyllableText}");
Expand Down Expand Up @@ -3168,10 +3169,10 @@ static void write_first_syllable_text(FILE *f, const char *const syllable_type,
}
}
}
if (t) {
if (t || end_of_word) {
fprintf(f, "{}");
} else {
fprintf(f, "{\\GreForceHyphen}");
fprintf(f, "{\\GreEmptyFirstSyllableHyphen}");
}

fprintf(f, "}");
Expand Down Expand Up @@ -3243,13 +3244,17 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable,
unsigned char first_of_disc, gregoriotex_status *const status,
const gregorio_score *const score,
void (*const write_this_syllable_text)
(FILE *, const char *, const gregorio_character *))
(FILE *, const char *, const gregorio_character *, bool))
{
gregorio_element *clef_change_element = NULL, *element;
const char *syllable_type = NULL;
bool event_anticipated = false;
bool end_of_word = syllable->position == WORD_END
|| syllable->position == WORD_ONE_SYLLABLE || !syllable->text
|| !syllable->next_syllable
|| syllable->next_syllable->type == GRE_END_OF_LINE;
if (!syllable) {
write_this_syllable_text(f, NULL, NULL);
write_this_syllable_text(f, NULL, NULL, end_of_word);
return;
}
/* Very first: before anything, if the syllable is the beginning of a
Expand All @@ -3273,7 +3278,7 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable,
} else {
fprintf(f, "%%\n%%\n\\GreNewLine %%\n%%\n%%\n");
}
write_this_syllable_text(f, NULL, syllable->text);
write_this_syllable_text(f, NULL, syllable->text, end_of_word);
return;
}
/*
Expand All @@ -3296,7 +3301,7 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable,
write_syllable(f, syllable, 2, status, score,
write_syllable_text);
fprintf(f, "}%%\n");
write_this_syllable_text(f, NULL, syllable->text);
write_this_syllable_text(f, NULL, syllable->text, end_of_word);
return;
}
}
Expand All @@ -3307,14 +3312,14 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable,
&& (syllable->elements)[0]->u.misc.unpitched.info.bar ==
B_DIVISIO_FINALIS) {
handle_final_bar(f, "DivisioFinalis", syllable);
write_this_syllable_text(f, NULL, syllable->text);
write_this_syllable_text(f, NULL, syllable->text, end_of_word);
return;
}
if (!syllable->next_syllable && !syllable->text
&& (syllable->elements)[0]->u.misc.unpitched.info.bar ==
B_DIVISIO_MAIOR) {
handle_final_bar(f, "DivisioMaior", syllable);
write_this_syllable_text(f, NULL, syllable->text);
write_this_syllable_text(f, NULL, syllable->text, end_of_word);
return;
} else {
syllable_type = "\\GreBarSyllable";
Expand All @@ -3327,12 +3332,9 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable,
syllable->next_syllable? syllable->next_syllable->text : NULL);
syllable_type = "\\GreSyllable";
}
write_this_syllable_text(f, syllable_type, syllable->text);
write_this_syllable_text(f, syllable_type, syllable->text, end_of_word);
fprintf(f, "{}{\\Gre%s}", syllable->first_word ? "FirstWord" : "Unstyled");
if (syllable->position == WORD_END
|| syllable->position == WORD_ONE_SYLLABLE || !syllable->text
|| !syllable->next_syllable
|| syllable->next_syllable->type == GRE_END_OF_LINE) {
if (end_of_word) {
fprintf(f, "{1}");
} else {
fprintf(f, "{0}");
Expand Down
38 changes: 19 additions & 19 deletions tex/gregoriotex-syllable.tex
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@

\newif\ifgre@showhyphenafterthissyllable%
\def\GreForceHyphen{\global\gre@showhyphenafterthissyllabletrue\gre@debugmsg{hyphen}{Forcing hyphen in gabc}}
\def\GreEmptyFirstSyllableHyphen{\ifgre@forceemptyfirstsyllablehyphen\GreForceHyphen\fi}%

%% general macro : it will typeset the syllable : arguments are :
% #1 : macro setting the letters of this syllable
Expand All @@ -546,15 +547,12 @@
\gre@debugmsg{general}{}%
\gre@debugmsg{general}{New syllable: \expandafter\unexpanded{#1}}%
\gre@debugmsg{general}{}%
\ifgre@forcehyphen%
\gre@showhyphenafterthissyllablefalse%
\ifcase#4\ifgre@forcehyphen%
\gre@debugmsg{hyphen}{Forcing hyphen}%
\gre@showhyphenafterthissyllabletrue%
\else%
\gre@debugmsg{hyphen}{not forcing hyphen}%
\gre@showhyphenafterthissyllablefalse%
\fi%
\fi\fi%
#1%
\ifgre@forceemptyfirstsyllablehyphen\else\gre@showhyphenafterthissyllablefalse\gre@debugmsg{hyphen}{Getting rid of hyphen}\fi%
\gre@firstglyphtrue%
\gre@dimen@bolextra = 0pt\relax%
\gre@calculate@textaligncenter{\gre@firstsyllablepart}{\gre@middlesyllablepart}{0}% we first get the width between the alignment point and the end of the syllable
Expand Down Expand Up @@ -639,24 +637,26 @@
\gre@debugmsg{hyphen}{spacing requires hyphen}%
\gre@showhyphenafterthissyllabletrue%
\fi %
\ifgre@showhyphenafterthissyllable\relax%
\gre@debugmsg{hyphen}{Showing the hyphen}%
% if it's the last syllable of line, the hyphen will be \GreHyph
\ifnum\gre@lastoflinecount=1\relax %
\setbox\gre@box@syllabletext=\hbox{\gre@fixedtextformat{\gre@pointandclick{\gre@firstsyllablepart\gre@middlesyllablepart\gre@endsyllablepart#3{\GreHyph}\relax}{#6}}}%
\else %
\setbox\gre@box@syllabletext=\hbox{\gre@fixedtextformat{\gre@pointandclick{\gre@firstsyllablepart\gre@middlesyllablepart\gre@endsyllablepart#3{-}}{#6}}}%
\fi %
% recomputing end difference and final skip with the final hyphen
\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}%
\fi% ficase#4
\ifgre@showhyphenafterthissyllable\relax%
\gre@debugmsg{hyphen}{Showing the hyphen}%
% if it's the last syllable of line, the hyphen will be \GreHyph
\ifnum\gre@lastoflinecount=1\relax %
\setbox\gre@box@syllabletext=\hbox{\gre@fixedtextformat{\gre@pointandclick{\gre@firstsyllablepart\gre@middlesyllablepart\gre@endsyllablepart#3{\GreHyph}\relax}{#6}}}%
\else %
\setbox\gre@box@syllabletext=\hbox{\gre@fixedtextformat{\gre@pointandclick{\gre@firstsyllablepart\gre@middlesyllablepart\gre@endsyllablepart#3{-}}{#6}}}%
\fi %
% recomputing end difference and final skip with the final hyphen
\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 %
\ifcase#4 %
\gre@debugmsg{hyphen}{No hyphen}%
\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}}}%
\fi%
\fi% ficase#4
\fi %
\fi%
% then we reuse temp, we assign to it the \gre@dimen@begindifference, but only if it is positive, else it is 0
\gre@debugmsg{ifdim}{ begindifference > 0pt}%
\ifdim\gre@dimen@begindifference > 0 pt\relax%
Expand Down

0 comments on commit ab86ab7

Please sign in to comment.