Skip to content

Commit

Permalink
Merge pull request #1166 from gregorio-project/fix-1138
Browse files Browse the repository at this point in the history
Fix 1138
  • Loading branch information
eroux authored Jun 28, 2016
2 parents 26d1496 + 2e6bcf5 commit 313898e
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/).
- 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)).
- In cases of a syllable without note, the space between notes of the previous and next syllables was sometimes not enough (see [#1137](https://github.com/gregorio-project/gregorio/issues/1137)).

### Changed
- When the clef and the first note are at a reasonable vertical distance, `shortspaceafterlineclef` is used instead of `spaceafterlineclef` (make them equal if you don't want this feature). This is used only on the first line, when there is an initial on one line. See [#1138](https://github.com/gregorio-project/gregorio/issues/1138).

## [4.2.0-rc1] - 2016-05-31
### Fixed
- The `900_gregorio.xml` file for Scribus now matches `main-lualatex.tex` again (see [#1087](https://github.com/gregorio-project/gregorio/issues/1087)).
Expand Down
3 changes: 2 additions & 1 deletion doc/Command_Index_gregorio.tex
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ \section{Gregorio Controls}
\#1 & character & The initial letter of the score.\\
\end{argtable}

\macroname{\textbackslash GreSetInitialClef}{\#1\#2\#3\#4\#5\#6}{gregoriotex-signs.tex}
\macroname{\textbackslash GreSetInitialClef}{\#1\#2\#3\#4\#5\#6\#7}{gregoriotex-signs.tex}
Macro for writing initial clef.

\begin{argtable}
Expand All @@ -865,6 +865,7 @@ \section{Gregorio Controls}
\#4 & \texttt{c} or \texttt{f} & Type of secondary clef.\\
\#5 & \texttt{0}--\texttt{5} & Line of secondary clef (\texttt{0} for no secondary clef).\\
\#6 & integer & Height of flat in secondary clef (\texttt{3} for no flat).\\
\#7 & integer & \texttt{0} if clef and first note are far enough to use a shorter space, 1 otherwise.\\
\end{argtable}

\macroname{\textbackslash GreSetLinesClef}{\#1\#2\#3\#4\#5\#6\#7}{gregoriotex-main.tex}
Expand Down
5 changes: 3 additions & 2 deletions doc/Command_Index_internal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ \section{Gregorio\TeX{} Controls}
\#6 & integer & if \texttt{3}, it means that we must not put a flat after the secondary clef, otherwise it’s the height of the flat\\
\end{argtable}
\macroname{\textbackslash gre@typeclef}{\#1\#2\#3\#4\#5\#6\#7\#8}{gregoriotex-signs.tex}
\macroname{\textbackslash gre@typeclef}{\#1\#2\#3\#4\#5\#6\#7\#8\#9}{gregoriotex-signs.tex}
Macro which typesets the clef.
\begin{argtable}
Expand All @@ -779,7 +779,8 @@ \section{Gregorio\TeX{} Controls}
\#3 & \texttt{0} & no need to use small clef characters (inside a line)\\
& \texttt{1} & we must use small clef characters (inside a line)\\
\#4 & \texttt{0} & no extra space is needed after the clef\\
& \texttt{}1 & we must type a space after the clef\\
& \texttt{1} & we must type a normal space after the clef\\
& \texttt{2} & we must type a short space after the clef\\
\#5 & integer & if \texttt{3}, it means that we must not put a flat after the clef, otherwise it’s the height of the flat\\
\#6 & character & the type of the secondary clef: c or f\\
\#7 & integer & the line of the secondary clef (1 is the lowest, 0 for no secondary clef)\\
Expand Down
49 changes: 47 additions & 2 deletions src/gregoriotex/gregoriotex-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -4028,6 +4028,50 @@ static void suppress_expansion(FILE *const f, const char *text)
}
}

static int first_note_near_clef(const gregorio_score *const score) {
gregorio_clef_info clef = gregorio_default_clef;
if (score->first_voice_info) {
clef = score->first_voice_info->initial_clef;
if (!clef.secondary_line && !clef.flatted && score->first_syllable
&& score->first_syllable->elements) {
const gregorio_element *element = score->first_syllable->elements[0];
if (element && element->type == GRE_ELEMENT) {
const gregorio_glyph *glyph = element->u.first_glyph;
if (glyph && glyph->type == GRE_GLYPH) {
const signed char clef_pitch = LOW_LINE_PITCH
+ ((clef.line - 1) * 2);
const gregorio_note *low_note = glyph->u.notes.first_note;
const gregorio_note *high_note = low_note;
switch (glyph->u.notes.glyph_type) {
case G_PODATUS:
/* next note is above the previous */
if (low_note->next) {
high_note = low_note->next;
}
break;
case G_FLEXA:
case G_PORRECTUS:
case G_PORRECTUS_FLEXUS:
/* there is a stem the size of the ambitus */
if (high_note->next) {
low_note = high_note->next;
}
break;
default:
/* to prevent the enum warning */
break;
}
if (high_note->u.note.pitch < clef_pitch - 3
|| low_note->u.note.pitch > clef_pitch + 3) {
return 0;
}
}
}
}
}
return 1;
}

void gregoriotex_write_score(FILE *const f, gregorio_score *const score,
const char *const point_and_click_filename)
{
Expand Down Expand Up @@ -4118,12 +4162,13 @@ void gregoriotex_write_score(FILE *const f, gregorio_score *const score,
if (score->first_voice_info) {
clef = score->first_voice_info->initial_clef;
}
fprintf(f, "\\GreSetInitialClef{%c}{%d}{%d}{%c}{%d}{%d}%%\n",
fprintf(f, "\\GreSetInitialClef{%c}{%d}{%d}{%c}{%d}{%d}{%d}%%\n",
gregorio_clef_to_char(clef.clef), clef.line,
clef_flat_height(clef.clef, clef.line, clef.flatted),
gregorio_clef_to_char(clef.secondary_clef), clef.secondary_line,
clef_flat_height(clef.secondary_clef, clef.secondary_line,
clef.secondary_flatted));
clef.secondary_flatted),
first_note_near_clef(score));
fprintf(f, "}{%%\n"); /* GreScoreOpening#3 */
current_syllable = score->first_syllable;
if (current_syllable) {
Expand Down
1 change: 1 addition & 0 deletions src/struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ static __inline bool is_fused(char liquescentia)
#define LOWEST_PITCH 3
#define DUMMY_PITCH (LOWEST_PITCH + 6)
#define LOW_LEDGER_LINE_PITCH (LOWEST_PITCH + 1)
#define LOW_LINE_PITCH (LOWEST_PITCH + 3)
#define MAX_PITCH (LOWEST_PITCH + 4 + (2 * 5))

#define NO_PITCH -128
Expand Down
21 changes: 16 additions & 5 deletions tex/gregoriotex-signs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
%% #1: the type of the clef : c or f
%% #2: the line of the clef (1 is the lowest)
%% #3: if we must use small clef characters (inside a line) or not 0: if not inside, 1 if inside
%% #4: if we must type a space after or not
%% #4: 0: no space after, 1: normal space after, 2: short space after
%% #5: if 3, it means that we must not put a flat after the clef, otherwise it's the height of the flat
%% #6: the type of the secondary clef : c or f
%% #7: the line of the secondary clef (1 is the lowest)
Expand Down Expand Up @@ -218,9 +218,12 @@
\global\gre@dimen@clefwidth=\wd\gre@box@temp@width %
\fi %
\copy\gre@box@temp@width %
\gre@skip@temp@two=\gre@space@skip@spaceafterlineclef\relax%
\ifnum#4=0\relax %
\ifcase#4 %
\gre@skip@temp@two=\gre@space@skip@afterclefnospace\relax%
\or %
\gre@skip@temp@two=\gre@space@skip@spaceafterlineclef\relax%
\else %
\gre@skip@temp@two=\gre@space@skip@shortspaceafterlineclef\relax%
\fi %
\gre@hskip\gre@skip@temp@two %
}%
Expand Down Expand Up @@ -269,10 +272,18 @@
% macro that writes the initial key, and sets the next keys to the same value
% if #3 is 3, it means that we must not put a flat after the key, otherwise it's the height
% of the flat
\def\GreSetInitialClef#1#2#3#4#5#6{%
\def\GreSetInitialClef#1#2#3#4#5#6#7{%
\gre@save@clef{#1}{#2}{#3}{#4}{#5}{#6}%
\ifgre@showclef%
\gre@typeclef{#1}{#2}{0}{1}{#3}{#4}{#5}{#6}%
\ifnum\gre@initiallines=1\relax %
\ifnum#7=1\relax %
\gre@typeclef{#1}{#2}{0}{1}{#3}{#4}{#5}{#6}%
\else %
\gre@typeclef{#1}{#2}{0}{2}{#3}{#4}{#5}{#6}%
\fi %
\else %
\gre@typeclef{#1}{#2}{0}{1}{#3}{#4}{#5}{#6}%
\fi %
\else%
\gre@skip@temp@four = \gre@space@dimen@noclefspace\relax%
\hbox{\kern\gre@skip@temp@four}%
Expand Down
3 changes: 3 additions & 0 deletions tex/gregoriotex-spaces.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,9 @@
\ifgre@scale@spaceafterlineclef%
\gre@changeonedimenfactor{spaceafterlineclef}{#1}{#2}%
\fi%
\ifgre@scale@shortspaceafterlineclef%
\gre@changeonedimenfactor{shortspaceafterlineclef}{#1}{#2}%
\fi%
\ifgre@scale@interwordspacenotes%
\gre@changeonedimenfactor{interwordspacenotes}{#1}{#2}%
\fi%
Expand Down
2 changes: 2 additions & 0 deletions tex/gsp-default.tex
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@
\grecreatedim{spaceaftersigns}{0.08203 cm plus 0.0082 cm minus 0.0082 cm}{scalable}%
% space after a clef at the beginning of a line
\grecreatedim{spaceafterlineclef}{0.27345 cm plus 0.14584 cm minus 0.01367 cm}{scalable}%
% space after a clef at the beginning of a line, when the clef and first note are vertically distant
\grecreatedim{shortspaceafterlineclef}{0.2 cm plus 0.2 cm minus 0.01367 cm}{scalable}%
% minimal space between notes of different words
\grecreatedim{interwordspacenotes}{0.27 cm plus 0.15 cm minus 0.05 cm}{scalable}%
% minimal space between notes of the same syllable.
Expand Down

0 comments on commit 313898e

Please sign in to comment.