lilypond-user
[Top][All Lists]
Advanced

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

Re: horizontal alignment suggestions


From: Neil Puttock
Subject: Re: horizontal alignment suggestions
Date: Mon, 4 May 2009 22:03:43 +0100

2009/5/3 Kieren MacMillan <address@hidden>:

> There's likely a way to make a Scheme function which automatically
> \translate-s the text the correct amount, but I don't have time to
> investigate it.

Since the instrument name conveniently makes up the negative part of
the score markup's horizontal extent, the easiest workaround is to
remove it from the score's bounding box.

The following markup command performs a selective \with-dimensions on
a markup without having to work out the extent of the instrument name:

#(define-markup-command (ignoreInstrumentName layout props score) (markup?)
  (let* (
         ;; get stencil from markup
         (stencil (interpret-markup layout props score))
         ;; get dimensions of stencil in X and Y axes
         (x-extent (ly:stencil-extent stencil X))
         (y-extent (ly:stencil-extent stencil Y)))

    ;; reset left part of x-extent so it's the same as
    ;; a score markup without an instrument name
    (set-car! x-extent -0.2)
    ;; return a copy of original stencil with altered bounding box
    (ly:make-stencil (ly:stencil-expr stencil) x-extent y-extent)))

\markup {
  \fill-line {
    \ignoreInstrumentName
    \score {
      \new Staff \with { instrumentName = "Instrument Name" } { a4 g a f }
      \layout { indent = 0 }
    }
  }
}
\markup {
  \fill-line {
    \score {
      \new Staff { a4 g a f }
      \layout { indent = 0 }
    }
  }
}

Regards,
Neil




reply via email to

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