lilypond-user
[Top][All Lists]
Advanced

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

Re: Baseline align in TextSpanner


From: Davide Liessi
Subject: Re: Baseline align in TextSpanner
Date: Sun, 14 Oct 2018 21:16:54 +0200

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 |
}



reply via email to

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