Re: Accidental in brackets
Hi David, Am 05.12.2016 um 17:41 schrieb David Nalesnik: > Hi Urs, > > On Mon, Dec 5, 2016 at 10:30 AM, tisimstwrote: >> ... > Haven't examined the other alternatives proposed, but here's something > I just did. It's based on a rewrite of functions in > lily/accidental.cc > > HTH, > David Thanks for this. Seems to work perfectly. I renamed your parenthesize function because it would break the regular \parenthesize command. Best Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Accidental in brackets
On Mon, Dec 5, 2016 at 11:39 AM, David Nalesnikwrote: > On Mon, Dec 5, 2016 at 11:34 AM, SoundsFromSound > wrote: >> David Nalesnik wrote >>> Haven't examined the other alternatives proposed, but here's something >>> I just did. It's based on a rewrite of functions in >>> lily/accidental.cc >>> >>> HTH, >>> David >>> >>> ___ >>> lilypond-user mailing list >> >>> lilypond-user@ >> >>> https://lists.gnu.org/mailman/listinfo/lilypond-user >>> >>> >>> accidental-brackets.ly (3K) >>> http://lilypond.1069038.n5.nabble.com/attachment/197640/0/accidental-brackets.ly; >> >> Wow. David, this looks amazing. Perfect and exactly what the doctor ordered >> - well, for what I need :) Hope it helps others too! Huge thanks for this. >> Works like a charm. >> >> Ben >> > > > Thanks! > > On a side note, I'm becoming more and more convinced that C++ stencil > stuff should be ported to Scheme. It makes user modification so much > easier. > Though, on a technical note, I'm unsure of the best way to handle the pattern of repeatedly modifying a variable's value which the C++ source does in stencil functions. I've tried to avoid use of set! -- instead declaring new variables in the course of a let* block. But maybe set! isn't so un-schemic and is better for eliminating levels of nesting? David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Accidental in brackets
David Nalesnik wrote > Haven't examined the other alternatives proposed, but here's something > I just did. It's based on a rewrite of functions in > lily/accidental.cc > > HTH, > David > > ___ > lilypond-user mailing list > lilypond-user@ > https://lists.gnu.org/mailman/listinfo/lilypond-user > > > accidental-brackets.ly (3K) > http://lilypond.1069038.n5.nabble.com/attachment/197640/0/accidental-brackets.ly; Wow. David, this looks amazing. Perfect and exactly what the doctor ordered - well, for what I need :) Hope it helps others too! Huge thanks for this. Works like a charm. Ben - composer | sound designer LilyPond Tutorials (for beginners) --> http://bit.ly/bcl-lilypond -- View this message in context: http://lilypond.1069038.n5.nabble.com/Accidental-in-brackets-tp197629p197648.html Sent from the User mailing list archive at Nabble.com. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Accidental in brackets
On Mon, Dec 5, 2016 at 11:34 AM, SoundsFromSoundwrote: > David Nalesnik wrote >> Haven't examined the other alternatives proposed, but here's something >> I just did. It's based on a rewrite of functions in >> lily/accidental.cc >> >> HTH, >> David >> >> ___ >> lilypond-user mailing list > >> lilypond-user@ > >> https://lists.gnu.org/mailman/listinfo/lilypond-user >> >> >> accidental-brackets.ly (3K) >> http://lilypond.1069038.n5.nabble.com/attachment/197640/0/accidental-brackets.ly; > > Wow. David, this looks amazing. Perfect and exactly what the doctor ordered > - well, for what I need :) Hope it helps others too! Huge thanks for this. > Works like a charm. > > Ben > Thanks! On a side note, I'm becoming more and more convinced that C++ stencil stuff should be ported to Scheme. It makes user modification so much easier. David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Accidental in brackets
Hi Urs, On Mon, Dec 5, 2016 at 10:30 AM, tisimst <tisimst.lilyp...@gmail.com> wrote: > Urs, > > On Mon, Dec 5, 2016 at 7:54 AM, Mike Solomon [via Lilypond] <[hidden email]> > wrote: >> >> Hey! >> >> Total hack, but if you check out scm/stencil.scm, you’ll see how >> parentheses are made… >> >> (define-public (parenthesize-stencil >> stencil half-thickness width angularity padding) >> "Add parentheses around @var{stencil}, returning a new stencil." >> (let* ((y-extent (ly:stencil-extent stencil Y)) >> (lp (make-parenthesis-stencil >> y-extent half-thickness (- width) angularity)) >> (rp (make-parenthesis-stencil >> y-extent half-thickness width angularity))) >> (set! stencil (ly:stencil-combine-at-edge stencil X LEFT lp padding)) >> (set! stencil (ly:stencil-combine-at-edge stencil X RIGHT rp padding)) >> stencil)) >> >> So it looks like you can substitute in make-connected-path-stencil for >> make-parenthesis-stencil, using sensible parameters for the connected path >> based on the y extent and the width. > > > Here's another option for you that I created recently that creates brackets > roughly the same size as the real parentheses glyphs, so I think it (the > second one I describe in that message) tends to look a little better than > relying on the stencil of the accidental because, for example, you'll get > very different results for a flat glyph vs. a natural glyph (as will Mike's > code): > http://lists.gnu.org/archive/html/lilypond-user/2016-11/msg00928.html > > Best, > Abraham > Haven't examined the other alternatives proposed, but here's something I just did. It's based on a rewrite of functions in lily/accidental.cc HTH, David \version "2.19.46" % Returns default parens #(define (parenthesize grob m) (let* ((fm (ly:grob-default-font grob)) (op (ly:font-get-glyph fm "accidentals.leftparen")) (cl (ly:font-get-glyph fm "accidentals.rightparen")) (m (ly:stencil-combine-at-edge m X LEFT op 0)) (m (ly:stencil-combine-at-edge m X RIGHT cl 0))) m)) % Parens as brackets #(define (parenthesize grob mol) (let* ((ext (ly:stencil-extent mol Y)) (ss (ly:staff-symbol-staff-space grob)) (ext (interval-widen ext (/ ss 2.0))) ; too thin ;(thickness (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness)) (thickness 0.2) (protrusion 0.5) (lb (ly:bracket Y ext thickness protrusion)) (rb (ly:bracket Y ext thickness (- protrusion))) (mol (ly:stencil-combine-at-edge mol X LEFT lb 0)) (mol (ly:stencil-combine-at-edge mol X RIGHT rb 0))) mol)) #(define accidental-interface::square-brackets (lambda (grob) (let* ((fm (ly:grob-default-font grob)) (alist (ly:grob-property grob 'glyph-name-alist)) (alt (ly:grob-property grob 'alteration)) (glyph-name (ly:assoc-get alt alist #f)) (mol (if (string? glyph-name) (ly:font-get-glyph fm glyph-name) (begin (ly:warning (_ "Could not find glyph-name for alteration ~s") alt) (ly:font-get-glyph fm "noteheads.s1cross" (mol (if (eq? #t (ly:grob-property grob 'restore-first)) (let ((acc (ly:font-get-glyph fm "accidentals.natural"))) (if (ly:stencil? acc) (ly:stencil-combine-at-edge mol X LEFT acc 0.1) (begin (ly:warning "natural alteration glyph not found") mol))) mol))) (if (eq? #t (ly:grob-property grob 'parenthesized)) (parenthesize grob mol) mol { cis''?1 ces''? cisis''? ceses''? c''!? \override Staff.AccidentalCautionary.stencil = #accidental-interface::square-brackets cis''? ces''? cisis''? ceses''? c''!? % not cautionary... cis'' <es'? ges'? bes'?> }___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Accidental in brackets
Urs, On Mon, Dec 5, 2016 at 7:54 AM, Mike Solomon [via Lilypond] < ml-node+s1069038n197630...@n5.nabble.com> wrote: > Hey! > > Total hack, but if you check out scm/stencil.scm, you’ll see how > parentheses are made… > > (define-public (parenthesize-stencil > stencil half-thickness width angularity padding) > "Add parentheses around @var{stencil}, returning a new stencil." > (let* ((y-extent (ly:stencil-extent stencil Y)) > (lp (make-parenthesis-stencil > y-extent half-thickness (- width) angularity)) > (rp (make-parenthesis-stencil > y-extent half-thickness width angularity))) > (set! stencil (ly:stencil-combine-at-edge stencil X LEFT lp padding)) > (set! stencil (ly:stencil-combine-at-edge stencil X RIGHT rp padding)) > stencil)) > > So it looks like you can substitute in make-connected-path-stencil for > make-parenthesis-stencil, using sensible parameters for the connected path > based on the y extent and the width. > Here's another option for you that I created recently that creates brackets roughly the same size as the real parentheses glyphs, so I think it (the second one I describe in that message) tends to look a little better than relying on the stencil of the accidental because, for example, you'll get very different results for a flat glyph vs. a natural glyph (as will Mike's code): http://lists.gnu.org/archive/html/lilypond-user/2016-11/msg00928.html Best, Abraham -- View this message in context: http://lilypond.1069038.n5.nabble.com/Accidental-in-brackets-tp197629p197639.html Sent from the User mailing list archive at Nabble.com.___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Accidental in brackets
Hey! Total hack, but if you check out scm/stencil.scm, you’ll see how parentheses are made… (define-public (parenthesize-stencil stencil half-thickness width angularity padding) "Add parentheses around @var{stencil}, returning a new stencil." (let* ((y-extent (ly:stencil-extent stencil Y)) (lp (make-parenthesis-stencil y-extent half-thickness (- width) angularity)) (rp (make-parenthesis-stencil y-extent half-thickness width angularity))) (set! stencil (ly:stencil-combine-at-edge stencil X LEFT lp padding)) (set! stencil (ly:stencil-combine-at-edge stencil X RIGHT rp padding)) stencil)) So it looks like you can substitute in make-connected-path-stencil for make-parenthesis-stencil, using sensible parameters for the connected path based on the y extent and the width. ~Mike On 5 December 2016 at 16.46.16, Urs Liska (u...@openlilylib.org) wrote: Hi all, I don't seem to find the right thing, neither in the docs, the LSR nor the list archive. I need to put square brackets around some accidentals in order to differentiate them from default parentheses. I don't find the way to create the respective stencil for this. It has to be possible to do that \once, and I assume I'll run into the situation where I will need both round and square ones within a chord. Any help available? Thanks Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Accidental in brackets
Hi all, I don't seem to find the right thing, neither in the docs, the LSR nor the list archive. I need to put square brackets around some accidentals in order to differentiate them from default parentheses. I don't find the way to create the respective stencil for this. It has to be possible to do that \once, and I assume I'll run into the situation where I will need both round and square ones within a chord. Any help available? Thanks Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user