lilypond-user
[Top][All Lists]
Advanced

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

Re: Parenthesis/bracket/brace questions


From: Thomas Morley
Subject: Re: Parenthesis/bracket/brace questions
Date: Mon, 21 May 2018 17:09:03 +0200

2018-05-21 15:03 GMT+02:00 Brent Annable <address@hidden>:
> Hey Andrew,
>
> Wow, this looks like exactly like my score! Thank you very much, I managed
> to tweak the values of this code to get exactly the shape I needed.
>
> On a side note, in my searches I noticed it's now possible to define
> different barline types, and the bracket type looks like it would also do
> the job very well here... but I can't get the brace to span both staves
> without having 'horns' (there seems to be some weird spanning behaviour
> too):
>
> \version "2.19.65"
>
> \defineBarLine "[" #'("" "[" ".")
> \defineBarLine "]" #'("]" "" ".")
>
> upper = {
>   c''4 \bar "[" 4 4 \bar "]" 4
> }
>
> lower = {
>   \clef bass
>   c4 4 4 4
> }
>
> \score {
>   \new PianoStaff <<
>     \new Staff {
>       \upper
>     }
>     \new Staff {
>       \lower
>     }
>   >>
> }
>
> Any ideas? I'm stumped.
>
> Brent.

Hi Brent,

(1)
thanks for spotting a bug in the definition of `make-bracket-bar-line'.
It will need further testings, before I can think of putting up a
patch, but I propose the fix below:

#(define ((make-bracket-bar-line dir) grob extent)
  "Draw a bracket-style bar line. If @var{dir} is set to @code{LEFT}, the
opening bracket will be drawn, for @code{RIGHT} we get the closing bracket."
  (let* ((thick-stil (make-thick-bar-line grob extent))
         (brackettips-up (ly:font-get-glyph (ly:grob-default-font grob)
                                            "brackettips.up"))
         (brackettips-down (ly:font-get-glyph (ly:grob-default-font grob)
                                              "brackettips.down"))
         ;; the x-extent of the brackettips must not be taken into account
         ;; for bar line constructs like "[|:", so we set new bounds:
         (tip-up-stil (ly:make-stencil (ly:stencil-expr brackettips-up)
                                       (cons 0 0)
                                       (ly:stencil-extent brackettips-up Y)))
         (tip-down-stil (ly:make-stencil (ly:stencil-expr brackettips-down)
                                         (cons 0 0)
                                         (ly:stencil-extent
brackettips-down Y)))
         (stencil (ly:stencil-add
                   thick-stil
                   (ly:stencil-translate-axis tip-up-stil
                                              (interval-end extent)
                                              Y)
                   (ly:stencil-translate-axis tip-down-stil
                                              (interval-start extent)
                                              Y))))

    (if (eqv? dir LEFT)
        stencil
        ;(ly:stencil-scale stencil -1 1)
        (flip-stencil X stencil)
        )))

#(add-bar-glyph-print-procedure "[" (make-bracket-bar-line LEFT))
#(add-bar-glyph-print-procedure "]" (make-bracket-bar-line RIGHT))


%% Example

#(define-bar-line "[" "|" "[" ".")
#(define-bar-line "]" "]" #f ".")


#(define-bar-line "[|:" "|" "[|:" ".|")
#(define-bar-line ":|]" ":|]" #f " |.")
#(define-bar-line ":|][|:" ":|]" "[|:" " |..|")

upper = {
  c''4 \bar "[" 4 4 \bar "]" 4
  c''4 \bar "[|:" 4 \bar ":|][|:" 4 \bar ":|]" 4
}

lower = {
  \clef bass
  c4 4 4 4
  c4 4 4 4
}

\score {
  \new PianoStaff <<
    \new Staff {
      \upper
    }
    \new Staff {
      \lower
    }
  >>
}

(2) You will always get those brackettips for every staff. It's a
limitation, caused by the way LilyPond prints BarLines/SpanBars.

As workaround two LSR-snippets are available:
http://lsr.di.unimi.it/LSR/Item?id=1032
http://lsr.di.unimi.it/LSR/Item?id=991



Cheers,
  Harm



reply via email to

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