lilypond-user
[Top][All Lists]
Advanced

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

Baseline align in TextSpanner


From: Davide Liessi
Subject: Baseline align in TextSpanner
Date: Fri, 28 Sep 2018 08:25:39 +0200

Hi all.
I want to align TextSpanner texts to baseline.
I'm trying to use the code provided by Thomas Morley / Harm in
http://lists.gnu.org/archive/html/lilypond-user/2016-10/msg00365.html
which works very well e.g. with \tempo, but applying \test to
TextSpanner.bound-details.left.text has no effect.
I also tried replacing ly:line-spanner::print in TextSpanner.stencil
with a new function but I couldn't make it work.
An example follows, including Harm's code.
Is there a way to adapt it to my case?
Best wishes.
Davide

\version "2.19.82"

#(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 test-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 (test layout props glyph-name)
   (markup?)
   (let* ((stil (interpret-markup layout props glyph-name))
          (new-stile-expr
           (lists-map
            test-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)
      )))

{
  \override TextSpanner.bound-details.left.text = \markup { \test "a" }
  b2\startTextSpan b2\stopTextSpan
  \override TextSpanner.bound-details.left.text = \markup { \test "p" }
  b2\startTextSpan b2\stopTextSpan
}



reply via email to

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