|
View:
New views
15 Messages
—
Rating Filter:
Alert me
|
|
|
How to really center a text above a note?Hi,
There must be a way to really center a simple text above a note. But these two lines center the text above the *left* side of the note: { c'4-\markup\center-align text } { \once \override TextScript #'self-alignment-X = #CENTER c'4-"text" } How can I center a text or markup above the *center* of the note/chord? tia, Wilbert Berendsen -- Frescobaldi, LilyPond editor for KDE: http://www.frescobaldi.org/ _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
RE: How to really center a text above a note?Hi Wilbert, > There must be a way to really center a simple text above a note. > But [this centers] the text above the *left* side of the note: > { > \once \override TextScript #'self-alignment-X = #CENTER > c'4-"text" > } > How can I center a text or markup above the *center* of the note/chord? Offset the text by half the width of the notehead: \version "2.12.2" textmusic = \relative { \override TextScript #'self-alignment-X = #CENTER \override TextScript #'extra-offset = #'(0.6 . 0) c'-"center" c c c c,-"these" c c c c'-"words" } \score { \textmusic } Hope this helps! Kieren. _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
RE: How to really center a text above a note?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) David
|
|
|
Re: How to really center a text above a note?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. Breakable object have a break-align-anchor-alignment option that exactly specifies which side to use for aligning other things, but it seems not to work with common notes. I will try looking in the LilyPond source code to see how lyrics and dynamics do it... best regards, Wilbert Berendsen -- Frescobaldi, LilyPond editor for KDE: http://www.frescobaldi.org/ _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: How to really center a text above a note?Wilbert Berendsen <lilykde <at> xs4all.nl> writes:
> > 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. > I think the difference is that LyricTexts have NoteHeads as grob-parents, 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" } _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: How to really center a text above a note?Op maandag 25 mei 2009, schreef Michael Lauer:
> I think the difference is that LyricTexts have NoteHeads as grob-parents, > while TextScripts have PaperColumns. > (...) Many thanks, I'll try to dig this further out! best regards, Wilbert Berendsen -- Frescobaldi, LilyPond editor for KDE: http://www.frescobaldi.org/ _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: How to really center a text above a note?On Sun, May 24, 2009 at 8:36 PM, Michael Lauer <mrlauer1@...> wrote:
Hi Michael, hi Wilbert, Mark Polesky just pointed out to me that a thread I started yesterday ... http://lists.gnu.org/archive/html/lilypond-user/2009-06/msg00735.html ... asks essentially the same question that you guys were tackling here. So I thought I'd respond back to your posts here. First: Michael, that \centerText Scheme function you cooked up is very cool. If I'm reading correctly you're doing two things in the function. If the grob passed in is a notehead then you're saving the width (X-extent) of the notehead for use in the second condition. If the grob passed in is a TextScript then you're setting the X-offset of the TextScript to half the value of d, where d equals the width of the TextScript minus the width of the last known notehead. Yes? (So, basically exactly as David had sketched earlier in the thread?) Second: there used to be a (somewhat more) direct way of specifying the point-on-notehead to which TextScripts would make reference during positioning. Here're some settings from 2006: %%% BEGIN X-PARENT CENTERING SNIPPET %%% \version "2.9.16" textScriptCenterOnParent = \override TextScript #'X-offset = #(ly:make-simple-closure `(,+ ,(ly:make-simple-closure (list ly:self-alignment-interface::x-aligned-on-self)) ,(ly:make-simple-closure (list ly:self-alignment-interface::centered-on-x-parent)))) \textScriptCenterOnParent \override TextScript #'self-alignment-X = #left c'4_\markup { MMM } \override TextScript #'self-alignment-X = #center c'4_\markup { MMM } \override TextScript #'self-alignment-X = #right c'4_\markup { MMM } } %%% END X-PARENT SNIPPET %%% These are settings that I put together in September 2006 ... http://lists.gnu.org/archive/html/lilypond-user/2006-09/msg00088.html ... and, at that time, they worked great. See notehead-centering.png, reattached here for convenience. (And I should also mention that I cobbled together the settings given above by looking at the settings for OctavateEight in define-grobs.scm rather blindly. But they worked great.) But running that same code now (2.13.2) produces bizarre results. See weird-notehead-centering.png. So, thinking about Michael's statement here ... ML> I think the difference is that LyricTexts have NoteHeads as grob-parents, while TextScripts have PaperColumns. ... is it possible that TextScripts *used to* have NoteHeads as grob-parents (at least in 2.9.16) and have since changed to have PaperColumns as grob parents, thus rendering the settings from 2.9.16 no longer functional? Or is something else now going that would prevent calls to Self_alignment_interface::aligned_on_x_parent and centered_on_x_parent from working as they did previously? Trevor. -- Trevor Bača trevorbaca@... _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: How to really center a text above a note?A hint is to look at how the alignment is done for articulations, i.e.
Script layout objects, where the X-offset property is the function script-interface::calc-x-offset defined in scm/output-lib.scm. It doesn't work to use that function directly for TextScript objects, but you can probably use it as a building block or at least as inspiration for a similar function for TextScript objects. I figured this out when comparing to version 2.8, where the X-offset of Script objects indeed was calculated using ly:self-alignment-interface::centered-on-x-parent and yes, I have already tried to just replace this by script-interface::calc-x-offset in the code given below, so the solution is not that simple. /Mats Trevor Bača wrote: > Second: there used to be a (somewhat more) direct way of specifying > the point-on-notehead to which TextScripts would make reference during > positioning. Here're some settings from 2006: > > > %%% BEGIN X-PARENT CENTERING SNIPPET %%% > > \version "2.9.16" > > textScriptCenterOnParent = \override TextScript #'X-offset = > > #(ly:make-simple-closure > `(,+ ,(ly:make-simple-closure (list > ly:self-alignment-interface::x-aligned-on-self)) > ,(ly:make-simple-closure (list > ly:self-alignment-interface::centered-on-x-parent)))) > > \new Staff { > \textScriptCenterOnParent > \override TextScript #'self-alignment-X = #left > c'4_\markup { MMM } > \override TextScript #'self-alignment-X = #center > c'4_\markup { MMM } > \override TextScript #'self-alignment-X = #right > c'4_\markup { MMM } > } > > %%% END X-PARENT SNIPPET %%% > > > These are settings that I put together in September 2006 ... > > http://lists.gnu.org/archive/html/lilypond-user/2006-09/msg00088.html > > ... and, at that time, they worked great. See notehead-centering.png, > reattached here for convenience. > > (And I should also mention that I cobbled together the settings given > above by looking at the settings for OctavateEight in define-grobs.scm > rather blindly. But they worked great.) > > But running that same code now (2.13.2) produces bizarre results. See > weird-notehead-centering.png. > > So, thinking about Michael's statement here ... > > ML> I think the difference is that LyricTexts have NoteHeads as > grob-parents, > while TextScripts have PaperColumns. > > ... is it possible that TextScripts *used to* have NoteHeads as > grob-parents (at least in 2.9.16) and have since changed to have > PaperColumns as grob parents, thus rendering the settings from 2.9.16 > no longer functional? > > Or is something else now going that would prevent calls to > Self_alignment_interface::aligned_on_x_parent and centered_on_x_parent > from working as they did previously? > > > Trevor. > > > -- > Trevor Bača > trevorbaca@... <mailto:trevorbaca@...> > > ------------------------------------------------------------------------ > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------ > > _______________________________________________ > lilypond-user mailing list > lilypond-user@... > http://lists.gnu.org/mailman/listinfo/lilypond-user > -- ============================================= Mats Bengtsson Signal Processing School of Electrical Engineering Royal Institute of Technology (KTH) SE-100 44 STOCKHOLM Sweden Phone: (+46) 8 790 8463 Fax: (+46) 8 790 7260 Email: mats.bengtsson@... WWW: http://www.s3.kth.se/~mabe ============================================= _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: How to really center a text above a note?Trevor Bača wrote: > Or is something else now going that would prevent calls to > Self_alignment_interface::aligned_on_x_parent and > centered_on_x_parent from working as they did previously? Trevor, I honestly have no idea if this is relevant here, but recently I noticed that in define-grobs.scm, TextScript has 2 direction properties: line 1876: (direction . ,DOWN) line 1883: (direction . ,ly:script-interface::calc-direction) The possible consequences of this are currently under discussion in the developers mailing-list. http://lists.gnu.org/archive/html/lilypond-devel/2009-06/msg00620.html Don't know if this helps. - Mark _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: How to really center a text above a note?2009/6/29 Trevor Bača <trevorbaca@...>:
> ... is it possible that TextScripts *used to* have NoteHeads as grob-parents > (at least in 2.9.16) and have since changed to have PaperColumns as grob > parents, thus rendering the settings from 2.9.16 no longer functional? Michael's correct. The Text_engraver used to acknowledge rhythmic heads (i.e., noteheads & rests) and set them as X or Y parent depending on the side-support axis, but this code was removed in 2.11.15. > Or is something else now going that would prevent calls to > Self_alignment_interface::aligned_on_x_parent and centered_on_x_parent from > working as they did previously? The centring still works; it just that the text is anchored to the paper column. What appears to be strange positioning makes more sense if you display the paper columns (see attached image): in the centred case, the text is centred on the origin of the paper column (where the blue arrow is pointing). With apologies to Michael, here's a simpler method for centring text using a grob callback, which effectively does the same as your old code by retrieving the notehead (or rest) from the PaperColumn then mimicking the centered_on_x_parent callback: textScriptCenterOnParent = \override TextScript #'X-offset = #(lambda (grob) (let* ( ;; get parent in X axis (a PaperColumn) (paper-col (ly:grob-parent grob X)) ;; extract array of grobs attached to this column (elts (ly:grob-object paper-col 'elements)) ;; could be an unsafe assumption, but the first ;; element should be a NoteHead or Rest (rhythmic-head (ly:grob-array-ref elts 0))) (+ ;; read self-alignment-X (ly:self-alignment-interface::x-aligned-on-self grob) ;; equivalent to ly:self-alignment-interface::centered-on-x-parent, ;; but using the extracted notehead/rest instead of the paper column (interval-center (ly:grob-robust-relative-extent rhythmic-head rhythmic-head X))))) Regards, Neil _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: How to really center a text above a note?Neil Puttock <n.puttock <at> gmail.com> writes:
> > > With apologies to Michael, here's a simpler method for centring text > using a grob callback, which effectively does the same as your old > code by retrieving the notehead (or rest) from the PaperColumn then > mimicking the centered_on_x_parent callback: > Much nicer than mine, thanks! Michael _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: How to really center a text above a note?2009/6/29 Neil Puttock <n.puttock@...>:
> With apologies to Michael, here's a simpler method for centring text > using a grob callback, which effectively does the same as your old > code by retrieving the notehead (or rest) from the PaperColumn then > mimicking the centered_on_x_parent callback: Although I've been (shamefully) away from the LSR for the past few weeks, I can't help but thinking this could make a valuable snippet... Regards, Valentin _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: How to really center a text above a note?Valentin Villenave wrote: > 2009/6/29 Neil Puttock : > > With apologies to Michael, here's a simpler method for centring > > text using a grob callback, which effectively does the same as > > your old code by retrieving the notehead (or rest) from the > > PaperColumn then mimicking the centered_on_x_parent callback: > > Although I've been (shamefully) away from the LSR for the past > few weeks, I can't help but thinking this could make a valuable > snippet... If the "unsafe assumption" on line 8 could be addressed, I think it should be implemented in the source. Neil? - Mark Here it is again: textScriptCenterOnParent = \override TextScript #'X-offset = #(lambda (grob) (let* ( ;; get parent in X axis (a PaperColumn) (paper-col (ly:grob-parent grob X)) ;; extract array of grobs attached to this column (elts (ly:grob-object paper-col 'elements)) ;; could be an unsafe assumption, but the first ;; element should be a NoteHead or Rest (rhythmic-head (ly:grob-array-ref elts 0))) (+ ;; read self-alignment-X (ly:self-alignment-interface::x-aligned-on-self grob) ;; equivalent to ly:self-alignment-interface::centered-on-x-parent, ;; but using the extracted notehead/rest instead of the paper column (interval-center (ly:grob-robust-relative-extent rhythmic-head rhythmic-head X))))) _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: How to really center a text above a note?2009/7/5 Mark Polesky <markpolesky@...>:
> If the "unsafe assumption" on line 8 could be addressed, I think it > should be implemented in the source. Neil? I can probably do a loop to pick up the first head, i.e., filtering out any grobs which don't support rhythmic-head-interface. I don't think it's suitable for inclusion in the source, but would be fine as a selected snippet. Regards, Neil _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: How to really center a text above a note?On Tue, Jul 7, 2009 at 10:33 AM, Neil Puttock <n.puttock@...> wrote: 2009/7/5 Mark Polesky <markpolesky@...>: Hi Neil, Just a quick note to let you know that the structure (and commenting) of your response back three or four days ago was really super helpful. The code clarifies a couple of things (like access to grob parent) that I had always wondered about. I realized that I hadn't sent a proper thank you and I really should have. Thanks much! Trevor. -- Trevor Bača trevorbaca@... _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
| Free embeddable forum powered by Nabble | Forum Help |