Skip to content

Commit

Permalink
Used tex_write_text for printing nabc to fix character handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
henryso committed Mar 5, 2016
1 parent d2243e6 commit 9ddd20f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<eu>` 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.
Expand Down
34 changes: 23 additions & 11 deletions src/gregoriotex/gregoriotex-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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");
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions tex/gregoriotex-nabc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

-- GREGORIO_VERSION 4.1.0

local catcode_at_letter = luatexbase.catcodetables['gre@atletter']

local gregallaliases = {
["ci~"] = "cl>",
["pe~"] = "ta>",
Expand Down Expand Up @@ -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
22 changes: 10 additions & 12 deletions tex/gregoriotex-nabc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}}%
Expand Down

0 comments on commit 9ddd20f

Please sign in to comment.