4 texidoc
= "The 'flag property of the Stem 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 stem-grob
)
13 (let
* ((log
(-
(ly
:grob-property stem-grob
'duration-log
) 2))
14 (is-up
(eqv?
(ly
:grob-property stem-grob
'direction
) UP
))
15 (yext
(if is-up
(cons
(* log -
0.8) 0) (cons
0 (* log
0.8))))
16 (flag-stencil
(make-filled-box-stencil
'(-
0.4 . 0.4) yext
))
17 (stroke-style
(ly
:grob-property stem-grob
'stroke-style
))
18 (stroke-stencil
(if
(equal? stroke-style
"grace") (make-line-stencil
0.2 -
0.9 -
0.4 0.9 -
0.4) empty-stencil
)))
19 (ly
:stencil-add flag-stencil stroke-stencil
)))
22 % Create a flag stencil by looking up the glyph from the font
23 #(define
(inverted-flag stem-grob
)
24 (let
* ((dir
(if
(eqv?
(ly
:grob-property stem-grob
'direction
) UP
) "d" "u"))
25 (flag
(retrieve-glyph-flag
"" dir
"" stem-grob
))
26 (line-thickness
(ly
:staff-symbol-line-thickness stem-grob
))
27 (stem-thickness
(ly
:grob-property stem-grob
'thickness
))
28 (stem-width
(* line-thickness stem-thickness
))
29 (stroke-style
(ly
:grob-property stem-grob
'stroke-style
))
30 (stencil
(if
(null? stroke-style
) flag
31 (add-stroke-glyph flag stem-grob dir stroke-style
"")))
32 (rotated-flag
(ly
:stencil-rotate-absolute stencil
180 0 0)))
33 (ly
:stencil-translate rotated-flag
(cons
(-
(/ stem-width
2)) 0))))
36 \override Score
.RehearsalMark
#'self-alignment-X
= #LEFT
38 \mark "Function: weight-flag (custom)"
39 \override Stem
#'flag
= #weight-flag
42 \mark "Function: inverted-flag (custom)"
43 \override Stem
#'flag
= #inverted-flag