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