From 9ddd20f69d3631a2fb400d3e1e8c2d3d3fbbc161 Mon Sep 17 00:00:00 2001 From: "Henry So, Jr." Date: Sat, 5 Mar 2016 15:44:32 -0500 Subject: [PATCH] Used tex_write_text for printing nabc to fix character handling. Fixes #1015. --- CHANGELOG.md | 1 + src/gregoriotex/gregoriotex-write.c | 34 +++++++++++++++++++---------- tex/gregoriotex-nabc.lua | 7 ++++++ tex/gregoriotex-nabc.tex | 22 +++++++++---------- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff37615e6..cbd11ec53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/). - Corrected the end-of-line shift for a ragged line break before `` blocks (see [#988](https://github.com/gregorio-project/gregorio/issues/988)). - Additional space is now added on top of lines with very high notes or signs (see [#883](https://github.com/gregorio-project/gregorio/issues/883)). - High notes are now taken into account for vertical placement of above lines test (see [#960](https://github.com/gregorio-project/gregorio/issues/960)). +- Deminutus figures in nabc work again (see [#1015](https://github.com/gregorio-project/gregorio/issues/1015)). ### Added - The macro `\grechangecount` now allows to change some numeric values of the configuration. This version introduces two of them: `additionaltopspacethreshold` and `additionaltopspacealtthreshold`, see GregorioRef for details. diff --git a/src/gregoriotex/gregoriotex-write.c b/src/gregoriotex/gregoriotex-write.c index adcc24c70..bfa34171c 100644 --- a/src/gregoriotex/gregoriotex-write.c +++ b/src/gregoriotex/gregoriotex-write.c @@ -2534,20 +2534,31 @@ static int gregoriotex_syllable_first_type(gregorio_syllable *syllable) static __inline void write_low_choral_sign(FILE *const f, const gregorio_note *const note, int special) { - fprintf(f, "\\GreLowChoralSign{%d}{%s%s%s}{%d}%%\n", - pitch_value(note->u.note.pitch), - note->choral_sign_is_nabc? "\\GreNABCChar{" : "", - note->choral_sign, note->choral_sign_is_nabc? "}" : "", special); + if (note->choral_sign_is_nabc) { + fprintf(f, "\\GreLowChoralSign{%d}{\\GreNABCChar{", + pitch_value(note->u.note.pitch)); + tex_escape_text(f, note->choral_sign); + fprintf(f, "}}{%d}%%\n", special); + } else { + fprintf(f, "\\GreLowChoralSign{%d}{%s}{%d}%%\n", + pitch_value(note->u.note.pitch), note->choral_sign, + special); + } } static __inline void write_high_choral_sign(FILE *const f, const gregorio_note *const note, int pitch_offset) { - fprintf(f, "\\GreHighChoralSign{%d}{%s%s%s}{\\GreOCase%s}%%\n", - pitch_value(note->u.note.pitch + pitch_offset), - note->choral_sign_is_nabc? "\\GreNABCChar{" : "", - note->choral_sign, note->choral_sign_is_nabc? "}" : "", - note->gtex_offset_case); + if (note->choral_sign_is_nabc) { + fprintf(f, "\\GreHighChoralSign{%d}{\\GreNABCChar{", + pitch_value(note->u.note.pitch + pitch_offset)); + tex_escape_text(f, note->choral_sign); + fprintf(f, "}}{\\GreOCase%s}%%\n", note->gtex_offset_case); + } else { + fprintf(f, "\\GreHighChoralSign{%d}{%s}{\\GreOCase%s}%%\n", + pitch_value(note->u.note.pitch + pitch_offset), + note->choral_sign, note->gtex_offset_case); + } } static void gregoriotex_write_choral_sign(FILE *f, gregorio_glyph *glyph, @@ -3593,8 +3604,9 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable, size_t i; for (i = 0; i < element->nabc_lines; i++) { if (element->nabc[i]) { - fprintf(f, "\\GreNABCNeumes{%d}{%s}%%\n", (int)(i+1), - element->nabc[i]); + fprintf(f, "\\GreNABCNeumes{%d}{", (int)(i+1)); + tex_escape_text(f, element->nabc[i]); + fprintf(f, "}%%\n"); } } } diff --git a/tex/gregoriotex-nabc.lua b/tex/gregoriotex-nabc.lua index c98be962e..c8865b6bb 100644 --- a/tex/gregoriotex-nabc.lua +++ b/tex/gregoriotex-nabc.lua @@ -22,6 +22,8 @@ -- GREGORIO_VERSION 4.1.0 +local catcode_at_letter = luatexbase.catcodetables['gre@atletter'] + local gregallaliases = { ["ci~"] = "cl>", ["pe~"] = "ta>", @@ -413,6 +415,11 @@ local function init_font(fontname) end end +local function print_nabc(nabc) + tex.sprint(catcode_at_letter, nabc) +end + gregoriotex.parse_nabc = gregallparse_neumes +gregoriotex.print_nabc = print_nabc gregoriotex.init_nabc_font = init_font gregoriotex.nabc_font_tables = gregalltab diff --git a/tex/gregoriotex-nabc.tex b/tex/gregoriotex-nabc.tex index b516a27db..090e31557 100644 --- a/tex/gregoriotex-nabc.tex +++ b/tex/gregoriotex-nabc.tex @@ -37,20 +37,18 @@ \gre@nabcfontloadedtrue% } -\newcommand{\grenabccharno}[3]{{\directlua{ - tex.sprint(gregoriotex.parse_nabc("\luatexluaescapestring{#1}", "\luatexluaescapestring{#2}", \luatexluaescapestring{#3})) +\def\grenabccharno#1#2#3{{\directlua{ + gregoriotex.print_nabc(gregoriotex.parse_nabc("#1", "\luatexluaescapestring{#2}", #3)) }}} -\def\GreNABCChar#1{% - \begingroup % - \catcode`\~=12{}% - \catcode`\@=11{}% - \gre@font@nabc % - \gre@style@nabc % - \grenabccharno{#1}{\gre@nabcfontname}{1}% - \endgre@style@nabc% - \endgroup % -} +\def\GreNABCChar#1{{% + %\catcode`\~=12{}% + %\catcode`\@=11{}% + \gre@font@nabc % + \gre@style@nabc % + \grenabccharno{#1}{\gre@nabcfontname}{1}% + \endgre@style@nabc% +}} \def\GreNABCNeumes#1#2{% \GreSetTextAboveLines{\GreNABCChar{#2}}%