lilypond-user
[Top][All Lists]
Advanced

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

Re: Double-underline markup


From: Thomas Morley
Subject: Re: Double-underline markup
Date: Thu, 17 Oct 2019 10:46:59 +0200

Am Di., 15. Okt. 2019 um 13:19 Uhr schrieb Pierre Perol-Schneider
<address@hidden>:
>
> Hi Urs a,d Aaron,
>
> Simply:
>
> \markup {
>   \underline
>   \override #'(offset . 6)\underline
>   "Lorem ipsum"
>   \override #'(offset . 5)\underline
>   \override #'(offset . 10)\underline
>   "dolor sit amet"
> }
>
> Works too. However, lines length are not equals, even in Aaron's coding.

That's due to how make-line-stencil works.

Why not more generic (extending the built-in \underline):

#(define-markup-command (underline-h layout props arg)
  (markup?)
  #:category font
  #:properties ((thickness 1) (offset 2) (gap 2) (amount 1))

  (let* ((thick (ly:output-def-lookup layout 'line-thickness))
         (underline-thick (* thickness thick))
         (m (interpret-markup layout props arg))
         (stil-x-ext (ly:stencil-extent m X))
         (x1 (car stil-x-ext))
         (x2 (cdr stil-x-ext))
         (y (* thick (- offset)))
         (y-off (* thick (- gap)))
         (lines
           (map
             (lambda (i)
               (let ((y-dist (+ y (* i y-off))))
                 (make-line-stencil underline-thick x1 y-dist x2 y-dist)))
             (iota amount 0 1))))
    (apply ly:stencil-add m lines)))

\markup
  \underline-h "underlined"
\markup
  \override #'(amount . 2)
  \underline-h "underlined"
\markup
  \override #'(amount . 3)
  \underline-h "underlined"
\markup
  \override #'(offset . 4)
  \override #'(amount . 3)
  \underline-h "underlined"
\markup
  \override #'(offset . 4)
  \override #'(amount . 3)
  \override #'(gap . 3)
  \underline-h "underlined"



Cheers,
  Harm



reply via email to

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