From 5ee2820646bde78899018d0bfc3e10e1ce347ff6 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Thu, 25 Feb 2016 22:36:44 +0000 Subject: gregorio 4.1.0-rc2 git-svn-id: svn://tug.org/texlive/trunk@39858 c570f23f-e606-0410-a88d-b1316a301751 --- .../src/gregoriotex/gregoriotex-write.c | 85 +++++++++++++++------- 1 file changed, 57 insertions(+), 28 deletions(-) (limited to 'Build/source/texk/gregorio/gregorio-src/src') diff --git a/Build/source/texk/gregorio/gregorio-src/src/gregoriotex/gregoriotex-write.c b/Build/source/texk/gregorio/gregorio-src/src/gregoriotex/gregoriotex-write.c index 647d1ab8341..041c8806682 100644 --- a/Build/source/texk/gregorio/gregorio-src/src/gregoriotex/gregoriotex-write.c +++ b/Build/source/texk/gregorio/gregorio-src/src/gregoriotex/gregoriotex-write.c @@ -1104,16 +1104,13 @@ static void gregoriotex_write_voice_info(FILE *f, gregorio_voice_info *voice_inf "file or voice_info passed as NULL", return); } -/* this function indicates if the syllable is the last of the line. If it's the - * last of the score it returns false, as it's handled another way */ -static bool gregoriotex_is_last_of_line(gregorio_syllable *syllable) +/* this function indicates if the syllable is the last of the line or score. */ +static bool is_last_of_line(gregorio_syllable *syllable) { gregorio_element *current_element = NULL; - if (!(syllable->next_syllable)) { - return false; - } - if ((syllable->next_syllable->elements)[0] - && (syllable->next_syllable->elements)[0]->type == GRE_END_OF_LINE) { + if (!(syllable->next_syllable) || ((syllable->next_syllable->elements)[0] + && (syllable->next_syllable->elements)[0]->type + == GRE_END_OF_LINE)) { /* the next syllable start by an end of line */ return true; } @@ -1135,6 +1132,21 @@ static bool gregoriotex_is_last_of_line(gregorio_syllable *syllable) return false; } +/* determines if there are more GRE_GLYPHs */ +static bool has_more_notes(const gregorio_element *element) { + for (element = element->next; element; element = element->next) { + if (element->type == GRE_ELEMENT) { + const gregorio_glyph *glyph; + for (glyph = element->u.first_glyph; glyph; glyph = glyph->next) { + if (glyph->type == GRE_GLYPH) { + return true; + } + } + } + } + return false; +} + /* * ! @brief Prints the beginning of each text style */ @@ -1556,11 +1568,12 @@ OFFSET_CASE(BarVirgula); OFFSET_CASE(BarDivisioFinalis); static void write_bar(FILE *f, gregorio_bar type, - gregorio_sign signs, bool is_inside_bar, bool has_text) + gregorio_sign signs, bool is_inside_bar, bool has_text, unsigned char first_of_disc) { /* the type number of function vepisemaorrare */ const char *offset_case = BarStandard; - if (is_inside_bar) { + /* don't use "In" version of bars in the first argument of a GreDiscretionary */ + if (is_inside_bar && first_of_disc != 1) { fprintf(f, "\\GreIn"); } else { fprintf(f, "\\Gre"); @@ -2384,8 +2397,14 @@ static int gregoriotex_syllable_first_type(gregorio_syllable *syllable) result = 10; break; case B_DIVISIO_MINIMA: + result = 11; + break; case B_DIVISIO_MINOR: + result = 12; + break; case B_DIVISIO_MAIOR: + result = 13; + break; case B_DIVISIO_MINOR_D1: case B_DIVISIO_MINOR_D2: case B_DIVISIO_MINOR_D3: @@ -2394,10 +2413,10 @@ static int gregoriotex_syllable_first_type(gregorio_syllable *syllable) case B_DIVISIO_MINOR_D6: case B_DIVISIO_MINOR_D7: case B_DIVISIO_MINOR_D8: - result = 11; + result = 14; break; case B_DIVISIO_FINALIS: - result = 12; + result = 15; break; default: /* not reachable unless there's a programming error */ @@ -2473,7 +2492,7 @@ static int gregoriotex_syllable_first_type(gregorio_syllable *syllable) } /* the only thing that should reach this point is an empty next syllable * we treat that kind of syllable as a bar */ - return 13; + return 16; } static __inline void write_low_choral_sign(FILE *const f, @@ -3099,7 +3118,7 @@ static void gregoriotex_print_change_line_clef(FILE *f, } } -static __inline bool is_manual_custos(const gregorio_element *element) +static __inline bool is_manual_custos(const gregorio_element *const element) { return element->type == GRE_CUSTOS && element->u.misc.pitched.force_pitch; } @@ -3354,6 +3373,7 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable, const char *syllable_type = NULL; bool event_anticipated = false; bool end_of_word; + bool end_of_line; gregorio_not_null(syllable, write_syllable, return); end_of_word = syllable->position == WORD_END || syllable->position == WORD_ONE_SYLLABLE || !syllable->text @@ -3438,12 +3458,16 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable, * bar syllable */ syllable_type = "\\GreBarSyllable"; } else { - syllable_type = "\\GreSyllable"; + if (first_of_disc == 1) { + syllable_type = "\\GreBarSyllable"; + } else { + syllable_type = "\\GreSyllable"; + } } } else { write_fixed_text_styles(f, syllable->text, syllable->next_syllable? syllable->next_syllable->text : NULL); - syllable_type = "\\GreBarSyllable"; + syllable_type = "\\GreNoNoteSyllable"; } write_this_syllable_text(f, syllable_type, syllable->text, end_of_word); fprintf(f, "{}{\\Gre%s}", syllable->first_word ? "FirstWord" : "Unstyled"); @@ -3452,17 +3476,25 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable, } else { fprintf(f, "{0}"); } + end_of_line = is_last_of_line(syllable); if (syllable->next_syllable) { fprintf(f, "{\\GreSetNextSyllable"); write_text(f, syllable->next_syllable->text); + if (end_of_line) { + fprintf(f, "\\GreLastOfLine"); + } fprintf(f, "}{"); write_syllable_point_and_click(f, syllable, status); fprintf(f, "}{%d}{", gregoriotex_syllable_first_type(syllable->next_syllable)); } else { - fprintf(f, "{\\GreSetNextSyllable{}{}{}{}{}}{"); + fprintf(f, "{\\GreSetNextSyllable{}{}{}{}{}"); + if (end_of_line) { + fprintf(f, "\\GreLastOfLine"); + } + fprintf(f, "}{"); write_syllable_point_and_click(f, syllable, status); - fprintf(f, "}{0}{"); + fprintf(f, "}{16}{"); } if (syllable->translation) { if (syllable->translation_type == TR_WITH_CENTER_BEGINNING) { @@ -3481,17 +3513,10 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable, fprintf(f, "%%\n\\GreSetTextAboveLines{%s}%%\n", syllable->abovelinestext); } - if (gregoriotex_is_last_of_line(syllable)) { - fprintf(f, "%%\n\\GreLastOfLine %%\n"); - } - if (!syllable->next_syllable) { - fprintf(f, "%%\n\\GreLastOfScore %%\n"); - } fprintf(f, "}{%%\n"); if (syllable->elements) { - for (element = *syllable->elements; element; - element = element->next) { + for (element = *syllable->elements; element; element = element->next) { if (element->nabc_lines && element->nabc) { size_t i; for (i = 0; i < element->nabc_lines; i++) { @@ -3501,6 +3526,9 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable, } } } + if (!syllable->next_syllable && !has_more_notes(element)) { + fprintf(f, "\\GreLastOfScore"); + } switch (element->type) { case GRE_SPACE: switch (element->u.misc.unpitched.info.space) { @@ -3601,8 +3629,9 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable, case GRE_BAR: write_bar(f, element->u.misc.unpitched.info.bar, element->u.misc.unpitched.special_sign, - element->next && !is_manual_custos(element->next), - !element->previous && syllable->text); + element->next && !is_manual_custos(element->next) + && element->next->type != GRE_END_OF_LINE, + !element->previous && syllable->text, first_of_disc); break; case GRE_END_OF_LINE: -- cgit v1.2.3