4 texidoc = "The 'stencil property of the Flag grob can be set to a custom
5 scheme function to generate the glyph for the flag."
9 % test notes, which will be shown in different style:
10 testnotes = { \autoBeamOff c'8 d'16 c'32 d'64 \acciaccatura {c'8} d'64 c''8 d''16 c''32 d''64 \acciaccatura {c''8} d''64 }
12 #(define-public (weight-flag grob)
13 (let* ((stem-grob (ly:grob-parent grob X))
14 (log (- (ly:grob-property stem-grob 'duration-log) 2))
15 (is-up (eqv? (ly:grob-property stem-grob 'direction) UP))
16 (yext (if is-up (cons (* log -0.8) 0) (cons 0 (* log 0.8))))
17 (flag-stencil (make-filled-box-stencil '(-0.4 . 0.4) yext))
18 (stroke-style (ly:grob-property grob 'stroke-style))
19 (stroke-stencil (if (equal? stroke-style "grace") (make-line-stencil 0.2 -0.9 -0.4 0.9 -0.4) empty-stencil)))
20 (ly:stencil-add flag-stencil stroke-stencil)))
23 % Create a flag stencil by looking up the glyph from the font
24 #(define (inverted-flag grob)
25 (let* ((stem-grob (ly:grob-parent grob X))
26 (dir (if (eqv? (ly:grob-property stem-grob 'direction) UP) "d" "u"))
27 (flag (retrieve-glyph-flag "" dir "" grob))
28 (line-thickness (ly:staff-symbol-line-thickness grob))
29 (stem-thickness (ly:grob-property stem-grob 'thickness))
30 (stem-width (* line-thickness stem-thickness))
31 (stroke-style (ly:grob-property grob 'stroke-style))
32 (stencil (if (null? stroke-style) flag
33 (add-stroke-glyph flag grob dir stroke-style "")))
34 (rotated-flag (ly:stencil-rotate-absolute stencil 180 0 0)))
35 (ly:stencil-translate rotated-flag (cons (- (/ stem-width 2)) 0))))
38 \override Score.RehearsalMark.self-alignment-X = #LEFT
40 \mark "Function: weight-flag (custom)"
41 \override Flag.stencil = #weight-flag
44 \mark "Function: inverted-flag (custom)"
45 \override Flag.stencil = #inverted-flag