whiteout: override stencil, not markup-command
[opus_libre.git] / bin / text-functions.ly
blob940355e709dd89495c7be97d0450eed60812f3cb
1 %------------------------------------------------------------------%
2 % Opéra Libre -- text-functions.ly %
3 % %
4 % (c) Valentin Villenave, 2008, 2009 %
5 %------------------------------------------------------------------%
7 %% FIXME: adapt to new framework
10 %%%%%%%%%%%%%%%%%%%%%%%%%% In-score Text %%%%%%%%%%%%%%%%%%%%%%%%%%%
13 %% Non-standard synamics ------------------------------------------%
15 fpp = #(make-dynamic-script "fpp")
16 sffz = #(make-dynamic-script "sffz")
19 %% Composite Dynamics ---------------------------------------------%
21 % because of the use of a music-function,
22 % non-predefined composite dynamics have to be entered *before*
23 % the affected beat (unlike standard or predefined dynamics).
24 cmb =
25 #(define-music-function (parser location dyn str) (string? string?)
26 (make-music 'SequentialMusic 'elements
27 (list
28 (make-music 'OverrideProperty
29 'symbol 'DynamicText
30 'grob-property-path (list 'self-alignment-X)
31 'grob-value -0.6 'once #t)
32 (make-music 'AbsoluteDynamicEvent
33 'text
34 (markup #:rounded-whiteout 1
35 #:line (#:dynamic dyn
36 #:hspace .5
37 #:text #:medium #:italic str))))))
39 bmc =
40 #(define-music-function (parser location str dyn) (string? string?)
41 (make-music 'SequentialMusic 'elements
42 (list
43 (make-music 'OverrideProperty
44 'symbol 'DynamicText
45 'grob-property-path (list 'self-alignment-X)
46 'grob-value -0.6 'once #t)
47 (make-music 'AbsoluteDynamicEvent
48 'text
49 (markup #:rounded-whiteout 1
50 #:line (#:text #:medium #:italic str
51 #:hspace .5
52 #:dynamic dyn))))))
54 %% Predefined commands
56 ffsubito = #(make-dynamic-extra "ff" "subito")
57 fsubito = #(make-dynamic-extra "f" "subito")
58 fsempre = #(make-dynamic-extra "f" "sempre")
59 mfsubito = #(make-dynamic-extra "mf" "subito")
60 fmolto = #(make-dynamic-extra "f" "molto")
61 psempre = #(make-dynamic-extra "p" "sempre")
62 ppsempre = #(make-dynamic-extra "pp" "sempre")
63 mpsempre = #(make-dynamic-extra "mp" "sempre")
64 mfsempre = #(make-dynamic-extra "mf" "sempre")
65 mfintenso = #(make-dynamic-extra "mf" "intenso")
66 mpsostenuto = #(make-dynamic-extra "mp" "sostenuto")
67 psubito = #(make-dynamic-extra "p" "subito")
68 pdolce = #(make-dynamic-extra "p" "dolce")
69 ppdolce = #(make-dynamic-extra "pp" "dolce")
70 pleggiero = #(make-dynamic-extra "p" "leggiero")
71 ppleggiero = #(make-dynamic-extra "pp" "leggiero")
72 ppsubito = #(make-dynamic-extra "pp" "subito")
73 mfleggiero = #(make-dynamic-extra "mf" "leggiero")
74 piuf = #(make-extra-dynamic "più" "f")
75 pocof = #(make-extra-dynamic "poco" "f")
78 %% Text indications -----------------------------------------------%
80 ind =
81 #(define-music-function (parser location text music) (string? ly:music?)
82 (if
83 (equal? (ly:music-property music 'name) 'EventChord)
84 (set! (ly:music-property music 'elements)
85 (append (ly:music-property music 'elements)
86 (list (make-music 'TextScriptEvent 'direction 1
87 'text (markup #:indic text))))))
88 music)
90 nind =
91 #(define-music-function (parser location texte)
92 (string? )
93 (make-dynamic-script
94 (markup #:text #:indic texte)))
96 %% Predefined commands
97 pizz =
98 #(define-music-function (parser location music) (ly:music?)
99 #{ \ind #"pizz." $music #})
101 arco =
102 #(define-music-function (parser location music) (ly:music?)
103 #{ \ind #"arco" $music #})
105 flaut =
106 #(define-music-function (parser location music) (ly:music?)
107 #{ \ind #"flautando" $music #})
109 simile =
110 #(define-music-function (parser location music) (ly:music?)
111 #{ \ind #"simile" $music #})
113 loco =
114 #(define-music-function (parser location music) (ly:music?)
115 #{ \ind #"loco" $music #})
117 ordin =
118 #(define-music-function (parser location music) (ly:music?)
119 #{ \ind #"(ordin.)" $music #})
121 meno =
122 #(define-music-function (parser location music) (ly:music?)
123 #{ \ind #"meno" $music #})
125 jet =
126 #(define-music-function (parser location music) (ly:music?)
127 #{ \ind #"jeté" $music #})
129 %%%%%%%%%%%%%%%%%%%%%%%%%%%% Other Text %%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 %% Lyrics formatting ----------------------------------------------%
134 freeStyleOn = {
135 \override Lyrics . LyricExtender #'stencil = ##f }
137 freeStyleOff = {
138 \revert Lyrics . LyricExtender #'stencil }
140 leftSyl = {
141 \once \override LyricText #'self-alignment-X = #0.9 }
143 dash = {
144 \once \override LyricHyphen #'minimum-distance = #4
145 \once \override LyricHyphen #'length = #2
146 \once \override LyricHyphen #'thickness = #1.2
149 ital = {
150 \once \override LyricText #'font-shape = #'italic }
152 smallcaps = {
153 \override LyricText #'font-shape = #'caps }
155 normal = {
156 \revert LyricText #'font-shape }
159 %% Scenography formatting ---------------------------------------%
160 long = {
161 \once \override TextScript #'extra-spacing-width = #'(0 . 0)
162 \once \override TextScript #'infinite-spacing-height = ##t
165 #(define-markup-command (did layout props text) (markup?)
166 (interpret-markup layout props
167 (markup #:override '(line-width . 40)
168 #:override '(box-padding . 1)
169 #:override '(corner-radius . 2)
170 #:rounded-box #:sans #:italic #:small #:justify-string text)))
172 #(define-markup-command (init-did layout props text) (markup?)
173 (interpret-markup layout props
174 (markup
175 ; #:override (cons 'line-width (* 1 (chain-assoc-get 'line-width props)))
176 #:fill-line (
177 #:override '(line-width . 60)
178 #:override '(box-padding . 1.5)
179 #:override '(corner-radius . 2)
180 #:rounded-box #:sans #:italic #:small #:justify-string text))))
183 %% Table of contents --------------------------------------------%
184 tocAct =
185 #(define-music-function (parser location text) (markup?)
186 (add-toc-item! 'tocActMarkup text))
188 tocQuote =
189 #(define-music-function (parser location text) (markup?)
190 (add-toc-item! 'tocQuoteMarkup text))
192 %% Characters and instrument names ------------------------------%
194 #(define characters `((dummy . "")))
195 #(define instruments `((dummy . "")))
197 #(define (char-name n) (car (car (assoc-get n characters))))
198 #(define (char-shortname n) (cdr (car (assoc-get n characters))))
199 #(define (instr-name n) (car (car (assoc-get n instruments))))
200 #(define (instr-shortname n) (cdr (car (assoc-get n instruments))))
202 #(define (make-char-name n . pad)
203 (let* ((txt (char-name n))
204 (srt (char-shortname n))
205 (m (if (pair? pad)
206 (markup #:hcenter-in (car pad) txt)
207 (markup txt)))
208 (n (markup srt))) fixme: shortname has no padding
209 (ly:export (make-sequential-music (list
210 (context-spec-music (make-property-set 'instrumentName m)
211 'Staff)
212 (context-spec-music (make-property-set 'shortInstrumentName n)
213 'Staff)
214 (context-spec-music (make-property-set 'midiInstrument "voice oohs")
215 'Staff))))))
217 #(define (make-instrument-name n midi . pad)
218 (let* ((txt (instr-name n))
219 (srt (instr-shortname n))
220 (m (if (pair? pad)
221 (markup #:hcenter-in (car pad) txt)
222 (markup txt)))
223 (n (markup srt))) ;; fixme: shortname has no padding
224 (ly:export (make-sequential-music (list
225 (context-spec-music (make-property-set 'instrumentName m)
226 'Staff)
227 (context-spec-music (make-property-set 'shortInstrumentName n)
228 'Staff)
229 (context-spec-music (make-property-set 'midiInstrument midi)
230 'Staff))))))