lilypond-user
[Top][All Lists]
Advanced

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

Re: within \markup, how to \translate by width of another markup?


From: Jean Abou Samra
Subject: Re: within \markup, how to \translate by width of another markup?
Date: Tue, 17 May 2022 09:50:15 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1



Le 17/05/2022 à 07:49, Werner LEMBERG a écrit :
Sth like

\markup \box \number \column \with-dimensions-from \right-align "0"
\right-align { 11 10 6 5 4 3 2 1 }
While this is an ingenious solution – thanks! – it doesn't fit my
needs, alas, since two-digit numbers stick out to the left of the box.
This is exacerbated by the fact that in figured bass there are
sometimes prepended symbols like '#' – this can cause collisions with
other figured bass stacks on the left side in tight typesetting
situations.

In other words, the horizontal dimension of your solution is (0 . 100)
with some stuff sticking out to the left.  What I want is (-50 . 100),
without something sticking out to the left.

AFAICS, we are back to square one, needing the possibility to
`\translate` something by the width of another markup.  I will cook
something up and see how well it works.


Probably

\version "2.22.2"

#(define-markup-command (translate-by-extent-of layout props axis direction extent-source mkup)
   (index? ly:dir? markup? markup?)
   (let* ((stil (interpret-markup layout props mkup))
          (source-stil (interpret-markup layout props extent-source))
          (ext (ly:stencil-extent source-stil axis))
          (trans (* direction (interval-length ext))))
   (ly:stencil-translate-axis stil trans axis)))


\markup \box \number \column {
  \translate-by-extent-of #X #RIGHT 9 \right-align { 11 10 }
  6 5 4 3 2 1
}



That being said, I think I would rather define an interface to
align a markup on another markup.


\version "2.22.2"

#(define-markup-command (align-on-other layout props axis self-align-dir other-align-dir
                                        alignment-markup printed-markup)
   (index? number? number? markup? markup?)
   (let* ((stil (interpret-markup layout props printed-markup))
          (stil-ext (ly:stencil-extent stil axis))
          (align-stil (interpret-markup layout props alignment-markup))
          (align-ext (ly:stencil-extent align-stil axis))
          (trans (- (interval-index align-ext other-align-dir)
                    (interval-index stil-ext self-align-dir))))
     (ly:stencil-translate-axis stil trans axis)))

\markup \number \column {
  \align-on-other #X #RIGHT #RIGHT 9 { 11 10 }
  6 5 4 3 2 1
}

By the way, are you sur this is the canonical presentation for
figured bass digits? \figures { <11 10 6 5 4 3 2 1> } seems to
do a kind of \center-column (using the ad-hoc translation you
mentioned), which what I would expect ...

Best,
Jean




reply via email to

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