Syllable spacing in Lua#1720
Conversation
…erently from the old one, in the following ways: + The old algorithm worked by moving the last part of a syllable to the first part of the next syllable. It could therefore break ligatures between the middle and last part of a syllable. The new algorithm works by joining the text boxes together; it does not break ligatures. + If maximumspacewithoutdash > 0, the old algorithm could make the last part of a syllable "jump" across the space between syllables; the new one only rewrites syllables if they are actually touching. - The old algorithm computed syllable spacing after rewriting; the new algorithm computes them in the opposite order. This means that some syllable spacing will be slightly too big or small. This will be fixable when syllable spacing is also moved to Lua.
…calculated in TeX for now, because it's needed in a couple of places, but \GreSyllable only generates a zero-width \hskip, and the Lua code recalculates it and resizes the \hskip accordingly. The Lua syllablefinalskip calculation uses the actual begindifference of the next syllable, not the predicted one (nextbegindifference). In the old code, sometimes this prediction was wrong (gregorio-project#1723). Therefore this commit breaks several tests, but I believe they are all actually bug fixes.
|
Commit 4fa508d starts to move the calculation of Because it uses the actual Because of #1723: Because of #1724: Only miniscule changes: |
- Move syllable clearing for \GreSyllables into Lua, which works by directly measuring the distances between syllables. This fixes issue gregorio-project#1725 but also breaks tests/gabc-output/glyphs/clear.gabc because it now inserts no extra space (and never removes space). - Simplify syllable spacing by directly measuring distances between syllables, similarly to above.
|
Commit ec4e22c moves syllable clearing into Lua. The amount to shift a syllable in order to clear it is now measured exactly, whereas previously it depended on predicting the begindifference of the next syllable, as well as issue #1725. So cleared syllables are tighter than before. Breaks two new tests: |
…en a syllable and the next, a hyphen is inserted. This used to be done in \GreSyllable, but now is done in the Lua pre_linebreak filter. - Added some missing cases to \gre@calculate@eolshift - Remove TeX code computing syllablefinalskip and code that depends on it * It is still used inside the new bar spacing algorithm, but for a different purpose * There is still a macro \gre@calculate@syllablefinalskip, but it actually computes minNotesDistance and minTextDistance - Intra-line and end-of-line hyphens are now generated by the same code * One very minor side effect is that end-of-line hyphens should now be correctly kerned.
|
Commit a48c861 moves hyphenation into Lua. This was the last thing that depended on syllablefinalskip, so syllablefinalskip can be deleted from the TeX code, and perhaps it would make sense to merge (so that @lbssousa can work on #1715), after 6.2.0 of course. Some very minor benefits:
Several more tests are broken. If a hyphenated word comes before a bar, the space between them is now incorrect until bar spacing is moved into Lua. This happens in the following tests:
Miniscule differences:
More than miniscule but not worrisome in my opinion:
|
|
This code defers some computations to the pre-linebreak filter, which can depend on user settings. If the user changes settings in the middle of the score (using |
|
I'd definitely like to see some documentation on the new Lua code before merging. We've been very poor about documenting our Lua code thus far and I'd like to start changing that. I'm thinking that our policy for new Lua code should be as follows: Every new function (or non-trivial change to an existing function) gets a documentation comment in EmmyLua-style: Do you think that's reasonable? The goal is to improve our Lua documentation over time without there being an overwhelming amount of work. (Though if someone gets ambitious and wants to document all current Lua functions, I won't stop them. That's how I really got into the project: creating the TeX documentation.) |
|
The code documentation suggestion seems good. I started a discussion on the gregorio-devel mailing list in an attempt to standardize our lua style. |
|
The last commit takes a first stab at adding the Lua comments. |
|
To fix:
|
- Handle discretionaries (which disrupt syllable numbering) more correctly
rpspringuel
left a comment
There was a problem hiding this comment.
The addition of the Lua comments makes it much easier to read through the new Lua file. Thank you.
Still need CHANGELOG entry. Based on what I saw, I don't think any UPGRADE entry is needed.
|
I believe merging #1743 first will make this one easier, as it will fix a few failing tests. |
|
To fix:
|
…ng/ligaturing after syllable rewriting. This fixes the problem. When two syllables are merged, the link for the first syllable spans both syllables, and the original link for the second syllable is lost.
|
The last outstanding issue with this is that there are several settings that are read at pre-linebreak time. If the user changes any of these mid-score, the change will affect the entire score, which is probably not what they want. Currently, I believe it's just:
I think it will be better to save these settings per-syllable. Should it just save all of them, or are there any settings that are inconceivable that anyone would want to change them mid-score? |
|
I would normally have said all those were score-wide settings, but as I think about it, I can conceive of situations where someone might want to change them mid-score, at least for a few syllables. My question now is whether we should try to implement this as a defaults-exceptions scheme (where the changes inside a score create exceptions for some number of syllables, up to the rest of the score, but leave the original settings intact), or simply allow the user to change the settings mid-score and rely on them to change things back for the next score if that is what they want> |
…ole syllable is bold or italic, the hyphen is too. This is the same behavior as the old code for intra-line syllables. But it is different from the old code for end-of-line syllables; the old code matched the hyphen's font to the last character's.
|
It looks like mid-score changes persist to the next score, so I think that should stay the same. It also looks like:
|
|
The above commit was the last thing I wanted to fix, so I think this could be really ready now. |
… algorithm)" This reverts commit 4ac81fc, which was incorrect. The problem is that when a hyphen is inserted, it does not move the end-of-syllable boundary. This is fine because adjust_syllablefinalskip does this already. However, if the next syllable is a bar syllable and the old bar spacing algorithm is used, there is no syllablefinalskip to adjust. The result is that the hyphen could protrude too far. This can be fixed correctly, but causes other problems. It seems better to defer this to a proper fix of issue gregorio-project#1755.

This is aiming towards #1673, but pursuing a different strategy than what was proposed there.
The first commit (02ec952) moves syllable rewriting into Lua, which has the following benefits:
ETA: These two cases are demonstrated in gregorio-project/gregorio-test#420.
And there are still the following problems:
The first problem can be seen in the test
tex-output/syllable-rewriting/syllable-rewriting.tex
ETA: The existing code was already making an approximation, in that it was aligning the first note and vowel without taking ligaturing and kerning into account. The new code is just extending this approximation to possibly a whole word. In my opinion, the approximation is visible only in the test
syllable-rewriting.tex(because of the unusual font) and causes only a miniscule difference elsewhere.Further tests that have miniscule differences:
gabc-output/glyphs/torculus_resupinus_quilisma.gabc
gabc-output/glyphs/torculus_resupinus.gabc
gabc-output/slurs.gabc
gabc-output/FactusEst.gabc
tex-output/dominican-flats/dominican-flats.tex
tex-output/SalveReginaOP/SalveReginaOP.tex
tex-output/bugs/fix-595/fix-595.tex
tex-output/bugs/fix-1110/fix-1110.tex
tex-output/lyric-centering/lyric-centering.tex
Tests that have big changes:
Closes #1719.