Skip to content

Bar spacing in Lua - #1764

Draft
davidweichiang wants to merge 16 commits into
gregorio-project:developfrom
davidweichiang:lua-bar-spacing
Draft

Bar spacing in Lua#1764
davidweichiang wants to merge 16 commits into
gregorio-project:developfrom
davidweichiang:lua-bar-spacing

Conversation

@davidweichiang

@davidweichiang davidweichiang commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This follow-up to #1720 moves both the old and new bar spacing algorithms to Lua, as well as a few other computations. The result is that much of the redundant information in .gtex files can be eliminated.

Remaining to-do items:

  • Quite a few tests are changed, which I will catalogue once the dust is settled on Syllable spacing in Lua #1720.
  • Mid-score changes in bar spacing settings are not yet respected.

- Replicates bug gregorio-project#959 and gregorio-project#1734.
- Two bars in a row are spaced differently than before.
…able and \GreBarSyllable; this also fixes a very minor bug in syllable_clearing
…SyllableBeforeEUOUAE.

- \GreLastOfLine was previously used to anticipate forced line breaks and clef changes. This is now done in Lua.
- It was also called by \GreLastSyllableBeforeEUOUAE to change the syllable-final skip before an euouae. But the syllable-final skip is always dropped at a line break, so making \GreLastSyllableBeforeEUOUAE into a no-op seems to have no effect; in particular, the test euouae.tex still passes.
@davidweichiang
davidweichiang changed the base branch from develop to ctan July 11, 2026 17:37
@davidweichiang
davidweichiang changed the base branch from ctan to develop July 11, 2026 17:37
@davidweichiang

davidweichiang commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

There are currently 37 tests failing.

Consecutive bar syllables

This is the biggest category. If there are two bar syllables in a row, the first syllable's nextbegindifference did not equal the second syllable's begindifference (issue #1734, case 2).

However, it's not really clear what the right behavior is. A bar syllable depends on both the previous and next syllable, so when there are two bar syllables in a row, what should be done? The intent of the old code seemed to be to initialize both bar syllables so that the bar is aligned above the text, then adjust the first bar syllable, then adjust the second bar syllable. That's what the new code does.

Better in my opinion

  • gabc-output/glyphs/divisio_finalis.gabc
  • gabc-output/glyphs/bars.gabc
  • gabc-output/bar-substitution.gabc
  • tex-output/bugs/fix-1110/fix-1110.tex

Don't know if better or worse

  • gabc-output/glyphs/high-bars-2-lines.gabc
  • gabc-output/glyphs/high-bars-3-lines.gabc
  • gabc-output/glyphs/high-bars.gabc
  • gabc-output/glyphs/high-bars-5-lines.gabc
  • gabc-output/empty-syllables.gabc
  • gabc-output/lines/2-lines.gabc
  • gabc-output/lines/3-lines.gabc
  • gabc-output/lines/5-lines.gabc
  • tex-output/bugs/fix-1205/fix-1205.tex
  • tex-output/bugs/fix-1416/fix'1416.tex

Punctum mora adjustment

In my opinion these are all better.

New code uses actual width of punctum mora and space before it

  • tex-output/bugs/fix-396/fix-396.tex

When punctum mora occurs before a clef change, and there is no break, the old code didn't use correct punctum mora adjustment.

  • gabc-output/bugs/fix-1192.gabc

A syllable that has nabc that extends beyond a punctum mora doesn't need a punctum mora adjustment.

  • gabc-output/FactusEst.gabc: ve-
  • gabc-output/veni.gabc

Bars with no text (added after 9d45861)

When a bar syllable has no text, there's an empty text box whose position sometimes affects spacing before and after the syllable. Now the text box is centered directly under the bar.

In my opinion better:

  • gabc-output/bugs/fix-928-unison-no-break.gabc
  • gabc-output/glyphs/flexus-stroke.gabc

Other features

In my opinion these are all better.

Syllable clearing for bar syllables is more accurate

  • gabc-output/glyphs/clear.gabc

Old code computed eolshift using the width of a custos, even when the custos was disabled or flatted.

  • fix-1146.tex

Old code adjusted for alteration in the next syllable, even if it's on the next line

  • gabc-output/bugs/fix-243.gabc
  • gabc-output/bugs/fix-243-old.gabc

In clef changes, old calculation uses wrong nextbegindifference (issue #1724 case 1 and #1191)

  • gabc-output/flatted-custos-clef-change.gabc: alteration adjustment is not supposed to happen after clef, but previously it did
  • gabc-output/glyphs/clef_change.gabc

Tests that revealed new bugs

Miniscule or no difference, except in debugging marks

  • gabc-output/edge_cases.gabc
  • gabc-output/bugs/fix-1424.gabc
  • tex-output/bar-spacing/last-line.tex
  • tex-output/bar-spacing-old/bar-spacing-old.tex
  • tex-output/hidelyricsnotes/text-only.tex
  • gabc-output/glyphs/punctum-inclinatum-2.gabc
  • tex-output/bar-spacing/lyric-centering.tex (new after commit 9d45861)

Tests that need a closer look

  • fix-845.tex: The new result is clearly worse. My notes say that this is actually an existing bug, but I'm not so sure.
  • tex-output/nabc-skip-alterations/nabc-skip-alterations.tex: I haven't paid very close attention to tests involving NABC, since NABC spacing is in flux. However, these changes are large.
  • tex-output/nabc-skip-alterations/nabc-skip-alterations-two-voices.tex

…nderneath the bar so that it doesn't interfere with the spacing before and after the syllable. Fixes tests fix-845 and breaks fix-928-unison-no-break and flexus-stroke (but for the better).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant