\version "2.15.34" #(define (bar-line::calc-bar-extent grob) (let ((staff-symbol (ly:grob-object grob 'staff-symbol)) (staff-extent (cons 0 0))) (if (ly:grob? staff-symbol) (let* ((bar-line-color (ly:grob-property grob 'color)) (staff-color (ly:grob-property staff-symbol 'color)) (radius (ly:staff-symbol-staff-radius grob)) (line-thickness (ly:staff-symbol-line-thickness grob))) (set! staff-extent (ly:staff-symbol::height staff-symbol)) (if (and (eq? bar-line-color staff-color) radius) (interval-widen staff-extent (- 1 (* 1/2 (/ line-thickness radius))))))) staff-extent)) #(define-public (bar-line::print grob) (let* ((glyph (ly:grob-property grob 'glyph-name)) (bar-extent (ly:grob-property grob 'bar-extent '(0 . 0))) (extent (interval-length bar-extent)) (stencil (if (and (not (eq? glyph '())) (> extent 0)) (bar-line::compound-bar-line grob glyph extent #f)))) stencil)) #(define (bar-line::simple-bar-line grob width extent rounded) (let ((blot (if rounded (ly:output-def-lookup layout 'blot-diameter) 0))) (ly:round-filled-box (cons 0 width) (cons (* -0.5 extent) (* 0.5 extent)) blot))) #(define (bar-line::tick-bar-line grob height rounded) (let ((half-staff (* 1/2 (ly:staff-symbol-staff-space grob))) (stafflinethick (ly:staff-symbol-line-thickness grob)) (blot (if rounded (ly:output-def-lookup layout 'blot-diameter) 0))) (ly:round-filled-box (cons 0 stafflinethick) (cons (- height half-staff) (+ height half-staff)) blot))) #(define (bar-line::compound-bar-line grob glyph extent rounded) (let* ((staff-symbol (ly:grob-object grob 'staff-symbol)) (line-count (if (ly:grob? staff-symbol) (ly:grob-property staff-symbol 'line-count) 0)) (staff-space (ly:staff-symbol-staff-space grob)) (stafflinethick (ly:staff-symbol-line-thickness grob)) (dist (if (or (odd? line-count) (zero? line-count)) 1 (* staff-space (if (< staff-space 2) 2 1/2)))) (font (ly:grob-default-font grob)) (dot (ly:font-get-glyph font "dots.dot")) (kern (* (ly:grob-property grob 'kern 1) stafflinethick)) (thinkern (* (ly:grob-property grob 'thinkern 1) stafflinethick)) (hair (* (ly:grob-property grob 'hair-thickness 1) stafflinethick)) (fatline (* (ly:grob-property grob 'thick-thickness 1) stafflinethick)) (thin-stil (bar-line::simple-bar-line grob hair extent rounded)) (thick-stil (bar-line::simple-bar-line grob fatline extent rounded)) (stencil (case glyph (("|") thin-stil) ((".") thick-stil) (("'") (bar-line::tick-bar-line grob extent rounded)) (else (make-filled-box-stencil (cons 0 0) (cons 0 extent)))))) stencil )) music = \relative f { c'4 d e f | f f f f \bar "" | g g g g \bar "." g a b c \bar "||" c c c c \bar "'" c b a g \bar "|:" f e d c \bar "|." } \score { \new Staff { \new Voice { \music } } } \score { \new Staff { \new Voice { \override Staff.BarLine #'bar-extent = #bar-line::calc-bar-extent \override Staff.BarLine #'stencil = #bar-line::print \music } } }