|
From: | Trevor Bača |
Subject: | Re: How to really center a text above a note? |
Date: | Mon, 29 Jun 2009 07:06:44 -0500 |
Wilbert Berendsen <lilykde <at> xs4all.nl> writes:I think the difference is that LyricTexts have NoteHeads as grob-parents,
>
> Op zondag 24 mei 2009, schreef madMuze:
> > perhaps a Schemer could pull the X-extent info from the attachment point
> > notehead, divide it by 2 and send that to the offset. Meanwhile, it may to
> > helpful to know that:
> > quarter-note head width = about 1.31
> > half-note head width = about 1.39
> > whole-note head width = about 1.96
> > (in staff space units)
>
> Thanks! But I think lyrics and dynamics are also able to center themselves
> nicely. So there must be way to get the center.
>
while TextScripts have PaperColumns.
Here's something that's pretty hacky, but seems to work, at least
in this simple case:
#(define lastNoteHeadWidth 0)
#(define (centerTextFn grob grob-origin context)
(cond ((grob::has-interface grob 'note-head-interface)
(set! lastNoteHeadWidth (cdr (ly:grob-property grob 'X-
extent))))
((grob::has-interface grob 'text-script-interface)
(let* ((xext (ly:grob-property grob 'X-extent))
(offset (* (- lastNoteHeadWidth (car xext) (cdr xext))
0.5)))
(ly:grob-set-property! grob 'X-offset offset)))))
centerText = \applyOutput #'Voice #centerTextFn
{
\centerText c'1-"Text"
\centerText c'4-"Text"
}
notehead-centering.png
Description: PNG image
weird-notehead-centering.png
Description: PNG image
[Prev in Thread] | Current Thread | [Next in Thread] |