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: Sun, 20 Oct 2019 20:25:14 +0200

Am So., 20. Okt. 2019 um 12:58 Uhr schrieb David Kastrup <address@hidden>:
>
> Thomas Morley <address@hidden> writes:
>
> > Am Sa., 19. Okt. 2019 um 14:45 Uhr schrieb David Kastrup <address@hidden>:

> >> b) change a property (akin to offset but probably unique to \underline
> >> to avoid unexpected interactions) for the sake of additional
> >> underline calls.  That would result in the _innermost_ \underline call
> >> ending up lowest.

> Basically, the idea was to just call something like
>
>   (interpret-markup layout (prepend-alist-chain 'offset (1+ offset) props) 
> arg)

I thought I tried that unsuccessfully, maybe the incantation was not
exactly correct...

Now it works and I come up with below.
Though, it bugs me that the _innermost_ \underline call ends up lowest
as you wrote and I found no automagic way to do it different.

Any ideas?

Currently this means, if one wants to switch underlines, p.e. for
nested calls of \underline, one needs to override properties manually
(as shown in the example). It would be preferable to have an option
for it...

Thanks,
  Harm

#(define-markup-command (underline-tst-II layout props arg)
  (markup?)
  #:category font
  #:properties ((thickness 1) (underline-offset 2) (underline-distance 2))

  (let* ((thick (ly:output-def-lookup layout 'line-thickness))
         (underline-thick (* thickness thick))
         (m (interpret-markup
              layout
              (prepend-alist-chain
                'underline-offset
                (+ underline-offset underline-distance)
                props)
              arg))
         (arg-x-ext (ly:stencil-extent m X))
         (x1 (car arg-x-ext))
         (x2 (cdr arg-x-ext))
         (y (* thick (- underline-offset)))
         (raw-line-stil (make-line-stencil underline-thick x1 y x2 y))
         (line
           (ly:make-stencil
             (ly:stencil-expr raw-line-stil)
             arg-x-ext
             (ly:stencil-extent raw-line-stil Y))))
    (ly:stencil-add m line)))

\markup
  \box
  \parenthesize
  \line {
    \underline-tst-II
    \underline-tst-II
    \line {
      Some text:
      \box
      \underline-tst-II
      \underline-tst-II
      \underline-tst-II
      \underline-tst-II
      "pq-tst"
      for testings
    }

    \override #'(underline-offset . 10)
    \underline-tst-II
    \underline-tst-II
    \line {
      Some text:
      \box
      \override #'(underline-offset . 2)
      \underline-tst-II
      \underline-tst-II
      \underline-tst-II
      \underline-tst-II
      "pq-tst"
      for testings
    }
}



reply via email to

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