diff --git a/CHANGELOG.md b/CHANGELOG.md index dcfd9b31..54348840 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/). - Fixed a bug that caused a custos to sometimes change into a clef. See [#1373](https://github.com/gregorio-project/gregorio/issues/1373). - Fixed the alignment of 2-line initials so that an initial's baseline more exactly aligns with the baseline of the lowest line it appears next to. - When fancyhdr and GregorioTeX are used together, GregorioTeX's disabling of hyphenation and its `post_linebreak` modification of the `post_linebreak_filter` interfere with multiline headers. Using the `fancyhdr/before` and `fancyhdr/after` hooks we temporarily reenable hyphenation and disable our `post_linebreak` modification while headers and footers are being processed in the middle of a score. See [#1603](https://github.com/gregorio-project/gregorio/issues/1603). +- Fixed a bug that could cause a hyphen to appear on the wrong line. See [#1319](https://github.com/gregorio-project/gregorio/issues/1319). +- Fixed the placement of above-lines text (``) relative to a note above the staff or when the number of staff lines is not 4. See [#1613](https://github.com/gregorio-project/gregorio/issues/1613) and [#1614](https://github.com/gregorio-project/gregorio/issues/1614). +- Fixed a bug where the above-lines text (``) could collid with a note above the staff. See [#1613](https://github.com/gregorio-project/gregorio/issues/1613). +- Fixed a bug that could cause the clef and staff to be printed too high. See [#1503](https://github.com/gregorio-project/gregorio/issues/1503). ### Changed - Modified gregorio to append to the log file specified as an argument and to send early messages to it. See [#1541](https://github.com/gregorio-project/gregorio/issues/1541). diff --git a/doc/Command_Index_internal.tex b/doc/Command_Index_internal.tex index 8016c016..af4af49f 100644 --- a/doc/Command_Index_internal.tex +++ b/doc/Command_Index_internal.tex @@ -1294,9 +1294,6 @@ \section{Gregorio\TeX{} Controls} \#1 & integer & The number of staff lines\\ \end{argtable} -\macroname{\textbackslash gre@stafflines}{}{gregoriotex-main.tex} -Contains the number of staff lines. - \macroname{\textbackslash gre@romannumeral@majuscule}{\#1}{gregoriotex-main.tex} Typesets its numeric argument as an upper-case Roman numeral. @@ -1912,15 +1909,6 @@ \subsection{Flags} \macroname{\textbackslash ifgre@scale@stafflinefactor}{}{gregoriotex-spaces.tex} Boolean indicating whether the stafflinefactor should scale with changes of \texttt{grefactor}, or not. -\macroname{\textbackslash ifgre@haslinethree}{}{gregoriotex-spaces.tex} -Boolean indicating whether the staff has a third line. - -\macroname{\textbackslash ifgre@haslinefour}{}{gregoriotex-spaces.tex} -Boolean indicating whether the staff has a fourth line. - -\macroname{\textbackslash ifgre@haslinefive}{}{gregoriotex-spaces.tex} -Boolean indicating whether the staff has a fifth line. - \macroname{\textbackslash gre@count@shiftaftermora}{}{gregoriotex-signs.tex} Count indicating when the presence of a punctum mora at the end of a syllable should affect the spacing with the next syllable. @@ -2024,6 +2012,9 @@ \subsection{Flags} \macroname{\textbackslash ifgre@noteadditionalspacelinestext}{}{gregoriotex-main.tex} Boolean indicating that the additional space needed between the notes and the lyrics due to really low notes should follow the user setting of noteadditionalspacelinestext (as opposed to being calculated automatically, the default). +\macroname{\textbackslash gre@count@stafflines}{}{gregoriotex-main.tex} +Count containing the number of staff lines. + \macroname{\textbackslash ifgre@alteration@effect@note}{}{gregoriotex-signs.tex} Boolean indicating that soft alterations should last until they apply to a single note (i.e. all soft alterations will be printed). diff --git a/tex/gregoriotex-main.tex b/tex/gregoriotex-main.tex index 98a82b31..79a6103e 100644 --- a/tex/gregoriotex-main.tex +++ b/tex/gregoriotex-main.tex @@ -214,8 +214,7 @@ \let\gre@pitch@underbrace\gre@pitch@b % \let\gre@pitch@overbraceglyph\gre@pitch@g % \let\gre@pitch@bar\gre@pitch@g % -\let\gre@pitch@dummy\gre@pitch@g % -\let\gre@pitch@nominal\gre@pitch@e % +\let\gre@pitch@dummy\gre@pitch@e % not above or below staff, even if 2 lines % factor is the factor with which you open you font (the number after the at). It will decide almost everything (spaces, etc.), so it is particularly important. % it is set to the default value : 17 (the value that makes it look like a standard graduale) @@ -735,8 +734,8 @@ \else% \gre@dimen@temp@five=\gre@dimen@additionaltopspacenabc\relax% \fi% - \gre@dimen@temp@five=\dimexpr(4\gre@dimen@stafflineheight % - + 4\gre@dimen@interstafflinespace % + \gre@dimen@temp@five=\dimexpr(\gre@dimen@staffheight % + + \gre@dimen@interstafflinespace % + \gre@space@dimen@spacebeneathtext % + \gre@dimen@currenttranslationheight % + \gre@space@dimen@spacelinestext % @@ -789,45 +788,17 @@ \vbox attr \gre@attrid@part=2 {% \gre@style@normalstafflines% \vskip\glueexpr(\gre@dimen@additionaltopspace+\gre@space@skip@spaceabovelines+\gre@dimen@currentabovelinestextheight)\relax% - \ifgre@showlines % - \hrule height \gre@dimen@stafflineheight width \gre@dimen@stafflinewidth\relax% - \else % - \vskip\gre@dimen@stafflineheight\relax% - \fi % - \gre@skip@temp@four = \gre@dimen@interstafflinespace\relax% - \kern\gre@skip@temp@four % - \ifgre@showlines % - \hrule height \gre@dimen@stafflineheight width \gre@dimen@stafflinewidth\relax% - \else % - \vskip\gre@dimen@stafflineheight\relax% - \fi % - \ifgre@haslinethree % - \gre@skip@temp@four = \gre@dimen@interstafflinespace\relax% - \kern\gre@skip@temp@four % + \gre@count@temp@one=0\relax + \loop \ifgre@showlines % \hrule height \gre@dimen@stafflineheight width \gre@dimen@stafflinewidth\relax% \else % \vskip\gre@dimen@stafflineheight\relax% \fi % - \fi % - \ifgre@haslinefour % - \gre@skip@temp@four = \gre@dimen@interstafflinespace\relax% - \kern\gre@skip@temp@four % - \ifgre@showlines % - \hrule height \gre@dimen@stafflineheight width \gre@dimen@stafflinewidth\relax% - \else % - \vskip\gre@dimen@stafflineheight\relax% - \fi % - \fi % - \ifgre@haslinefive % - \gre@skip@temp@four = \gre@dimen@interstafflinespace\relax% - \kern\gre@skip@temp@four % - \ifgre@showlines % - \hrule height \gre@dimen@stafflineheight width \gre@dimen@stafflinewidth\relax% - \else % - \vskip\gre@dimen@stafflineheight\relax% - \fi % - \fi % + \advance\gre@count@temp@one by 1\relax + \ifnum\gre@count@temp@one<\gre@count@stafflines + \kern\gre@dimen@interstafflinespace\relax + \repeat \kern\dimexpr(\gre@space@dimen@spacelinestext+\gre@dimen@additionalbottomspace+\gre@space@dimen@spacebeneathtext+\gre@dimen@currenttranslationheight)\relax% \endgre@style@normalstafflines % }% @@ -1049,13 +1020,11 @@ % gre@attr@dash (see its definition in gregorio-syllable) is 0 when we are in a score, and unset when we are not \newif\ifgre@beginningofscore% -\newif\ifgre@haslinethree% -\newif\ifgre@haslinefour% -\newif\ifgre@haslinefive% +\newcount\gre@count@stafflines \def\gre@setstafflines#1{% \gre@trace{gre@setstafflines{#1}}% - \def\gre@stafflines{#1}% + \gre@count@stafflines=#1\relax \ifcase#1% 0 \gre@error{Invalid number of staff lines}% \or % 1 @@ -1080,9 +1049,6 @@ \let\gre@char@bar@divisiomaior\GreCPDivisioMaiorTwo % \let\gre@char@bar@divisiomaiordotted\GreCPDivisioMaiorDottedTwo % \let\gre@char@bar@divisiomaiordottedbacking\GreCPDivisioMaiorDottedBackingTwo % - \gre@haslinethreefalse % - \gre@haslinefourfalse % - \gre@haslinefivefalse % \or % 3 \let\gre@pitch@adjust@top\gre@pitch@h % \let\gre@pitch@abovestaff\gre@pitch@i % @@ -1103,9 +1069,6 @@ \let\gre@char@bar@divisiomaior\GreCPDivisioMaiorThree % \let\gre@char@bar@divisiomaiordotted\GreCPDivisioMaiorDottedThree % \let\gre@char@bar@divisiomaiordottedbacking\GreCPDivisioMaiorDottedBackingThree % - \gre@haslinethreetrue % - \gre@haslinefourfalse % - \gre@haslinefivefalse % \or % 4 \let\gre@pitch@adjust@top\gre@pitch@j % \let\gre@pitch@abovestaff\gre@pitch@k % @@ -1126,9 +1089,6 @@ \let\gre@char@bar@divisiomaior\GreCPDivisioMaiorFour % \let\gre@char@bar@divisiomaiordotted\GreCPDivisioMaiorDottedFour % \let\gre@char@bar@divisiomaiordottedbacking\GreCPDivisioMaiorDottedBackingFour % - \gre@haslinethreetrue % - \gre@haslinefourtrue % - \gre@haslinefivefalse % \or % 5 \let\gre@pitch@adjust@top\gre@pitch@l % \let\gre@pitch@abovestaff\gre@pitch@m % @@ -1149,9 +1109,6 @@ \let\gre@char@bar@divisiomaior\GreCPDivisioMaiorFive % \let\gre@char@bar@divisiomaiordotted\GreCPDivisioMaiorDottedFive % \let\gre@char@bar@divisiomaiordottedbacking\GreCPDivisioMaiorDottedBackingFive % - \gre@haslinethreetrue % - \gre@haslinefourtrue % - \gre@haslinefivetrue % \else % \gre@error{Invalid number of staff lines}% \fi % diff --git a/tex/gregoriotex-signs.tex b/tex/gregoriotex-signs.tex index d242b4d7..c871d76a 100644 --- a/tex/gregoriotex-signs.tex +++ b/tex/gregoriotex-signs.tex @@ -705,44 +705,44 @@ \or\gre@fontchar@custostoplong % \or\gre@fontchar@custostopshort % \or % - \ifgre@haslinethree % + \ifnum\gre@count@stafflines>2\relax \gre@fontchar@custostoplong % \else % \gre@fontchar@custosbottomlong % \fi % \or % - \ifgre@haslinethree % + \ifnum\gre@count@stafflines>2\relax \gre@fontchar@custostopshort % \else % \gre@fontchar@custosbottomshort % \fi % \or % - \ifgre@haslinefour % + \ifnum\gre@count@stafflines>3\relax \gre@fontchar@custostoplong % \else % \gre@fontchar@custosbottomlong % \fi % \or % - \ifgre@haslinefour % + \ifnum\gre@count@stafflines>3\relax \gre@fontchar@custostopshort % \else % - \ifgre@haslinethree % + \ifnum\gre@count@stafflines>2\relax \gre@fontchar@custosbottomshort % \else % \gre@fontchar@custosbottommiddle % \fi % \fi % \or % - \ifgre@haslinefive % + \ifnum\gre@count@stafflines>4\relax \gre@fontchar@custostoplong % \else % \gre@fontchar@custosbottomlong % \fi % \or % - \ifgre@haslinefive % + \ifnum\gre@count@stafflines>4\relax \gre@fontchar@custostopshort % \else % - \ifgre@haslinefour % + \ifnum\gre@count@stafflines>3\relax \gre@fontchar@custosbottomshort % \else % \gre@fontchar@custosbottommiddle % @@ -750,7 +750,7 @@ \fi % \or\gre@fontchar@custosbottomlong % \or % - \ifgre@haslinefive % + \ifnum\gre@count@stafflines>4\relax \gre@fontchar@custosbottomshort % \else % \gre@fontchar@custosbottommiddle % @@ -1637,8 +1637,8 @@ + \gre@space@dimen@spacebeneathtext % + \gre@space@dimen@spacelinestext % + \gre@dimen@currenttranslationheight % - + \gre@stafflines\gre@dimen@interstafflinespace % - + \gre@stafflines\gre@dimen@stafflineheight)\relax% + + \gre@count@stafflines\gre@dimen@interstafflinespace % + + \gre@count@stafflines\gre@dimen@stafflineheight)\relax% \or % 1 \gre@dimen@glyphraisevalue=% \dimexpr(\gre@dimen@additionalbottomspace % diff --git a/tex/gregoriotex-spaces.tex b/tex/gregoriotex-spaces.tex index 279b8c3e..ee8dfaa6 100644 --- a/tex/gregoriotex-spaces.tex +++ b/tex/gregoriotex-spaces.tex @@ -231,8 +231,8 @@ \def\gre@calculate@staffheight{% \gre@trace{gre@calculate@staffheight}% \global\gre@dimen@staffheight = \dimexpr % - \gre@stafflines\gre@dimen@stafflineheight % - + \gre@stafflines\gre@dimen@interstafflinespace % + \gre@count@stafflines\gre@dimen@stafflineheight % + + \gre@count@stafflines\gre@dimen@interstafflinespace % - \gre@dimen@interstafflinespace\relax% \relax % \gre@trace@end% @@ -733,7 +733,7 @@ \global\gre@isonalinetrue% \or\gre@count@temp@three=\number 8% \or\gre@count@temp@three=\number 9% - \ifgre@haslinethree % + \ifnum\gre@count@stafflines>2\relax \global\gre@isonalinetrue% \else % \ifgre@ledgerline@above % @@ -742,10 +742,10 @@ \fi % \or\gre@count@temp@three=\number 10% \or\gre@count@temp@three=\number 11% - \ifgre@haslinefour % + \ifnum\gre@count@stafflines>3\relax \global\gre@isonalinetrue% \else % - \ifgre@haslinethree % + \ifnum\gre@count@stafflines>2\relax \ifgre@ledgerline@above % \global\gre@isonalinetrue% \fi % @@ -753,10 +753,10 @@ \fi % \or\gre@count@temp@three=\number 12% \or\gre@count@temp@three=\number 13% - \ifgre@haslinefive % + \ifnum\gre@count@stafflines>4\relax \global\gre@isonalinetrue% \else % - \ifgre@haslinefour % + \ifnum\gre@count@stafflines>3\relax \ifgre@ledgerline@above % \global\gre@isonalinetrue% \fi % @@ -764,7 +764,7 @@ \fi % \or\gre@count@temp@three=\number 14% \or\gre@count@temp@three=\number 15% - \ifgre@haslinefive % + \ifnum\gre@count@stafflines>4\relax \ifgre@ledgerline@above % \global\gre@isonalinetrue% \fi % diff --git a/tex/gregoriotex-syllable.tex b/tex/gregoriotex-syllable.tex index a415e1f2..5a251256 100644 --- a/tex/gregoriotex-syllable.tex +++ b/tex/gregoriotex-syllable.tex @@ -154,16 +154,21 @@ % #7 is the line:char:column for a textedit link \def\GreGlyph#1#2#3#4#5#6#7{% \gre@newglyphcommon % + % Create box containing the new glyph. \setbox\gre@box@temp@width=\hbox{\gre@pointandclick{\gre@font@music #1}{#7}}% \global\gre@dimen@lastglyphwidth=\wd\gre@box@temp@width % % the three next lines are a trick to get the additional lines below the glyphs \gre@skip@temp@one = \gre@dimen@lastglyphwidth\relax% \kern\gre@skip@temp@one % + % #5 contains things like ledger lines, but also calls to \GreGlyphHeights #5\relax % \kern-\gre@skip@temp@one % \gre@calculate@glyphraisevalue{#2}{0}{}% \raise\gre@dimen@glyphraisevalue% - \copy\gre@box@temp@width% + % Since \gre@box@temp@width was created before the calls + % to \GreGlyphHeights, we need to rebox it to + % set \gre@attr@glyph@top and \gre@attr@glyph@bottom correctly. + \hbox{\unhcopy\gre@box@temp@width}% \ifgre@endofscore\else\ifgre@boxing\else % #3% \fi\fi % diff --git a/tex/gregoriotex.lua b/tex/gregoriotex.lua index 99e6e8a4..0d67e206 100644 --- a/tex/gregoriotex.lua +++ b/tex/gregoriotex.lua @@ -476,11 +476,10 @@ end local function dump_nodes_helper(head, indent) local dots = string.rep('..', indent) for n in traverse(head) do - local ids = format("%s", has_attribute(n, part_attr)) + local ids = format("%s", has_attribute(n, glyph_id)) if node.type(n.id) == 'penalty' then - log(dots .. "%s=%s {%s}", node.type(n.id), n.penalty, ids) + log(dots .. "%s %s {%s}", node.type(n.id), n.penalty, ids) elseif n.id == whatsit and n.subtype == user_defined_subtype and n.user_id == marker_whatsit_id then - log("marker-whatsit %s", n.value) log(dots .. "marker-whatsit %s", n.value) elseif n.id == glyph then local f = font.fonts[n.font] @@ -490,9 +489,11 @@ local function dump_nodes_helper(head, indent) end log(dots .. "glyph %s {%s}", charname, ids) elseif n.id == rule then - log(dots .. "rule subtype=%s width=%spt height=%spt depth=%spt", n.subtype, n.width/65536, n.height/65536, n.depth/65536) + log(dots .. "rule [%s] width=%.2fpt height=%.2fpt depth=%.2fpt", n.subtype, n.width/2^16, n.height/2^16, n.depth/2^16) + elseif n.id == hlist or n.id ==vlist then + log(dots .. "%s [%s] width=%.2fpt height=%.2fpt depth=%.2fpt shift=%.2fpt {%s}", node.type(n.id), n.subtype, n.width/2^16, n.height/2^16, n.depth/2^16, n.shift/2^16, ids) elseif n.id == glue then - log(dots .. "glue subtype=%s width=%spt", n.subtype, n.width/65536) + log(dots .. "glue [%s] width=%.2fpt", n.subtype, n.width/2^16) else log(dots .. "node %s [%s] {%s}", node.type(n.id), n.subtype, ids) end @@ -720,9 +721,6 @@ end local function post_linebreak(h, groupcode, glyphes) -- TODO: to be changed according to the font local lastseennode = nil - local adddash = false - local currentfont = 0 - local currentshift = 0 local centerstartnode = nil local line_id = nil local line_top = nil @@ -754,6 +752,7 @@ local function post_linebreak(h, groupcode, glyphes) line_bottom = nil line_has_translation = false line_has_abovelinestext = false + for n in traverse_id(hlist, line.head) do syl_id = has_attribute(n, syllable_id_attr) or syl_id if has_attribute(n, center_attr, startcenter) then @@ -764,32 +763,12 @@ local function post_linebreak(h, groupcode, glyphes) else center_translation(centerstartnode, n, line.glue_set, line.glue_sign, line.glue_order) end - elseif has_attribute(n, dash_attr, potentialdashvalue) then - adddash=true - lastseennode=n - currentfont = 0 - -- we traverse the list, to detect the font to use, - -- and also not to add an hyphen if there is already one - for g in node.traverse_id(glyph, n.head) do - if currentfont == 0 then - currentfont = g.font - end - if g.char == hyphen or g.char == 45 then - adddash = false - end - end - if currentshift == 0 then - currentshift = n.shift - end - -- if we encounter a text that doesn't need a dash, we acknowledge it - elseif has_attribute(n, dash_attr, nopotentialdashvalue) then - adddash=false end - + if new_score_heights then local glyph_id = has_attribute(n, glyph_id_attr) - local glyph_top = has_attribute(n, glyph_top_attr) or 9 -- 'g' - local glyph_bottom = has_attribute(n, glyph_bottom_attr) or 9 -- 'g' + local glyph_top = has_attribute(n, glyph_top_attr) or 7 -- 'e' = \gre@pitch@dummy + local glyph_bottom = has_attribute(n, glyph_bottom_attr) or 7 -- 'e' = \gre@pitch@dummy if glyph_id and glyph_id > prev_line_id then if not line_id or glyph_id > line_id then line_id = glyph_id @@ -812,13 +791,7 @@ local function post_linebreak(h, groupcode, glyphes) is_mark(n, abovelinestext_mark) end end - if adddash==true then - local dashnode, hyphnode = getdashnnode() - dashnode.shift = currentshift - hyphnode.font = currentfont - insert_after(line.head, lastseennode, dashnode) - addash=false - end + if line_id then new_score_heights[prev_line_id] = { linenum, line_top, line_bottom, line_has_translation and 1 or 0, @@ -830,8 +803,6 @@ local function post_linebreak(h, groupcode, glyphes) new_score_last_syllables[syl_id] = syl_id end end - -- we reinitialize the shift value, because it may change according to the line - currentshift=0 end end @@ -871,7 +842,43 @@ local function post_linebreak(h, groupcode, glyphes) end end end - + + -- Look for words that are broken across lines and insert a hyphen + for line in traverse_id(hlist, h) do + if has_attribute(line, dash_attr) then + -- Look for the last node that has dash_attr > 0 + local adddash=false + for n in traverse_id(hlist, line.head) do + -- If a syllable is not word-final, it may need a dash if it + -- ends up being line-final. + -- Note: This also loops over translations, but translations + -- come before lyrics, so they should never become lastseennode + if has_attribute(n, dash_attr, potentialdashvalue) then + adddash=true + lastseennode=n + -- if we encounter a text that doesn't need a dash, we acknowledge it + elseif has_attribute(n, dash_attr, nopotentialdashvalue) then + adddash=false + end + end + + -- If the last syllable needed a dash, add it + if adddash then + local lastglyph + -- we traverse the list, to detect the font to use, + -- and also not to add an hyphen if there is already one + for g in node.traverse_id(glyph, lastseennode.head) do + lastglyph = g + end + if not (lastglyph.char == hyphen or lastglyph.char == 45) then + local dashnode, hyphnode = getdashnnode() + hyphnode.font = lastglyph.font + insert_after(lastseennode.head, lastglyph, dashnode) + end + end + end + end + --dump_nodes(h) -- due to special cases, we don't return h here (see comments in bug #20974) return true @@ -1290,6 +1297,7 @@ local function include_score(input_file, force_gabccompile, allow_deprecated) glog_file = string.format("%s%s-%s.glog", output_dir, cleaned_filename, internalversion:gsub("%.", "_")) compile_gabc(gabc_file, gtex_filename, glog_file, allow_deprecated) + gtex_filename = lfs.normalize(gtex_filename) tex.print(string.format([[\input %s\relax]], gtex_filename)) return else @@ -1298,6 +1306,7 @@ local function include_score(input_file, force_gabccompile, allow_deprecated) end end if not gabc_file then + gtex_file = lfs.normalize(gtex_file) tex.print(string.format([[\input %s\relax]], gtex_file)) return end @@ -1320,6 +1329,7 @@ local function include_score(input_file, force_gabccompile, allow_deprecated) elseif force_gabccompile then compile_gabc(gabc_file, gtex_file, glog_file, allow_deprecated) end + gtex_file = lfs.normalize(gtex_file) tex.print(string.format([[\input %s\relax]], gtex_file)) return end @@ -1641,7 +1651,9 @@ local function adjust_line_height(inside_discretionary, for_next_line) if for_next_line then local last = score_heights['last'] if last then - local target_id = tex.getattribute(glyph_id_attr) + 1 + -- Let target_id be the glyph_id of the last glyph on this line. + -- Then heights[target_id] is the information for the next line. + local target_id = tex.getattribute(glyph_id_attr) while target_id <= last do heights = score_heights[target_id] if heights then break end