Hi all,

When a lyric syllable begins with a typographer’s single quote (e.g., ’cause, 
’ll, etc.), the "ignore-punctuation" hack doesn't work. Any hints on how to fix 
this would be appreciated.

Thanks,
Kieren.

%%%  SNIPPET BEGINS
\version "2.19"

#(define space-set
  (list->char-set
    (string->list "—.?-;,:“”‘’–— */()[]{}|<>!`~&…")))

#(define (width grob text)
  (let* ((X-extent
           (ly:stencil-extent (grob-interpret-markup grob text) X)))
   (if (interval-empty? X-extent)
       0
       (cdr X-extent))))

#(define (center-on-word grob)
  (let* ((text (ly:grob-property-data grob 'text))
         (syllable (markup->string text))
         (word-position
           (if (string-skip syllable space-set)
               (string-skip syllable space-set)
               0))
         (word-end
           (if (string-skip-right syllable space-set)
               (+ (string-skip-right syllable space-set) 1)
               (string-length syllable)))
         (preword (substring syllable 0 word-position))
         (word (substring syllable word-position word-end))
         (preword-width (width grob preword))
         (word-width (width grob (if (string-null? syllable) text word)))
         (note-column (ly:grob-parent grob X))
         (note-column-extent (ly:grob-extent note-column note-column X))
         (note-column-width (interval-length note-column-extent)))

  (-
    (*
      (/ (- note-column-width word-width) 2)
      (1+ (ly:grob-property-data grob 'self-alignment-X)))
    preword-width)))

\layout {
  ragged-right = ##f
  line-width = 3\in
}


\score {
  <<
    \new Staff { c''2 2 }
    \addlyrics { That -- ’ll }
  >>
  \layout {
    \context {
      \Lyrics
      \override LyricText.X-offset = #center-on-word
    }
  }
}
}

\score {
  <<
    \new Staff { c''2 2 }
    \addlyrics { That -- ’ll }
  >>
}
%%%  SNIPPET ENDS
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to