1 ;;;; define-markup-commands.scm -- markup commands
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
9 ;;; * each markup function should have a doc string with
10 ;; syntax, description and example.
12 (define-public empty-stencil (ly:make-stencil '() '(1 . -1) '(1 . -1)))
13 (define-public point-stencil (ly:make-stencil "" '(0 . 0) '(0 . 0)))
15 (def-markup-command (stencil layout props stil) (ly:stencil?)
20 (def-markup-command (with-url layout props url arg) (string? markup?)
21 "Add a link to URL @var{url} around @var{arg}. This only works in
24 ((stil (interpret-markup layout props arg))
25 (xextent (ly:stencil-extent stil X))
26 (yextent (ly:stencil-extent stil Y))
27 (old-expr (ly:stencil-expr stil))
28 (url-expr (list 'url-link url `(quote ,xextent) `(quote ,yextent))))
31 (ly:make-stencil url-expr xextent yextent)
34 (def-markup-command (score layout props score) (ly:score?)
35 "Inline an image of music."
36 (let* ((systems (ly:score-embedded-format score layout)))
38 (if (= 0 (vector-length systems))
40 (ly:warn "No systems found in \\score markup. Did you forget \\layout?")
43 (let* ((stencil (ly:paper-system-stencil (vector-ref systems 0))))
45 (ly:stencil-align-to! stencil Y CENTER)
48 (def-markup-command (simple layout props str) (string?)
49 "A simple text string; @code{\\markup @{ foo @}} is equivalent with
50 @code{\\markup @{ \\simple #\"foo\" @}}."
51 (interpret-markup layout props str))
53 (def-markup-command (encoded-simple layout props sym str) (symbol? string?)
54 "A text string, encoded with encoding @var{sym}. See
55 @usermanref{Text encoding} for more information."
56 (Text_interface::interpret_string layout
60 ;; TODO: use font recoding.
62 ;; (map make-word-markup (string-tokenize str)))))
64 (define-public empty-markup
65 (make-simple-markup ""))
68 (def-markup-command (postscript layout props str) (string?)
69 "This inserts @var{str} directly into the output as a PostScript
70 command string. Due to technicalities of the output backends,
71 different scales should be used for the @TeX{} and PostScript backend,
72 selected with @code{-f}.
75 For the TeX backend, the following string prints a rotated text
80 0 0 moveto /ecrm10 findfont
81 1.75 scalefont setfont 90 rotate (hello) show
85 The magical constant 1.75 scales from LilyPond units (staff spaces) to
88 For the postscript backend, use the following
91 gsave /ecrm10 findfont
93 scalefont setfont 90 rotate (hello) show grestore
98 (list 'embedded-ps str)
101 ;;(def-markup-command (fill-line layout props line-width markups)
102 ;; (number? markup-list?)
103 ;; no parser tag -- should make number? markuk-list? thingy
104 (def-markup-command (fill-line layout props markups)
106 "Put @var{markups} in a horizontal line of width @var{line-width}.
107 The markups are spaced/flushed to fill the entire line.
108 If there are no arguments, return an empty stencil.
110 (let* ((orig-stencils
111 (map (lambda (x) (interpret-markup layout props x))
115 (if (ly:stencil-empty? stc)
117 stc)) orig-stencils))
120 (if (ly:stencil-empty? stc)
122 (interval-length (ly:stencil-extent stc X))))
124 (text-width (apply + text-widths))
125 (word-count (length stencils))
126 (word-space (chain-assoc-get 'word-space props))
127 (line-width (chain-assoc-get 'linewidth props))
132 (/ (- line-width text-width) 2)
133 (/ (- line-width text-width) 2)))
136 (- line-width text-width)))
138 (get-fill-space word-count line-width text-widths))))
146 (line-stencils (if (= word-count 1)
153 (if (null? (remove ly:stencil-empty? orig-stencils))
155 (stack-stencils-padding-list X RIGHT fill-space-normal line-stencils))))
157 (define (get-fill-space word-count line-width text-widths)
158 "Calculates the necessary paddings between each two adjacent texts.
159 The lengths of all texts are stored in @var{text-widths}.
160 The normal formula for the padding between texts a and b is:
161 padding = line-width/(word-count - 1) - (length(a) + length(b))/2
162 The first and last padding have to be calculated specially using the
163 whole length of the first or last text.
164 Returns a list of paddings.
167 ;; special case first padding
168 ((= (length text-widths) word-count)
170 (- (- (/ line-width (1- word-count)) (car text-widths)) (/ (car (cdr text-widths)) 2))
171 (get-fill-space word-count line-width (cdr text-widths))))
172 ;; special case last padding
173 ((= (length text-widths) 2)
174 (list (- (/ line-width (1- word-count)) (+ (/ (car text-widths) 2) (car (cdr text-widths)))) 0))
177 (- (/ line-width (1- word-count)) (/ (+ (car text-widths) (car (cdr text-widths))) 2))
178 (get-fill-space word-count line-width (cdr text-widths))))))
180 (define (font-markup qualifier value)
181 (lambda (layout props arg)
182 (interpret-markup layout
183 (prepend-alist-chain qualifier value props)
187 (def-markup-command (line layout props args) (markup-list?)
188 "Put @var{args} in a horizontal line. The property @code{word-space}
189 determines the space between each markup in @var{args}."
191 (chain-assoc-get 'word-space props)
192 (remove ly:stencil-empty?
193 (map (lambda (m) (interpret-markup layout props m)) args))))
195 (def-markup-command (fromproperty layout props symbol) (symbol?)
196 "Read the @var{symbol} from property settings, and produce a stencil
197 from the markup contained within. If @var{symbol} is not defined, it
198 returns an empty markup"
199 (let* ((m (chain-assoc-get symbol props)))
201 (interpret-markup layout props m)
202 (ly:make-stencil '() '(1 . -1) '(1 . -1)))))
205 (def-markup-command (on-the-fly layout props procedure arg) (symbol? markup?)
206 "Apply the @var{procedure} markup command to
207 @var{arg}. @var{procedure} should take a single argument."
208 (let* ((anonymous-with-signature (lambda (layout props arg) (procedure layout props arg))))
209 (set-object-property! anonymous-with-signature
212 (interpret-markup layout props (list anonymous-with-signature arg))))
215 (def-markup-command (combine layout props m1 m2) (markup? markup?)
216 "Print two markups on top of each other."
217 (let* ((s1 (interpret-markup layout props m1))
218 (s2 (interpret-markup layout props m2)))
219 (ly:stencil-add s1 s2)))
221 (def-markup-command (finger layout props arg) (markup?)
222 "Set the argument as small numbers."
223 (interpret-markup layout
224 (cons '((font-size . -5) (font-encoding . fetaNumber)) props)
227 (def-markup-command (fontsize layout props mag arg) (number? markup?)
228 "This sets the relative font size, e.g.
230 A \\fontsize #2 @{ B C @} D
234 This will enlarge the B and the C by two steps.
238 (prepend-alist-chain 'font-size mag props)
241 (def-markup-command (magnify layout props sz arg) (number? markup?)
242 "This sets the font magnification for the its argument. In the following
243 example, the middle A will be 10% larger:
245 A \\magnify #1.1 @{ A @} A
248 Note: magnification only works if a font-name is explicitly selected.
249 Use @code{\\fontsize} otherwise."
252 (prepend-alist-chain 'font-magnification sz props)
255 (def-markup-command (bold layout props arg) (markup?)
256 "Switch to bold font-series"
257 (interpret-markup layout (prepend-alist-chain 'font-series 'bold props) arg))
259 (def-markup-command (sans layout props arg) (markup?)
260 "Switch to the sans serif family"
261 (interpret-markup layout (prepend-alist-chain 'font-family 'sans props) arg))
263 (def-markup-command (number layout props arg) (markup?)
264 "Set font family to @code{number}, which yields the font used for
265 time signatures and fingerings. This font only contains numbers and
266 some punctuation. It doesn't have any letters. "
267 (interpret-markup layout (prepend-alist-chain 'font-encoding 'fetaNumber props) arg))
269 (def-markup-command (roman layout props arg) (markup?)
270 "Set font family to @code{roman}."
271 (interpret-markup layout (prepend-alist-chain 'font-family 'roman props) arg))
273 (def-markup-command (huge layout props arg) (markup?)
274 "Set font size to +2."
275 (interpret-markup layout (prepend-alist-chain 'font-size 2 props) arg))
277 (def-markup-command (large layout props arg) (markup?)
278 "Set font size to +1."
279 (interpret-markup layout (prepend-alist-chain 'font-size 1 props) arg))
281 (def-markup-command (normalsize layout props arg) (markup?)
282 "Set font size to default."
283 (interpret-markup layout (prepend-alist-chain 'font-size 0 props) arg))
285 (def-markup-command (small layout props arg) (markup?)
286 "Set font size to -1."
287 (interpret-markup layout (prepend-alist-chain 'font-size -1 props) arg))
289 (def-markup-command (tiny layout props arg) (markup?)
290 "Set font size to -2."
291 (interpret-markup layout (prepend-alist-chain 'font-size -2 props) arg))
293 (def-markup-command (teeny layout props arg) (markup?)
294 "Set font size to -3."
295 (interpret-markup layout (prepend-alist-chain 'font-size -3 props) arg))
297 (def-markup-command (caps layout props arg) (markup?)
298 "Set @code{font-shape} to @code{caps}."
299 (interpret-markup layout (prepend-alist-chain 'font-shape 'caps props) arg))
301 ;(def-markup-command (latin-i layout props arg) (markup?)
302 ; "TEST latin1 encoding."
303 ; (interpret-markup layout (prepend-alist-chain 'font-shape 'latin1 props) arg))
305 (def-markup-command (dynamic layout props arg) (markup?)
306 "Use the dynamic font. This font only contains @b{s}, @b{f}, @b{m},
307 @b{z}, @b{p}, and @b{r}. When producing phrases, like ``pi@`{u} @b{f}'', the
308 normal words (like ``pi@`{u}'') should be done in a different font. The
309 recommend font for this is bold and italic"
311 layout (prepend-alist-chain 'font-encoding 'fetaDynamic props) arg))
313 (def-markup-command (italic layout props arg) (markup?)
314 "Use italic @code{font-shape} for @var{arg}. "
315 (interpret-markup layout (prepend-alist-chain 'font-shape 'italic props) arg))
317 (def-markup-command (typewriter layout props arg) (markup?)
318 "Use @code{font-family} typewriter for @var{arg}."
320 layout (prepend-alist-chain 'font-family 'typewriter props) arg))
322 (def-markup-command (upright layout props arg) (markup?)
323 "Set font shape to @code{upright}."
325 layout (prepend-alist-chain 'font-shape 'upright props) arg))
327 (def-markup-command (doublesharp layout props) ()
328 "Draw a double sharp symbol."
330 (interpret-markup layout props (markup #:musicglyph "accidentals.4")))
331 (def-markup-command (sesquisharp layout props) ()
332 "Draw a 3/2 sharp symbol."
333 (interpret-markup layout props (markup #:musicglyph "accidentals.3")))
335 (def-markup-command (sharp layout props) ()
336 "Draw a sharp symbol."
337 (interpret-markup layout props (markup #:musicglyph "accidentals.2")))
339 (def-markup-command (semisharp layout props) ()
340 "Draw a semi sharp symbol."
341 (interpret-markup layout props (markup #:musicglyph "accidentals.1")))
343 (def-markup-command (natural layout props) ()
344 "Draw a natural symbol."
345 (interpret-markup layout props (markup #:musicglyph "accidentals.0")))
347 (def-markup-command (semiflat layout props) ()
349 (interpret-markup layout props (markup #:musicglyph "accidentals.M1")))
351 (def-markup-command (flat layout props) ()
352 "Draw a flat symbol."
353 (interpret-markup layout props (markup #:musicglyph "accidentals.M2")))
355 (def-markup-command (sesquiflat layout props) ()
356 "Draw a 3/2 flat symbol."
357 (interpret-markup layout props (markup #:musicglyph "accidentals.M3")))
359 (def-markup-command (doubleflat layout props) ()
360 "Draw a double flat symbol."
361 (interpret-markup layout props (markup #:musicglyph "accidentals.M4")))
363 (def-markup-command (column layout props args) (markup-list?)
364 "Stack the markups in @var{args} vertically. The property
365 @code{baseline-skip} determines the space between each markup in @var{args}."
366 (display (chain-assoc-get 'baseline-skip props))(newline)
368 -1 0.0 (chain-assoc-get 'baseline-skip props)
369 (remove ly:stencil-empty?
370 (map (lambda (m) (interpret-markup layout props m)) args))))
372 (def-markup-command (dir-column layout props args) (markup-list?)
373 "Make a column of args, going up or down, depending on the setting
374 of the @code{#'direction} layout property."
375 (let* ((dir (chain-assoc-get 'direction props)))
377 (if (number? dir) dir -1)
379 (chain-assoc-get 'baseline-skip props)
380 (map (lambda (x) (interpret-markup layout props x)) args))))
382 (def-markup-command (center-align layout props args) (markup-list?)
383 "Put @code{args} in a centered column. "
384 (let* ((mols (map (lambda (x) (interpret-markup layout props x)) args))
385 (cmols (map (lambda (x) (ly:stencil-align-to! x X CENTER)) mols)))
386 (stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) cmols)))
388 (def-markup-command (vcenter layout props arg) (markup?)
389 "Align @code{arg} to its Y center. "
390 (let* ((mol (interpret-markup layout props arg)))
391 (ly:stencil-align-to! mol Y CENTER)
394 (def-markup-command (hcenter layout props arg) (markup?)
395 "Align @code{arg} to its X center. "
396 (let* ((mol (interpret-markup layout props arg)))
397 (ly:stencil-align-to! mol X CENTER)
400 (def-markup-command (right-align layout props arg) (markup?)
401 "Align @var{arg} on its right edge. "
402 (let* ((m (interpret-markup layout props arg)))
403 (ly:stencil-align-to! m X RIGHT)
406 (def-markup-command (left-align layout props arg) (markup?)
407 "Align @var{arg} on its left edge. "
408 (let* ((m (interpret-markup layout props arg)))
409 (ly:stencil-align-to! m X LEFT)
412 (def-markup-command (general-align layout props axis dir arg) (integer? number? markup?)
413 "Align @var{arg} in @var{axis} direction to the @var{dir} side."
414 (let* ((m (interpret-markup layout props arg)))
415 (ly:stencil-align-to! m axis dir)
418 (def-markup-command (halign layout props dir arg) (number? markup?)
419 "Set horizontal alignment. If @var{dir} is @code{-1}, then it is
420 left-aligned, while @code{+1} is right. Values in between interpolate
421 alignment accordingly."
422 (let* ((m (interpret-markup layout props arg)))
423 (ly:stencil-align-to! m X dir)
426 (def-markup-command (musicglyph layout props glyph-name) (string?)
427 "This is converted to a musical symbol, e.g. @code{\\musicglyph
428 #\"accidentals.0\"} will select the natural sign from the music font.
429 See @usermanref{The Feta font} for a complete listing of the possible glyphs."
431 (ly:paper-get-font layout (cons '((font-encoding . fetaMusic))
435 (def-markup-command (lookup layout props glyph-name) (string?)
436 "Lookup a glyph by name."
437 (ly:font-get-glyph (ly:paper-get-font layout props)
440 (def-markup-command (char layout props num) (integer?)
441 "Produce a single character, e.g. @code{\\char #65} produces the
443 (ly:get-glyph (ly:paper-get-font layout props) num))
445 (def-markup-command (raise layout props amount arg) (number? markup?)
447 This raises @var{arg}, by the distance @var{amount}.
448 A negative @var{amount} indicates lowering:
450 @lilypond[verbatim,fragment,relative=1]
451 c1^\\markup { C \\small \\raise #1.0 \\bold { \"9/7+\" }}
453 The argument to @code{\\raise} is the vertical displacement amount,
454 measured in (global) staff spaces. @code{\\raise} and @code{\\super}
455 raise objects in relation to their surrounding markups.
457 If the text object itself is positioned above or below the staff, then
458 @code{\\raise} cannot be used to move it, since the mechanism that
459 positions it next to the staff cancels any shift made with
460 @code{\\raise}. For vertical positioning, use the @code{padding}
461 and/or @code{extra-offset} properties. "
462 (ly:stencil-translate-axis (interpret-markup layout props arg)
465 (def-markup-command (fraction layout props arg1 arg2) (markup? markup?)
466 "Make a fraction of two markups."
467 (let* ((m1 (interpret-markup layout props arg1))
468 (m2 (interpret-markup layout props arg2)))
469 (ly:stencil-align-to! m1 X CENTER)
470 (ly:stencil-align-to! m2 X CENTER)
471 (let* ((x1 (ly:stencil-extent m1 X))
472 (x2 (ly:stencil-extent m2 X))
473 (line (ly:round-filled-box (interval-union x1 x2) '(-0.05 . 0.05) 0.0))
474 ;; should stack mols separately, to maintain LINE on baseline
475 (stack (stack-lines -1 0.2 0.6 (list m1 line m2))))
476 (ly:stencil-align-to! stack Y CENTER)
477 (ly:stencil-align-to! stack X LEFT)
478 ;; should have EX dimension
480 (ly:stencil-translate-axis stack 0.75 Y))))
483 ;; TODO: better syntax.
485 (def-markup-command (note-by-number layout props log dot-count dir) (number? number? number?)
486 "Construct a note symbol, with stem. By using fractional values for
487 @var{dir}, you can obtain longer or shorter stems."
488 (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) props)))
489 (size (chain-assoc-get 'font-size props 0))
490 (stem-length (* (magstep size) (max 3 (- log 1))))
491 (head-glyph (ly:font-get-glyph
493 (string-append "noteheads.s" (number->string (min log 2)))))
494 (stem-thickness 0.13)
495 (stemy (* dir stem-length))
496 (attachx (if (> dir 0)
497 (- (cdr (ly:stencil-extent head-glyph X)) stem-thickness)
499 (attachy (* dir 0.28))
500 (stem-glyph (and (> log 0)
502 (cons attachx (+ attachx stem-thickness))
503 (cons (min stemy attachy)
505 (/ stem-thickness 3))))
506 (dot (ly:font-get-glyph font "dots.dot"))
507 (dotwid (interval-length (ly:stencil-extent dot X)))
508 (dots (and (> dot-count 0)
509 (apply ly:stencil-add
511 (ly:stencil-translate-axis
512 dot (* (+ 1 (* 2 x)) dotwid) X))
513 (iota dot-count 1)))))
514 (flaggl (and (> log 2)
515 (ly:stencil-translate
516 (ly:font-get-glyph font
517 (string-append "flags."
518 (if (> dir 0) "u" "d")
519 (number->string log)))
520 (cons (+ attachx (/ stem-thickness 2)) stemy)))))
522 (set! stem-glyph (ly:stencil-add flaggl stem-glyph)))
523 (if (ly:stencil? stem-glyph)
524 (set! stem-glyph (ly:stencil-add stem-glyph head-glyph))
525 (set! stem-glyph head-glyph))
526 (if (ly:stencil? dots)
529 (ly:stencil-translate-axis dots
530 (+ (if (and (> dir 0) (> log 2))
533 ;; huh ? why not necessary?
534 ;;(cdr (ly:stencil-extent head-glyph X))
540 (use-modules (ice-9 regex))
543 (let ((divisor (log 2)))
544 (lambda (z) (inexact->exact (/ (log z) divisor)))))
546 (define (parse-simple-duration duration-string)
547 "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a (log dots) list."
548 (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string)))
549 (if (and match (string=? duration-string (match:substring match 0)))
550 (let ((len (match:substring match 1))
551 (dots (match:substring match 2)))
552 (list (cond ((string=? len "breve") -1)
553 ((string=? len "longa") -2)
554 ((string=? len "maxima") -3)
555 (else (log2 (string->number len))))
556 (if dots (string-length dots) 0)))
557 (error "This is not a valid duration string:" duration-string))))
559 (def-markup-command (note layout props duration dir) (string? number?)
560 "This produces a note with a stem pointing in @var{dir} direction, with
561 the @var{duration} for the note head type and augmentation dots. For
562 example, @code{\\note #\"4.\" #-0.75} creates a dotted quarter note, with
563 a shortened down stem."
564 (let ((parsed (parse-simple-duration duration)))
565 (note-by-number-markup layout props (car parsed) (cadr parsed) dir)))
567 (def-markup-command (normal-size-super layout props arg) (markup?)
568 "Set @var{arg} in superscript with a normal font size."
569 (ly:stencil-translate-axis (interpret-markup
572 (* 0.5 (chain-assoc-get 'baseline-skip props))
575 (def-markup-command (super layout props arg) (markup?)
578 @cindex lowering text
580 @cindex translating text
582 @cindex @code{\\super}
585 Raising and lowering texts can be done with @code{\\super} and
588 @lilypond[verbatim,fragment,relative=1]
589 c1^\\markup { E \"=\" mc \\super \"2\" }
593 (ly:stencil-translate-axis
596 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
598 (* 0.5 (chain-assoc-get 'baseline-skip props))
601 (def-markup-command (translate layout props offset arg) (number-pair? markup?)
602 "This translates an object. Its first argument is a cons of numbers
604 A \\translate #(cons 2 -3) @{ B C @} D
606 This moves `B C' 2 spaces to the right, and 3 down, relative to its
607 surroundings. This command cannot be used to move isolated scripts
608 vertically, for the same reason that @code{\\raise} cannot be used for
612 (ly:stencil-translate (interpret-markup layout props arg)
615 (def-markup-command (sub layout props arg) (markup?)
616 "Set @var{arg} in subscript."
617 (ly:stencil-translate-axis
620 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
622 (* -0.5 (chain-assoc-get 'baseline-skip props))
625 (def-markup-command (beam layout props width slope thickness) (number? number? number?)
626 "Create a beam with the specified parameters."
630 (yext (cons (min 0 y) (max 0 y)))
631 (half (/ thickness 2)))
637 (ly:output-def-lookup layout 'blotdiameter))
639 (cons (+ (- half) (car yext))
640 (+ half (cdr yext))))
645 (def-markup-command (normal-size-sub layout props arg) (markup?)
646 "Set @var{arg} in subscript, in a normal font size."
647 (ly:stencil-translate-axis
648 (interpret-markup layout props arg)
649 (* -0.5 (chain-assoc-get 'baseline-skip props))
652 (def-markup-command (hbracket layout props arg) (markup?)
653 "Draw horizontal brackets around @var{arg}."
654 (let ((th 0.1) ;; todo: take from GROB.
655 (m (interpret-markup layout props arg)))
656 (bracketify-stencil m X th (* 2.5 th) th)))
658 (def-markup-command (bracket layout props arg) (markup?)
659 "Draw vertical brackets around @var{arg}."
660 (let ((th 0.1) ;; todo: take from GROB.
661 (m (interpret-markup layout props arg)))
662 (bracketify-stencil m Y th (* 2.5 th) th)))
664 ;; todo: fix negative space
665 (def-markup-command (hspace layout props amount) (number?)
666 "This produces a invisible object taking horizontal space.
668 \\markup @{ A \\hspace #2.0 B @}
670 will put extra space between A and B, on top of the space that is
671 normally inserted before elements on a line.
674 (ly:make-stencil "" (cons 0 amount) '(-1 . 1))
675 (ly:make-stencil "" (cons amount amount) '(-1 . 1))))
677 (def-markup-command (override layout props new-prop arg) (pair? markup?)
678 "Add the first argument in to the property list. Properties may be
679 any sort of property supported by @internalsref{font-interface} and
680 @internalsref{text-interface}, for example
683 \\override #'(font-family . married) \"bla\"
687 (interpret-markup layout (cons (list new-prop) props) arg))
690 (def-markup-command (fontsize layout props increment arg) (number? markup?)
691 "Add @var{increment} to the font-size. Adjust baseline skip accordingly."
693 (let* ((fs (chain-assoc-get 'font-size props 0))
694 (bs (chain-assoc-get 'baseline-skip props 2))
696 (cons 'baseline-skip (* bs (magstep increment)))
697 (cons 'font-size (+ fs increment )))))
699 (interpret-markup layout (cons entries props) arg)))
701 (def-markup-command (bigger layout props arg) (markup?)
702 "Increase the font size relative to current setting"
703 (interpret-markup layout props
704 `(,fontsize-markup 1 ,arg)))
706 (def-markup-command (smaller layout props arg) (markup?)
707 "Decrease the font size relative to current setting"
708 (interpret-markup layout props
709 `(,fontsize-markup -1 ,arg)))
711 (def-markup-command larger (markup?) bigger-markup)
713 (def-markup-command (box layout props arg) (markup?)
714 "Draw a box round @var{arg}. Looks at @code{thickness},
715 @code{box-padding} and @code{font-size} properties to determine line
716 thickness and padding around the markup."
717 (let* ((th (chain-assoc-get 'thickness props 0.1))
718 (size (chain-assoc-get 'font-size props 0))
721 (chain-assoc-get 'box-padding props 0.2)))
722 (m (interpret-markup layout props arg)))
723 (box-stencil m th pad)))
725 ;;FIXME: is this working?
726 (def-markup-command (strut layout props) ()
727 "Create a box of the same height as the space in the current font."
728 (let ((m (Text_interface::interpret_markup layout props " ")))
729 (ly:stencil-set-extent! m X '(1000 . -1000))
732 (define number->mark-letter-vector (make-vector 25 #\A))
737 (if (= i (- (char->integer #\I) (char->integer #\A)))
739 (vector-set! number->mark-letter-vector j
740 (integer->char (+ i (char->integer #\A)))))
742 (define number->mark-alphabet-vector (list->vector
743 (map (lambda (i) (integer->char (+ i (char->integer #\A)))) (iota 26))))
745 (define (number->markletter-string vec n)
746 "Double letters for big marks."
747 (let* ((lst (vector-length vec)))
750 (string-append (number->markletter-string vec (1- (quotient n lst)))
751 (number->markletter-string vec (remainder n lst)))
752 (make-string 1 (vector-ref vec n)))))
754 (def-markup-command (markletter layout props num) (integer?)
755 "Make a markup letter for @var{num}. The letters start with A to Z
756 (skipping I), and continues with double letters."
757 (Text_interface::interpret_markup layout props
758 (number->markletter-string number->mark-letter-vector num)))
760 (def-markup-command (markalphabet layout props num) (integer?)
761 "Make a markup letter for @var{num}. The letters start with A to Z
762 and continues with double letters."
763 (Text_interface::interpret_markup layout props
764 (number->markletter-string number->mark-alphabet-vector num)))
766 (def-markup-command (bracketed-y-column layout props indices args)
768 "Make a column of the markups in @var{args}, putting brackets around
769 the elements marked in @var{indices}, which is a list of numbers."
770 (define (sublist lst start stop)
771 (take (drop lst start) (- (1+ stop) start)))
773 (define (stencil-list-extent ss axis)
775 (apply min (map (lambda (x) (car (ly:stencil-extent x axis))) ss))
776 (apply max (map (lambda (x) (cdr (ly:stencil-extent x axis))) ss))))
778 (define (stack-stencils stencils bskip last-stencil)
780 ((null? stencils) '())
781 ((not (ly:stencil? last-stencil))
783 (stack-stencils (cdr stencils) bskip (car stencils))))
785 (let* ((orig (car stencils))
786 (dir (chain-assoc-get 'direction props DOWN))
787 (new (ly:stencil-moved-to-edge last-stencil Y dir
791 (cons new (stack-stencils (cdr stencils) bskip new))))))
793 (define (make-brackets stencils indices acc)
796 (pair? (cdr indices)))
797 (let* ((encl (sublist stencils (car indices) (cadr indices)))
798 (x-ext (stencil-list-extent encl X))
799 (y-ext (stencil-list-extent encl Y))
802 (protusion (* 2.5 thick))
804 (ly:stencil-translate-axis
805 (ly:bracket Y y-ext thick protusion)
806 (- (car x-ext) pad) X))
807 (rb (ly:stencil-translate-axis
808 (ly:bracket Y y-ext thick (- protusion))
809 (+ (cdr x-ext) pad) X)))
812 stencils (cddr indices)
825 (chain-assoc-get 'baseline-skip props))
826 (stacked (stack-stencils
827 (remove ly:stencil-empty? stencils) 1.25 #f))
828 (brackets (make-brackets stacked indices '())))
830 (apply ly:stencil-add
831 (append stacked brackets))))