12

I was writing sheet music consisting of melody, chords and lyrics. To my surprise, the lyrics weren't aligned correctly under the notes. The file looked like correct Lilypond source code:

global = {
    \time 3/4
    \partial 4
}

theChords = \chordmode {
    c4 | c2. | a2:m e4 | a2:m d4 | g2
}

melody = \relative c'' {
    g8.( e16) | c4 e g | c2 e8. d16 | c4 e, fis | g2
}

theLyrics = \lyricmode {
    O say can you see, by the dawn's ear -- ly light
}

\score {
    \new ChoirStaff <<
        \new ChordNames {
            \global \theChords
        }
        \new Staff = "Melody" <<
            \new Voice = "Melody" {
                \global \melody
            }
        >>
        \new Lyrics \lyricsto "Melody" {
            \theLyrics
        }
    >>
}

However, it produced the following output:

16

It turns out the Word document I copied the lyrics from contained some non-breaking spaces; these don't stand out in the Lilypond editor* but the compiler doesn't recognize them as word separators. It sees the entirety of "O say can you see" as a single syllable.

When I replaced all non-standard spaces with regular ones, the lyrics were correctly aligned again.

*: or for that matter, most text editors. After posting this question, I realized the Stack Exchange editor (or perhaps my browser) automatically converts them to regular spaces. I've uploaded the file to Google Drive, that seems to preserve them and you can download it here. Trust me, the problem is real, and it cost me quite some time to figure out...

4
  • This is arguably a bug. Since virtually all environments display a NBSP the same as a regular space, the only reasonable system response for lilypond would be to treat them like regular spaces. If you do want a word with a space in it you should quote it for clarity. Mar 15 at 7:33
  • 1
    @KilianFoth yeah, maybe I should file a bug. You can already use a ~ to 'glue' words together.
    – Glorfindel
    Mar 15 at 9:58
  • 2
    It appears that using ~ has a different result: the tilde adds a tie to the words; using quotes to bind them together doesn't. A non-breaking space does exactly what you're telling it to do: that's not a bug. Mar 15 at 12:20
  • You can ‘glue’ words together by enclosing them in double-quotes: "five words in one note" "two words" "one".  (You ma also be able to do so by protecting the spaces with backslashes.)  So there would be no big loss in treating non-breaking spaces like ordinary ones.  — However, many other programs don't, so you could argue that it's more consistent for Lilypond not to either.
    – gidds
    Mar 15 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.