lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Explanation of ly:lyric-hyphen::set-spacing-rods


From: Basil Crow
Subject: Explanation of ly:lyric-hyphen::set-spacing-rods
Date: Thu, 28 Dec 2023 10:17:01 -0800

At a high level, how does ly:lyric-hyphen::set-spacing-rods work? I
understand that it inserts invisible objects to prevent lyric words
from being spaced too closely. How does it define the box widths and
stretchability/shrinkability of the springs in order to support
properties like LyricSpace.minimum-distance?

Context: I am implementing Knuth-Plass line-breaking in Neanes [1], a
GPL scorewriter for notating Byzantine chant in Byzantine neume
notation. Byzantine neumes indicate relative pitches rather than
absolute pitches, so there is almost no chance that Lilypond could
ever support Byzantine neume notation. In other words, there is almost
no chance that Neanes could ever compete with Lilypond. Rather, I am
trying to copy Lilypond's high-level solution to this problem.

After implementing basic Knuth-Plass line breaking for Byzantine
neumes in Neanes, I now need to tackle the problem of increasing
horizontal spacing for neumes with lyrics that are longer than the
neume. Naturally, I looked to Lilypond for inspiration, since it uses
a rod-spring model based on Knuth-Plass' box-glue algebra. I was
delighted to find the "Placing syllables horizontally" section in the
documentation [2], which has three examples that perfectly illustrate
what I am trying to achieve. So how does LilyPond achieve this?

I started digging through the code and found that there are LyricSpace
and LyricHyphen grobs, both of which call
ly:lyric-hyphen::set-spacing-rods to create "an invisible object that
prevents lyric words from being spaced too closely." This is precisely
what I expected. And when stepping through the first example from the
"Placing syllables horizontally" section of the documentation in GDB,
I found that this function was called 8 times: once for each note, as
expected.

What I don't yet understand is how the width of this invisible rod is
calculated, or how it interacts with springs to achieve the desired
spacing. My goal is to understand how the rods/springs are modeled so
that I can model them in a similar way in Neanes.

Any help understanding the code would be greatly appreciated. Even if
I could just get LilyPond to dump information about the rods and
springs before passing the problem to the line-breaking algorithm,
this would be helpful in itself.

[1] https://github.com/danielgarthur/neanes
[2] 
https://lilypond.org/doc/v2.23/Documentation/notation/techniques-specific-to-lyrics#placing-syllables-horizontally



reply via email to

[Prev in Thread] Current Thread [Next in Thread]