Skip to content

Commit

Permalink
Implemented a toggle-able forced hyphen for empty initial syllables.
Browse files Browse the repository at this point in the history
  • Loading branch information
henryso committed Oct 23, 2015
1 parent 4044076 commit 6519afa
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/).
- The spacing of manual in-line custos (`(f+)` in gabc) is now consistent with the spacing of automatic in-line custos (`(z0)` in gabc). See [#642](https://github.com/gregorio-project/gregorio/issues/642).
- Signs on the climacus praepunctis deminutus `(ghgf~)` neume are now positioned correctly. See [#650]((https://github.com/gregorio-project/gregorio/issues/650)

### Added
- The ability to force a hyphen after an empty first syllable, enabled by default since this was the behavior prior to 4.0. Version 4.0 has an improved spacing algorithm which will eliminate the hyphen if the notes for the first syllable are too close to the second. To switch to this behavior, use `\gresetemptyfirstsyllablehyphen{auto}`. See [UPGRADE.md](UPGRADE.md) and GregorioRef for details (for the change request, see [#653](https://github.com/gregorio-project/gregorio/issues/653)).


## [4.0.0-rc1] - 2015-10-08
### Fixed
Expand Down
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ In order to better match the new command naming conventions, the third argument

In order to be more consistent, making a bistropha or tristropha liquescent by adding `<` in gabc will now only affect the note thus marked. This means that a tristropha like `(gsss<)` will only show the final stropha as liquescent, which is different from the older behavior of making every stropha liquescent. If you prefer the old behavior, mark every note explicitly as liquescent with something like `(gs<gs<gs<)`.

### Empty first syllable hyphen

Prior to version 4.0, GregorioTeX would put a hyphen below an empty first syllable (which happens when the first syllable consists only of the initial). The spacing algorithm is improved in 4.0, but that eliminates the hyphen if there is not enough space between the note of the first syllable and the next syllable. The `\gresetemptyfirstsyllablehyphen` command controls this behavior. It defaults to `force`, which restores the pre-4.0 behavior, but may be changed to `auto` (i.e., `\gresetemptyfirstsyllablehyphen{auto}`) if you prefer the space-based behavior.

## 3.0
### TeX Live 2013

Expand Down
13 changes: 10 additions & 3 deletions doc/Command_Index_User.tex
Original file line number Diff line number Diff line change
Expand Up @@ -790,16 +790,23 @@ \subsubsection{End of Line Behavior}
\subsubsection{Hyphenation}

\macroname{\textbackslash gresethyphen}{\{\#1\}}{gregoriotex-main.tex}
Tell Gregorio\TeX\ to when to place a hyphen between
syllables in polysyllabic words in a score. This is done by overriding \texttt{maximumspacewithoutdash} so subsequent changes to this dimension will override this command.
Tells Gregorio\TeX\ how to place a hyphen between syllables in polysyllabic words in a score. This is done by overriding \texttt{maximumspacewithoutdash} so subsequent changes to this dimension will override this command.

\begin{argtable}
\#1 & force & Hyphens will appear between all syllables in polysyllabic words.\\
& auto & Hyphens will appear based on the setting of \texttt{maximumspacewithoutdash}
& auto & Hyphens will appear based on the setting of \texttt{maximumspacewithoutdash} (default)
\end{argtable}

\textbf{Nota Bene:} \verb=\gresethyphen{auto}= restores \texttt{maximumspacewithoutdash} to the value found in \textit{gsp-default.tex}. If you have changed your score size, you may need to change this distance to a more appropriate value using \verb=\grechangedim=.

\macroname{\textbackslash gresetemptyfirstsyllablehyphen}{\{\#1\}}{gregoriotex-syllable.tex}
Tells Gregorio\TeX\ how to place a hyphen after an empty first syllable (\ie, when the first syllable consists only of the big initial).

\begin{argtable}
\#1 & force & A hyphen will appear after an empty first syllable. (default)\\
& auto & A hyphen will appear after an empty fiest syllable based on the setting of \texttt{maximumspacewithoutdash}
\end{argtable}

\macroname{\textbackslash greseteolhyphen}{\{\#1\}}{gregoriotex-main.tex}
Marco to determine how much space the hyphen at the end of a line occupies for the purposes of spacing caluclations.

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 @@ -330,6 +330,9 @@ \section{Gregorio Controls}
& 1 & Indicates the flat for a key change.\\
\end{argtable}

\macroname{\textbackslash GreForceHyphen}{}{gregoriotex-syllable.tex}
Macro that indicates that a hyphen should be forced (if enabled) after the given syllable.

\macroname{\textbackslash GreFuseTwo}{\#1\#2}{gregoriotex-main.tex}
Macro for fusing two glyphs to create a larger neume.

Expand Down
4 changes: 4 additions & 0 deletions doc/Command_Index_internal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,11 @@ \subsection{Flags}
\macroname{\textbackslash ifgre@showclef}{}{gregoriotex-main.tex}
Boolean which indicates that the clef should be visible.

\macroname{\textbackslash gre@forceemptyfirstsyllablehyphen}{}{gregoriotex-syllable.tex}
Boolean which indicates that a hyphen after an empty first syllable should be forced.

\macroname{\textbackslash gre@forcehyphen}{}{gregoriotex-syllable.tex}
Boolean which indicates that the hyphen after this syllable should be forced.


\subsection{Boxes}
Expand Down
32 changes: 29 additions & 3 deletions src/gregoriotex/gregoriotex-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -2574,17 +2574,20 @@ static void write_fixed_text_styles(FILE *f, gregorio_character *syllable_text,
static void gregoriotex_write_text(FILE *f, gregorio_character *text,
bool *first_syllable)
{
bool skip_initial = first_syllable && *first_syllable;
if (text == NULL) {
fprintf(f, "{}{}{}{}{}");
if (skip_initial) {
fprintf(f, "\\GreForceHyphen{}");
}
return;
}
fprintf(f, "{");
gregorio_write_text(first_syllable && *first_syllable, text, f,
gregorio_write_text(skip_initial, text, f,
(&gtex_write_verb), (&gtex_print_char), (&gtex_write_begin),
(&gtex_write_end), (&gtex_write_special_char));
fprintf(f, "}{");
gregorio_write_first_letter_alignment_text(
first_syllable && *first_syllable, text, f,
gregorio_write_first_letter_alignment_text(skip_initial, text, f,
(&gtex_write_verb), (&gtex_print_char), (&gtex_write_begin),
(&gtex_write_end), (&gtex_write_special_char));
if (first_syllable) {
Expand All @@ -2593,6 +2596,29 @@ static void gregoriotex_write_text(FILE *f, gregorio_character *text,
gregoriotex_ignore_style = gregoriotex_next_ignore_style;
gregoriotex_next_ignore_style = ST_NO_STYLE;
fprintf(f, "}");
if (skip_initial) {
/* Check to see if we need to force a hyphen (empty first syllable) */
for (; text; text = text->next_character) {
if (text->is_character) {
break;
} else if (text->cos.s.type == ST_T_BEGIN) {
if (text->cos.s.style == ST_VERBATIM ||
text->cos.s.style == ST_SPECIAL_CHAR) {
break;
} else if (text->cos.s.style == ST_INITIAL) {
for (; text; text = text->next_character) {
if (!text->is_character && text->cos.s.type == ST_T_END
&& text->cos.s.style == ST_INITIAL) {
break;
}
}
}
}
}
if (!text) {
fprintf(f, "\\GreForceHyphen{}");
}
}
}

/*
Expand Down
19 changes: 19 additions & 0 deletions tex/gregoriotex-syllable.tex
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,20 @@
\gresetclivisalignment{special}%
}%

\newif\ifgre@forceemptyfirstsyllablehyphen%
\gre@forceemptyfirstsyllablehyphentrue%
\def\gresetemptyfirstsyllablehyphen#1{%
\IfStrEq{#1}{auto}%
{\gre@forceemptyfirstsyllablehyphenfalse}%
{\IfStrEq{#1}{force}%
{\gre@forceemptyfirstsyllablehyphentrue}%
{\gre@error{Unrecognized option for \protect\gresetlyriccentering}}%
}%
}%

\newif\ifgre@forcehyphen%
\def\GreForceHyphen{\gre@forcehyphentrue}

%% general macro : it will typeset the syllable : arguments are :
% #1 : macro setting the letters of this syllable
% #2 : reserved (unused)
Expand All @@ -536,7 +550,9 @@
\gre@debugmsg{general}{}%
\gre@debugmsg{general}{New syllable: \expandafter\unexpanded{#1}}%
\gre@debugmsg{general}{}%
\gre@forcehyphenfalse%
#1%
\ifgre@forceemptyfirstsyllablehyphen\else\gre@forcehyphenfalse\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 @@ -603,6 +619,9 @@
%
\gre@debugmsg{ifdim}{ temp@skip@one > maximumspacewithoutdash}%
\ifdim\gre@skip@temp@one > \gre@dimen@maximumspacewithoutdash\relax%
\gre@forcehyphentrue%
\fi
\ifgre@forcehyphen\relax%
% 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}}}%
Expand Down

0 comments on commit 6519afa

Please sign in to comment.