lilypond-user
[Top][All Lists]
Advanced

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

Re: Baseline align in TextSpanner


From: Trevor Bača
Subject: Re: Baseline align in TextSpanner
Date: Wed, 17 Oct 2018 20:19:28 -0500

Hi Davide,

Avoid the the LilyPond \tempo command entirely: then use markup (in text spanner bound-details) for everything. Alignment (baseline and otherwise) can then be controlled with text spanner bound-details.

If you need an empty region of of whitespace between two elements in your (possibly enchained) text spanners, play with the dash fraction / dash period of the text spanner to make the dashes disappear, leaving only your markup visible.

Trevor.



On Sun, Oct 14, 2018 at 2:17 PM Davide Liessi <address@hidden> wrote:
Dear Kieren,

Il giorno ven 5 ott 2018 alle ore 15:11 Kieren MacMillan
<address@hidden> ha scritto:
> This works for me:
[...]

your solution works well to keep all TextSpanners baseline-aligned,
but it still does not solve my real problem, which indeed was not
apparent in my first message.
I'm trying to make TextSpanners and tempo markings look the same,
including being aligned at the same baseline.
The reason is to follow the recommendations of Gould for tempo
alteration markings (example at page 184).

A slightly more realistic example follows: I would like to align
\tempo markings and TextSpanners to the same baseline.
As you can see using your trick on both does achieve the desired result.
I renamed the \test function to a more specific \baseline-align.
I'm cc-ing also Harm / Thomas Morley because I'm using his code, so he
may have some insights or suggestions.

Thanks for your help so far.
Best wishes!
Davide

%%% new example
\version "2.19.81"

#(define (lists-map function ls)
   "Apply @var{function} to @var{ls} and all of it sublists.
First it recurses over the children, then the function is applied to
@var{ls}."
   (if (list? ls)
       (set! ls (map (lambda (y) (lists-map function y)) ls))
       ls)
   (function ls))

#(define baseline-align-proc
   (lambda (e)
     (if (and (list? e) (member 'glyph-string e))
         (begin
          (for-each
           (lambda (x)
             (begin
              (set-car! (cadr x) 0)
              x))
           (cadr (last e)))
          e)
         e)))

#(define-markup-command (baseline-align layout props glyph-name)
   (markup?)
   (let* ((stil (interpret-markup layout props glyph-name))
          (new-stile-expr
           (lists-map
            baseline-align-proc
            (ly:stencil-expr stil))))

     (ly:make-stencil
      new-stile-expr
      (ly:stencil-extent stil X)
      ;(cons 0 (cdr (ly:stencil-extent stil Y)))
      (ly:stencil-extent stil Y)
      )))

startTempoSpan =
#(define-event-function
  (left-text)
  (markup?)
  #{
    \tweak bound-details.left.text \markup {
      \combine \transparent "Tj"
      #left-text
    }
    \tweak font-shape #'upright
    \tweak font-size 1
    \tweak font-series #'bold
    \startTextSpan
  #})
stopTempoSpan = \stopTextSpan

{
  R1 |
  \tempo \markup { \baseline-align \large "a" }
  R1 |
  \tempo \markup { \baseline-align \large "p" }
  R1 |
  <>\startTempoSpan "a"
  R1
  <>\stopTempoSpan |
  R1 |
  <>\startTempoSpan "p"
  R1
  <>\stopTempoSpan |
  R1
  \tempo \markup { \large \combine \transparent "Tj" "a" }
  R1 |
  \tempo \markup { \large \combine \transparent "Tj" "p" }
  R1 |
}

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


--

reply via email to

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