1 ;;;; define-markup-commands.scm -- markup commands
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
10 ;;; * each markup function should have a doc string with
11 ;; syntax, description and example.
13 (use-modules (ice-9 regex))
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19 (define-public empty-stencil (ly:make-stencil '() '(1 . -1) '(1 . -1)))
20 (define-public point-stencil (ly:make-stencil "" '(0 . 0) '(0 . 0)))
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 (define-builtin-markup-command (draw-circle layout props radius thickness fill)
28 (number? number? boolean?)
29 "A circle of radius @var{radius}, thickness @var{thickness} and
31 (make-circle-stencil radius thickness fill))
33 (define-builtin-markup-command (triangle layout props filled) (boolean?)
34 "A triangle, filled or not"
36 ((th (chain-assoc-get 'thickness props 0.1))
37 (size (chain-assoc-get 'font-size props 0))
40 (chain-assoc-get 'baseline-skip props 2))))
54 (define-builtin-markup-command (circle layout props arg) (markup?)
55 "Draw a circle around @var{arg}. Use @code{thickness},
56 @code{circle-padding} and @code{font-size} properties to determine line
57 thickness and padding around the markup."
59 (let* ((th (chain-assoc-get 'thickness props 0.1))
60 (size (chain-assoc-get 'font-size props 0))
63 (chain-assoc-get 'circle-padding props 0.2)))
64 (m (interpret-markup layout props arg)))
65 (circle-stencil m th pad)))
67 (define-builtin-markup-command (with-url layout props url arg) (string? markup?)
68 "Add a link to URL @var{url} around @var{arg}. This only works in
70 (let* ((stil (interpret-markup layout props arg))
71 (xextent (ly:stencil-extent stil X))
72 (yextent (ly:stencil-extent stil Y))
73 (old-expr (ly:stencil-expr stil))
74 (url-expr (list 'url-link url `(quote ,xextent) `(quote ,yextent))))
75 (ly:stencil-add (ly:make-stencil url-expr xextent yextent) stil)))
78 (define-builtin-markup-command (beam layout props width slope thickness)
79 (number? number? number?)
80 "Create a beam with the specified parameters."
81 (let* ((y (* slope width))
82 (yext (cons (min 0 y) (max 0 y)))
83 (half (/ thickness 2)))
88 width (+ (* width slope) (/ thickness -2))
89 width (+ (* width slope) (/ thickness 2))
91 ,(ly:output-def-lookup layout 'blot-diameter)
94 (cons (+ (- half) (car yext))
95 (+ half (cdr yext))))))
97 (define-builtin-markup-command (box layout props arg) (markup?)
98 "Draw a box round @var{arg}. Looks at @code{thickness},
99 @code{box-padding} and @code{font-size} properties to determine line
100 thickness and padding around the markup."
102 (let* ((th (chain-assoc-get 'thickness props 0.1))
103 (size (chain-assoc-get 'font-size props 0))
104 (pad (* (magstep size)
105 (chain-assoc-get 'box-padding props 0.2)))
106 (m (interpret-markup layout props arg)))
107 (box-stencil m th pad)))
109 (define-builtin-markup-command (filled-box layout props xext yext blot)
110 (number-pair? number-pair? number?)
111 "Draw a box with rounded corners of dimensions @var{xext} and
112 @var{yext}. For example,
114 \\filled-box #'(-.3 . 1.8) #'(-.3 . 1.8) #0
116 create a box extending horizontally from -0.3 to 1.8 and
117 vertically from -0.3 up to 1.8, with corners formed from a
118 circle of diameter 0 (ie sharp corners)."
122 (define-builtin-markup-command (rotate layout props ang arg) (number? markup?)
123 "Rotate object with @var{ang} degrees around its center."
124 (let* ((stil (interpret-markup layout props arg)))
125 (ly:stencil-rotate stil ang 0 0)))
128 (define-builtin-markup-command (whiteout layout props arg) (markup?)
129 "Provide a white underground for @var{arg}"
130 (stencil-whiteout (interpret-markup layout props arg)))
132 (define-builtin-markup-command (pad-markup layout props padding arg) (number? markup?)
133 "Add space around a markup object."
136 ((stil (interpret-markup layout props arg))
137 (xext (ly:stencil-extent stil X))
138 (yext (ly:stencil-extent stil Y)))
141 (ly:stencil-expr stil)
142 (interval-widen xext padding)
143 (interval-widen yext padding))))
145 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
149 ;;FIXME: is this working?
150 (define-builtin-markup-command (strut layout props) ()
151 "Create a box of the same height as the space in the current font."
152 (let ((m (ly:text-interface::interpret-markup layout props " ")))
153 (ly:make-stencil (ly:stencil-expr m)
155 (ly:stencil-extent m X)
159 ;; todo: fix negative space
160 (define-builtin-markup-command (hspace layout props amount) (number?)
161 "This produces a invisible object taking horizontal space.
163 \\markup @{ A \\hspace #2.0 B @}
165 will put extra space between A and B, on top of the space that is
166 normally inserted before elements on a line.
169 (ly:make-stencil "" (cons 0 amount) '(-1 . 1))
170 (ly:make-stencil "" (cons amount amount) '(-1 . 1))))
173 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
174 ;; importing graphics.
175 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
177 (define-builtin-markup-command (stencil layout props stil) (ly:stencil?)
182 (make-regexp "%%BoundingBox:[ \t]+([0-9-]+)[ \t]+([0-9-]+)[ \t]+([0-9-]+)[ \t]+([0-9-]+)"))
184 (define (get-postscript-bbox string)
185 "Extract the bbox from STRING, or return #f if not present."
187 ((match (regexp-exec bbox-regexp string)))
191 (string->number (match:substring match x)))
196 (define-builtin-markup-command (epsfile layout props axis size file-name) (number? number? string?)
197 "Inline an EPS image. The image is scaled along @var{axis} to
200 (if (ly:get-option 'safe)
201 (interpret-markup layout props "not allowed in safe")
202 (eps-file->stencil axis size file-name)
205 (define-builtin-markup-command (postscript layout props str) (string?)
206 "This inserts @var{str} directly into the output as a PostScript
207 command string. Due to technicalities of the output backends,
208 different scales should be used for the @TeX{} and PostScript backend,
209 selected with @code{-f}.
212 For the TeX backend, the following string prints a rotated text
217 0 0 moveto /ecrm10 findfont
218 1.75 scalefont setfont 90 rotate (hello) show
222 The magical constant 1.75 scales from LilyPond units (staff spaces) to
225 For the postscript backend, use the following
228 gsave /ecrm10 findfont
229 10.0 output-scale div
230 scalefont setfont 90 rotate (hello) show grestore
238 gsave currentpoint translate
247 (define-builtin-markup-command (score layout props score) (ly:score?)
248 "Inline an image of music."
249 (let* ((output (ly:score-embedded-format score layout)))
251 (if (ly:music-output? output)
252 (paper-system-stencil
253 (vector-ref (ly:paper-score-paper-systems output) 0))
255 (ly:warning (_"no systems found in \\score markup, does it have a \\layout block?"))
258 (define-builtin-markup-command (null layout props) ()
259 "An empty markup with extents of a single point"
263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
265 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
269 (define-builtin-markup-command (simple layout props str) (string?)
270 "A simple text string; @code{\\markup @{ foo @}} is equivalent with
271 @code{\\markup @{ \\simple #\"foo\" @}}."
272 (interpret-markup layout props str))
274 (define-builtin-markup-command (tied-lyric layout props str) (string?)
276 "Like simple-markup, but use tie characters for ~ tilde symbols."
278 (if (string-contains str "~")
280 ((parts (string-split str #\~))
281 (tie-str (ly:wide-char->utf-8 #x203f))
282 (joined (list-join parts tie-str))
283 (join-stencil (interpret-markup layout props tie-str))
286 (interpret-markup layout
289 (/ (interval-length (ly:stencil-extent join-stencil X)) -3.5)
291 (make-line-markup joined)))
292 ;(map (lambda (s) (interpret-markup layout props s)) parts))
293 (interpret-markup layout props str)))
296 ;; TODO: use font recoding.
298 ;; (map make-word-markup (string-tokenize str)))))
300 (define-public empty-markup
301 (make-simple-markup ""))
303 ;; helper for justifying lines.
304 (define (get-fill-space word-count line-width text-widths)
305 "Calculate the necessary paddings between each two adjacent texts.
306 The lengths of all texts are stored in @var{text-widths}.
307 The normal formula for the padding between texts a and b is:
308 padding = line-width/(word-count - 1) - (length(a) + length(b))/2
309 The first and last padding have to be calculated specially using the
310 whole length of the first or last text.
311 Return a list of paddings.
314 ((null? text-widths) '())
316 ;; special case first padding
317 ((= (length text-widths) word-count)
319 (- (- (/ line-width (1- word-count)) (car text-widths))
320 (/ (car (cdr text-widths)) 2))
321 (get-fill-space word-count line-width (cdr text-widths))))
322 ;; special case last padding
323 ((= (length text-widths) 2)
324 (list (- (/ line-width (1- word-count))
325 (+ (/ (car text-widths) 2) (car (cdr text-widths)))) 0))
328 (- (/ line-width (1- word-count))
329 (/ (+ (car text-widths) (car (cdr text-widths))) 2))
330 (get-fill-space word-count line-width (cdr text-widths))))))
332 (define-builtin-markup-command (fill-line layout props markups)
334 "Put @var{markups} in a horizontal line of width @var{line-width}.
335 The markups are spaced/flushed to fill the entire line.
336 If there are no arguments, return an empty stencil."
338 (let* ((orig-stencils
339 (map (lambda (x) (interpret-markup layout props x))
343 (if (ly:stencil-empty? stc)
345 stc)) orig-stencils))
348 (if (ly:stencil-empty? stc)
350 (interval-length (ly:stencil-extent stc X))))
352 (text-width (apply + text-widths))
353 (text-dir (chain-assoc-get 'text-direction props RIGHT))
354 (word-count (length stencils))
355 (word-space (chain-assoc-get 'word-space props 1))
356 (prop-line-width (chain-assoc-get 'line-width props #f))
357 (line-width (if prop-line-width prop-line-width
358 (ly:output-def-lookup layout 'line-width)))
363 (/ (- line-width text-width) 2)
364 (/ (- line-width text-width) 2)))
367 (- line-width text-width)))
369 (get-fill-space word-count line-width text-widths))))
377 (line-stencils (if (= word-count 1)
384 (if (= text-dir LEFT)
385 (set! line-stencils (reverse line-stencils)))
387 (if (null? (remove ly:stencil-empty? orig-stencils))
389 (stack-stencils-padding-list X
390 RIGHT fill-space-normal line-stencils))))
392 (define-builtin-markup-command (line layout props args) (markup-list?)
393 "Put @var{args} in a horizontal line. The property @code{word-space}
394 determines the space between each markup in @var{args}."
396 ((stencils (map (lambda (m) (interpret-markup layout props m)) args))
397 (space (chain-assoc-get 'word-space props))
398 (text-dir (chain-assoc-get 'text-direction props RIGHT))
401 (if (= text-dir LEFT)
402 (set! stencils (reverse stencils)))
407 (remove ly:stencil-empty? stencils))))
409 (define-builtin-markup-command (concat layout props args) (markup-list?)
410 "Concatenate @var{args} in a horizontal line, without spaces inbetween.
411 Strings and simple markups are concatenated on the input level, allowing
412 ligatures. For example, @code{\\concat @{ \"f\" \\simple #\"i\" @}} is
413 equivalent to @code{\"fi\"}."
415 (define (concat-string-args arg-list)
416 (fold-right (lambda (arg result-list)
417 (let ((result (if (pair? result-list)
420 (if (and (pair? arg) (eqv? (car arg) simple-markup))
421 (set! arg (cadr arg)))
422 (if (and (string? result) (string? arg))
423 (cons (string-append arg result) (cdr result-list))
424 (cons arg result-list))))
428 (interpret-markup layout
429 (prepend-alist-chain 'word-space 0 props)
430 (make-line-markup (concat-string-args args))))
432 (define (wordwrap-stencils stencils
433 justify base-space line-width text-dir)
435 "Perform simple wordwrap, return stencil of each line."
437 (define space (if justify
439 ;; justify only stretches lines.
443 (define (take-list width space stencils
444 accumulator accumulated-width)
445 "Return (head-list . tail) pair, with head-list fitting into width"
447 (cons accumulator stencils)
449 ((first (car stencils))
450 (first-wid (cdr (ly:stencil-extent (car stencils) X)))
451 (newwid (+ space first-wid accumulated-width))
455 (or (null? accumulator)
458 (take-list width space
460 (cons first accumulator)
462 (cons accumulator stencils))
470 ((line-break (take-list line-width space todo
472 (line-stencils (car line-break))
473 (space-left (- line-width (apply + (map (lambda (x) (cdr (ly:stencil-extent x X)))
476 (line-word-space (cond
477 ((not justify) space)
479 ;; don't stretch last line of paragraph.
480 ;; hmmm . bug - will overstretch the last line in some case.
481 ((null? (cdr line-break))
483 ((null? line-stencils) 0.0)
484 ((null? (cdr line-stencils)) 0.0)
485 (else (/ space-left (1- (length line-stencils))))))
487 (line (stack-stencil-line
489 (if (= text-dir RIGHT)
490 (reverse line-stencils)
493 (if (pair? (cdr line-break))
494 (loop (cons line lines)
498 (if (= text-dir LEFT)
500 (ly:stencil-translate-axis line
501 (- line-width (interval-end (ly:stencil-extent line X)))
503 (reverse (cons line lines))
510 (define (wordwrap-markups layout props args justify)
512 ((baseline-skip (chain-assoc-get 'baseline-skip props))
513 (prop-line-width (chain-assoc-get 'line-width props #f))
514 (line-width (if prop-line-width prop-line-width
515 (ly:output-def-lookup layout 'line-width)))
516 (word-space (chain-assoc-get 'word-space props))
517 (text-dir (chain-assoc-get 'text-direction props RIGHT))
518 (lines (wordwrap-stencils
519 (remove ly:stencil-empty?
520 (map (lambda (m) (interpret-markup layout props m)) args))
521 justify word-space line-width
525 (stack-lines DOWN 0.0 baseline-skip lines)))
527 (define-builtin-markup-command (justify layout props args) (markup-list?)
528 "Like wordwrap, but with lines stretched to justify the margins.
529 Use @code{\\override #'(line-width . X)} to set line-width, where X
530 is the number of staff spaces."
532 (wordwrap-markups layout props args #t))
534 (define-builtin-markup-command (wordwrap layout props args) (markup-list?)
535 "Simple wordwrap. Use @code{\\override #'(line-width . X)} to set
536 line-width, where X is the number of staff spaces."
538 (wordwrap-markups layout props args #f))
540 (define (wordwrap-string layout props justify arg)
542 ((baseline-skip (chain-assoc-get 'baseline-skip props))
543 (line-width (chain-assoc-get 'line-width props))
544 (word-space (chain-assoc-get 'word-space props))
546 (para-strings (regexp-split
547 (string-regexp-substitute "\r" "\n"
548 (string-regexp-substitute "\r\n" "\n" arg))
549 "\n[ \t\n]*\n[ \t\n]*"))
551 (text-dir (chain-assoc-get 'text-direction props RIGHT))
552 (list-para-words (map (lambda (str)
553 (regexp-split str "[ \t\n]+"))
555 (para-lines (map (lambda (words)
559 ly:stencil-empty? (map
561 (interpret-markup layout props x))
563 (lines (wordwrap-stencils stencils
572 (stack-lines DOWN 0.0 baseline-skip (apply append para-lines))))
575 (define-builtin-markup-command (wordwrap-string layout props arg) (string?)
576 "Wordwrap a string. Paragraphs may be separated with double newlines"
577 (wordwrap-string layout props #f arg))
579 (define-builtin-markup-command (justify-string layout props arg) (string?)
580 "Justify a string. Paragraphs may be separated with double newlines"
581 (wordwrap-string layout props #t arg))
584 (define-builtin-markup-command (wordwrap-field layout props symbol) (symbol?)
585 (let* ((m (chain-assoc-get symbol props)))
587 (interpret-markup layout props
588 (list wordwrap-string-markup m))
589 (ly:make-stencil '() '(1 . -1) '(1 . -1)))))
591 (define-builtin-markup-command (justify-field layout props symbol) (symbol?)
592 (let* ((m (chain-assoc-get symbol props)))
594 (interpret-markup layout props
595 (list justify-string-markup m))
596 (ly:make-stencil '() '(1 . -1) '(1 . -1)))))
600 (define-builtin-markup-command (combine layout props m1 m2) (markup? markup?)
601 "Print two markups on top of each other."
602 (let* ((s1 (interpret-markup layout props m1))
603 (s2 (interpret-markup layout props m2)))
604 (ly:stencil-add s1 s2)))
607 ;; TODO: should extract baseline-skip from each argument somehow..
609 (define-builtin-markup-command (column layout props args) (markup-list?)
610 "Stack the markups in @var{args} vertically. The property
611 @code{baseline-skip} determines the space between each markup in @var{args}."
614 ((arg-stencils (map (lambda (m) (interpret-markup layout props m)) args))
615 (skip (chain-assoc-get 'baseline-skip props)))
620 (remove ly:stencil-empty? arg-stencils))))
623 (define-builtin-markup-command (dir-column layout props args) (markup-list?)
624 "Make a column of args, going up or down, depending on the setting
625 of the @code{#'direction} layout property."
626 (let* ((dir (chain-assoc-get 'direction props)))
628 (if (number? dir) dir -1)
630 (chain-assoc-get 'baseline-skip props)
631 (map (lambda (x) (interpret-markup layout props x)) args))))
633 (define-builtin-markup-command (center-align layout props args) (markup-list?)
634 "Put @code{args} in a centered column. "
635 (let* ((mols (map (lambda (x) (interpret-markup layout props x)) args))
636 (cmols (map (lambda (x) (ly:stencil-aligned-to x X CENTER)) mols)))
638 (stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) cmols)))
640 (define-builtin-markup-command (vcenter layout props arg) (markup?)
641 "Align @code{arg} to its Y center. "
642 (let* ((mol (interpret-markup layout props arg)))
643 (ly:stencil-aligned-to mol Y CENTER)))
645 (define-builtin-markup-command (hcenter layout props arg) (markup?)
646 "Align @code{arg} to its X center. "
647 (let* ((mol (interpret-markup layout props arg)))
648 (ly:stencil-aligned-to mol X CENTER)))
650 (define-builtin-markup-command (right-align layout props arg) (markup?)
651 "Align @var{arg} on its right edge. "
652 (let* ((m (interpret-markup layout props arg)))
653 (ly:stencil-aligned-to m X RIGHT)))
655 (define-builtin-markup-command (left-align layout props arg) (markup?)
656 "Align @var{arg} on its left edge. "
657 (let* ((m (interpret-markup layout props arg)))
658 (ly:stencil-aligned-to m X LEFT)))
660 (define-builtin-markup-command (general-align layout props axis dir arg) (integer? number? markup?)
661 "Align @var{arg} in @var{axis} direction to the @var{dir} side."
662 (let* ((m (interpret-markup layout props arg)))
663 (ly:stencil-aligned-to m axis dir)))
665 (define-builtin-markup-command (halign layout props dir arg) (number? markup?)
666 "Set horizontal alignment. If @var{dir} is @code{-1}, then it is
667 left-aligned, while @code{+1} is right. Values in between interpolate
668 alignment accordingly."
669 (let* ((m (interpret-markup layout props arg)))
670 (ly:stencil-aligned-to m X dir)))
674 (define-builtin-markup-command (with-dimensions layout props x y arg) (number-pair? number-pair? markup?)
675 "Set the dimensions of @var{arg} to @var{x} and @var{y}."
677 (let* ((m (interpret-markup layout props arg)))
678 (ly:make-stencil (ly:stencil-expr m) x y)))
681 (define-builtin-markup-command (pad-around layout props amount arg) (number? markup?)
683 "Add padding @var{amount} all around @var{arg}. "
686 ((m (interpret-markup layout props arg))
687 (x (ly:stencil-extent m X))
688 (y (ly:stencil-extent m Y)))
691 (ly:make-stencil (ly:stencil-expr m)
692 (interval-widen x amount)
693 (interval-widen y amount))
697 (define-builtin-markup-command (pad-x layout props amount arg) (number? markup?)
699 "Add padding @var{amount} around @var{arg} in the X-direction. "
701 ((m (interpret-markup layout props arg))
702 (x (ly:stencil-extent m X))
703 (y (ly:stencil-extent m Y)))
706 (ly:make-stencil (ly:stencil-expr m)
707 (interval-widen x amount)
712 (define-builtin-markup-command (put-adjacent layout props arg1 axis dir arg2) (markup? integer? ly:dir? markup?)
714 "Put @var{arg2} next to @var{arg1}, without moving @var{arg1}. "
716 (let* ((m1 (interpret-markup layout props arg1))
717 (m2 (interpret-markup layout props arg2)))
719 (ly:stencil-combine-at-edge m1 axis dir m2 0.0)
722 (define-builtin-markup-command (transparent layout props arg) (markup?)
723 "Make the argument transparent"
725 ((m (interpret-markup layout props arg))
726 (x (ly:stencil-extent m X))
727 (y (ly:stencil-extent m Y)))
735 (define-builtin-markup-command (pad-to-box layout props x-ext y-ext arg)
736 (number-pair? number-pair? markup?)
737 "Make @var{arg} take at least @var{x-ext}, @var{y-ext} space"
740 ((m (interpret-markup layout props arg))
741 (x (ly:stencil-extent m X))
742 (y (ly:stencil-extent m Y)))
744 (ly:make-stencil (ly:stencil-expr m)
745 (interval-union x-ext x)
746 (interval-union y-ext y))))
749 (define-builtin-markup-command (hcenter-in layout props length arg)
751 "Center @var{arg} horizontally within a box of extending
752 @var{length}/2 to the left and right."
754 (interpret-markup layout props
755 (make-pad-to-box-markup
756 (cons (/ length -2) (/ length 2))
758 (make-hcenter-markup arg))))
761 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
763 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
765 (define-builtin-markup-command (fromproperty layout props symbol) (symbol?)
766 "Read the @var{symbol} from property settings, and produce a stencil
767 from the markup contained within. If @var{symbol} is not defined, it
768 returns an empty markup"
769 (let* ((m (chain-assoc-get symbol props)))
771 (interpret-markup layout props m)
772 (ly:make-stencil '() '(1 . -1) '(1 . -1)))))
775 (define-builtin-markup-command (on-the-fly layout props procedure arg) (symbol? markup?)
776 "Apply the @var{procedure} markup command to
777 @var{arg}. @var{procedure} should take a single argument."
778 (let* ((anonymous-with-signature (lambda (layout props arg) (procedure layout props arg))))
779 (set-object-property! anonymous-with-signature
782 (interpret-markup layout props (list anonymous-with-signature arg))))
786 (define-builtin-markup-command (override layout props new-prop arg) (pair? markup?)
787 "Add the first argument in to the property list. Properties may be
788 any sort of property supported by @internalsref{font-interface} and
789 @internalsref{text-interface}, for example
792 \\override #'(font-family . married) \"bla\"
796 (interpret-markup layout (cons (list new-prop) props) arg))
798 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
800 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
802 (define-builtin-markup-command (verbatim-file layout props name) (string?)
803 "Read the contents of a file, and include verbatimly"
807 (if (ly:get-option 'safe)
808 "verbatim-file disabled in safe mode"
810 ((str (ly:gulp-file name))
811 (lines (string-split str #\nl)))
813 (make-typewriter-markup
814 (make-column-markup lines)))
817 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
819 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
822 (define-builtin-markup-command (bigger layout props arg) (markup?)
823 "Increase the font size relative to current setting"
824 (interpret-markup layout props
825 `(,fontsize-markup 1 ,arg)))
827 (define-builtin-markup-command (smaller layout props arg) (markup?)
828 "Decrease the font size relative to current setting"
829 (interpret-markup layout props
830 `(,fontsize-markup -1 ,arg)))
832 (define-builtin-markup-command larger (markup?) bigger-markup)
834 (define-builtin-markup-command (finger layout props arg) (markup?)
835 "Set the argument as small numbers."
836 (interpret-markup layout
837 (cons '((font-size . -5) (font-encoding . fetaNumber)) props)
841 (define-builtin-markup-command (fontsize layout props increment arg) (number? markup?)
842 "Add @var{increment} to the font-size. Adjust baseline skip accordingly."
844 (let* ((fs (chain-assoc-get 'font-size props 0))
845 (bs (chain-assoc-get 'baseline-skip props 2))
847 (cons 'baseline-skip (* bs (magstep increment)))
848 (cons 'font-size (+ fs increment )))))
850 (interpret-markup layout (cons entries props) arg)))
854 ;; FIXME -> should convert to font-size.
855 (define-builtin-markup-command (magnify layout props sz arg) (number? markup?)
856 "Set the font magnification for the its argument. In the following
857 example, the middle A will be 10% larger:
859 A \\magnify #1.1 @{ A @} A
862 Note: magnification only works if a font-name is explicitly selected.
863 Use @code{\\fontsize} otherwise."
866 (prepend-alist-chain 'font-magnification sz props)
869 (define-builtin-markup-command (bold layout props arg) (markup?)
870 "Switch to bold font-series"
871 (interpret-markup layout (prepend-alist-chain 'font-series 'bold props) arg))
873 (define-builtin-markup-command (sans layout props arg) (markup?)
874 "Switch to the sans serif family"
875 (interpret-markup layout (prepend-alist-chain 'font-family 'sans props) arg))
877 (define-builtin-markup-command (number layout props arg) (markup?)
878 "Set font family to @code{number}, which yields the font used for
879 time signatures and fingerings. This font only contains numbers and
880 some punctuation. It doesn't have any letters. "
881 (interpret-markup layout (prepend-alist-chain 'font-encoding 'fetaNumber props) arg))
883 (define-builtin-markup-command (roman layout props arg) (markup?)
884 "Set font family to @code{roman}."
885 (interpret-markup layout (prepend-alist-chain 'font-family 'roman props) arg))
887 (define-builtin-markup-command (huge layout props arg) (markup?)
888 "Set font size to +2."
889 (interpret-markup layout (prepend-alist-chain 'font-size 2 props) arg))
891 (define-builtin-markup-command (large layout props arg) (markup?)
892 "Set font size to +1."
893 (interpret-markup layout (prepend-alist-chain 'font-size 1 props) arg))
895 (define-builtin-markup-command (normalsize layout props arg) (markup?)
896 "Set font size to default."
897 (interpret-markup layout (prepend-alist-chain 'font-size 0 props) arg))
899 (define-builtin-markup-command (small layout props arg) (markup?)
900 "Set font size to -1."
901 (interpret-markup layout (prepend-alist-chain 'font-size -1 props) arg))
903 (define-builtin-markup-command (tiny layout props arg) (markup?)
904 "Set font size to -2."
905 (interpret-markup layout (prepend-alist-chain 'font-size -2 props) arg))
907 (define-builtin-markup-command (teeny layout props arg) (markup?)
908 "Set font size to -3."
909 (interpret-markup layout (prepend-alist-chain 'font-size -3 props) arg))
911 (define-builtin-markup-command (fontCaps layout props arg) (markup?)
912 "Set @code{font-shape} to @code{caps}."
913 (interpret-markup layout (prepend-alist-chain 'font-shape 'caps props) arg))
916 (define-builtin-markup-command (smallCaps layout props text) (markup?)
917 "Turn @code{text}, which should be a string, to small caps.
919 \\markup \\smallCaps \"Text between double quotes\"
922 (define (make-small-caps-markup chars)
925 ((char-whitespace? (car chars))
926 (markup #:fontsize -2 #:simple (string-upcase (list->string (cdr chars)))))
929 #:fontsize -2 #:simple (string-upcase (list->string chars))))))
930 (define (make-not-small-caps-markup chars)
933 ((char-whitespace? (car chars))
934 (markup #:simple (list->string (cdr chars))))
937 #:simple (list->string chars)))))
938 (define (small-caps-aux done-markups current-chars rest-chars small? after-space?)
939 (cond ((null? rest-chars)
940 ;; the end of the string: build the markup
941 (make-line-markup (reverse! (cons ((if small?
942 make-small-caps-markup
943 make-not-small-caps-markup)
944 (reverse! current-chars))
946 ((char-whitespace? (car rest-chars))
948 (small-caps-aux done-markups current-chars (cdr rest-chars) small? #t))
949 ((or (and small? (char-lower-case? (car rest-chars)))
950 (and (not small?) (not (char-lower-case? (car rest-chars)))))
952 ;; add the char to the current char list
953 (small-caps-aux done-markups
954 (cons (car rest-chars)
956 (cons #\space current-chars)
963 ;; make a markup with current chars, and start a new list with new char
964 (small-caps-aux (cons ((if small?
965 make-small-caps-markup
966 make-not-small-caps-markup)
967 (reverse! current-chars))
970 (list (car rest-chars) #\space)
971 (list (car rest-chars)))
975 (interpret-markup layout props (small-caps-aux (list)
977 (cons #\space (string->list text))
981 (define-builtin-markup-command (caps layout props arg) (markup?)
982 (interpret-markup layout props (make-smallCaps-markup arg)))
984 (define-builtin-markup-command (dynamic layout props arg) (markup?)
985 "Use the dynamic font. This font only contains @b{s}, @b{f}, @b{m},
986 @b{z}, @b{p}, and @b{r}. When producing phrases, like ``pi@`{u} @b{f}'', the
987 normal words (like ``pi@`{u}'') should be done in a different font. The
988 recommend font for this is bold and italic"
990 layout (prepend-alist-chain 'font-encoding 'fetaDynamic props) arg))
992 (define-builtin-markup-command (text layout props arg) (markup?)
993 "Use a text font instead of music symbol or music alphabet font."
996 (interpret-markup layout (prepend-alist-chain 'font-encoding 'latin1 props)
1000 (define-builtin-markup-command (italic layout props arg) (markup?)
1001 "Use italic @code{font-shape} for @var{arg}. "
1002 (interpret-markup layout (prepend-alist-chain 'font-shape 'italic props) arg))
1004 (define-builtin-markup-command (typewriter layout props arg) (markup?)
1005 "Use @code{font-family} typewriter for @var{arg}."
1007 layout (prepend-alist-chain 'font-family 'typewriter props) arg))
1009 (define-builtin-markup-command (upright layout props arg) (markup?)
1010 "Set font shape to @code{upright}. This is the opposite of @code{italic}."
1012 layout (prepend-alist-chain 'font-shape 'upright props) arg))
1014 (define-builtin-markup-command (medium layout props arg) (markup?)
1015 "Switch to medium font-series (in contrast to bold)."
1016 (interpret-markup layout (prepend-alist-chain 'font-series 'medium props)
1019 (define-builtin-markup-command (normal-text layout props arg) (markup?)
1020 "Set all font related properties (except the size) to get the default normal text font, no matter what font was used earlier."
1022 (interpret-markup layout
1023 (cons '((font-family . roman) (font-shape . upright)
1024 (font-series . medium) (font-encoding . latin1))
1028 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1030 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1032 (define-builtin-markup-command (doublesharp layout props) ()
1033 "Draw a double sharp symbol."
1035 (interpret-markup layout props (markup #:musicglyph (assoc-get 1 standard-alteration-glyph-name-alist ""))))
1037 (define-builtin-markup-command (sesquisharp layout props) ()
1038 "Draw a 3/2 sharp symbol."
1039 (interpret-markup layout props (markup #:musicglyph (assoc-get 3/4 standard-alteration-glyph-name-alist ""))))
1042 (define-builtin-markup-command (sharp layout props) ()
1043 "Draw a sharp symbol."
1044 (interpret-markup layout props (markup #:musicglyph (assoc-get 1/2 standard-alteration-glyph-name-alist ""))))
1046 (define-builtin-markup-command (semisharp layout props) ()
1047 "Draw a semi sharp symbol."
1048 (interpret-markup layout props (markup #:musicglyph (assoc-get 1/4 standard-alteration-glyph-name-alist ""))))
1050 (define-builtin-markup-command (natural layout props) ()
1051 "Draw a natural symbol."
1052 (interpret-markup layout props (markup #:musicglyph (assoc-get 0 standard-alteration-glyph-name-alist ""))))
1054 (define-builtin-markup-command (semiflat layout props) ()
1056 (interpret-markup layout props (markup #:musicglyph (assoc-get -1/4 standard-alteration-glyph-name-alist ""))))
1058 (define-builtin-markup-command (flat layout props) ()
1059 "Draw a flat symbol."
1060 (interpret-markup layout props (markup #:musicglyph (assoc-get -1/2 standard-alteration-glyph-name-alist ""))))
1062 (define-builtin-markup-command (sesquiflat layout props) ()
1063 "Draw a 3/2 flat symbol."
1064 (interpret-markup layout props (markup #:musicglyph (assoc-get -3/4 standard-alteration-glyph-name-alist ""))))
1066 (define-builtin-markup-command (doubleflat layout props) ()
1067 "Draw a double flat symbol."
1068 (interpret-markup layout props (markup #:musicglyph (assoc-get -1 standard-alteration-glyph-name-alist ""))))
1070 (define-builtin-markup-command (with-color layout props color arg) (color? markup?)
1071 "Draw @var{arg} in color specified by @var{color}"
1073 (let* ((stil (interpret-markup layout props arg)))
1075 (ly:make-stencil (list 'color color (ly:stencil-expr stil))
1076 (ly:stencil-extent stil X)
1077 (ly:stencil-extent stil Y))))
1080 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1082 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1085 (define-builtin-markup-command (arrow-head layout props axis direction filled)
1086 (integer? ly:dir? boolean?)
1087 "produce an arrow head in specified direction and axis. Use the filled head if @var{filled} is specified."
1089 ((name (format "arrowheads.~a.~a~a"
1096 (ly:paper-get-font layout (cons '((font-encoding . fetaMusic))
1100 (define-builtin-markup-command (musicglyph layout props glyph-name) (string?)
1101 "This is converted to a musical symbol, e.g. @code{\\musicglyph
1102 #\"accidentals.natural\"} will select the natural sign from the music font.
1103 See @usermanref{The Feta font} for a complete listing of the possible glyphs."
1105 (ly:paper-get-font layout (cons '((font-encoding . fetaMusic))
1109 (define-builtin-markup-command (lookup layout props glyph-name) (string?)
1110 "Lookup a glyph by name."
1111 (ly:font-get-glyph (ly:paper-get-font layout props)
1114 (define-builtin-markup-command (char layout props num) (integer?)
1115 "Produce a single character, e.g. @code{\\char #65} produces the
1118 (ly:text-interface::interpret-markup layout props (ly:wide-char->utf-8 num)))
1120 (define number->mark-letter-vector (make-vector 25 #\A))
1125 (if (= i (- (char->integer #\I) (char->integer #\A)))
1127 (vector-set! number->mark-letter-vector j
1128 (integer->char (+ i (char->integer #\A)))))
1130 (define number->mark-alphabet-vector (list->vector
1131 (map (lambda (i) (integer->char (+ i (char->integer #\A)))) (iota 26))))
1133 (define (number->markletter-string vec n)
1134 "Double letters for big marks."
1135 (let* ((lst (vector-length vec)))
1138 (string-append (number->markletter-string vec (1- (quotient n lst)))
1139 (number->markletter-string vec (remainder n lst)))
1140 (make-string 1 (vector-ref vec n)))))
1142 (define-builtin-markup-command (markletter layout props num) (integer?)
1143 "Make a markup letter for @var{num}. The letters start with A to Z
1144 (skipping I), and continues with double letters."
1145 (ly:text-interface::interpret-markup layout props
1146 (number->markletter-string number->mark-letter-vector num)))
1148 (define-builtin-markup-command (markalphabet layout props num) (integer?)
1149 "Make a markup letter for @var{num}. The letters start with A to Z
1150 and continues with double letters."
1151 (ly:text-interface::interpret-markup layout props
1152 (number->markletter-string number->mark-alphabet-vector num)))
1156 (define-builtin-markup-command (slashed-digit layout props num) (integer?)
1157 "A feta number, with slash. This is for use in the context of
1158 figured bass notation"
1160 ((mag (magstep (chain-assoc-get 'font-size props 0)))
1163 (chain-assoc-get 'thickness props 0.16)))
1165 (number-stencil (interpret-markup layout
1166 (prepend-alist-chain 'font-encoding 'fetaNumber props)
1167 (number->string num)))
1168 (num-x (interval-widen (ly:stencil-extent number-stencil X)
1170 (num-y (ly:stencil-extent number-stencil Y))
1171 (is-sane (and (interval-sane? num-x) (interval-sane? num-y)))
1178 ,(car num-x) ,(- (interval-center num-y) dy)
1179 ,(cdr num-x) ,(+ (interval-center num-y) dy))
1185 ((not (ly:stencil? slash-stencil)) #f)
1186 ((= num 5) (ly:stencil-translate slash-stencil
1187 ;;(cons (* mag -0.05) (* mag 0.42))
1188 (cons (* mag -0.00) (* mag -0.07))
1191 ((= num 7) (ly:stencil-translate slash-stencil
1192 ;;(cons (* mag -0.05) (* mag 0.42))
1193 (cons (* mag -0.00) (* mag -0.15))
1197 (else slash-stencil)))
1200 (set! number-stencil
1201 (ly:stencil-add number-stencil slash-stencil))
1203 (ly:warning "invalid number for slashed digit ~a" num))
1208 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1209 ;; the note command.
1210 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1213 ;; TODO: better syntax.
1215 (define-builtin-markup-command (note-by-number layout props log dot-count dir) (number? number? number?)
1216 "Construct a note symbol, with stem. By using fractional values for
1217 @var{dir}, you can obtain longer or shorter stems."
1219 (define (get-glyph-name-candidates dir log style)
1220 (map (lambda (dir-name)
1221 (format "noteheads.~a~a~a" dir-name (min log 2)
1222 (if (and (symbol? style)
1223 (not (equal? 'default style)))
1224 (symbol->string style)
1226 (list (if (= dir UP) "u" "d")
1229 (define (get-glyph-name font cands)
1232 (if (ly:stencil-empty? (ly:font-get-glyph font (car cands)))
1233 (get-glyph-name font (cdr cands))
1236 (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) props)))
1237 (size-factor (magstep (chain-assoc-get 'font-size props 0)))
1238 (style (chain-assoc-get 'style props '()))
1239 (stem-length (* size-factor (max 3 (- log 1))))
1240 (head-glyph-name (get-glyph-name font (get-glyph-name-candidates (sign dir) log style)))
1241 (head-glyph (ly:font-get-glyph font head-glyph-name))
1242 (attach-indices (ly:note-head::stem-attachment font head-glyph-name))
1243 (stem-thickness (* size-factor 0.13))
1244 (stemy (* dir stem-length))
1245 (attach-off (cons (interval-index
1246 (ly:stencil-extent head-glyph X)
1247 (* (sign dir) (car attach-indices)))
1248 (* (sign dir) ; fixme, this is inconsistent between X & Y.
1250 (ly:stencil-extent head-glyph Y)
1251 (cdr attach-indices)))))
1252 (stem-glyph (and (> log 0)
1253 (ly:round-filled-box
1254 (ordered-cons (car attach-off)
1255 (+ (car attach-off) (* (- (sign dir)) stem-thickness)))
1256 (cons (min stemy (cdr attach-off))
1257 (max stemy (cdr attach-off)))
1258 (/ stem-thickness 3))))
1260 (dot (ly:font-get-glyph font "dots.dot"))
1261 (dotwid (interval-length (ly:stencil-extent dot X)))
1262 (dots (and (> dot-count 0)
1263 (apply ly:stencil-add
1265 (ly:stencil-translate-axis
1266 dot (* 2 x dotwid) X))
1267 (iota dot-count)))))
1268 (flaggl (and (> log 2)
1269 (ly:stencil-translate
1270 (ly:font-get-glyph font
1271 (string-append "flags."
1272 (if (> dir 0) "u" "d")
1273 (number->string log)))
1274 (cons (+ (car attach-off) (/ stem-thickness 2)) stemy)))))
1276 (if (and dots flaggl (> dir 0))
1277 (set! dots (ly:stencil-translate-axis dots 0.35 X)))
1279 (set! stem-glyph (ly:stencil-add flaggl stem-glyph)))
1280 (if (ly:stencil? stem-glyph)
1281 (set! stem-glyph (ly:stencil-add stem-glyph head-glyph))
1282 (set! stem-glyph head-glyph))
1283 (if (ly:stencil? dots)
1286 (ly:stencil-translate-axis
1288 (+ (cdr (ly:stencil-extent head-glyph X)) dotwid)
1294 (let ((divisor (log 2)))
1295 (lambda (z) (inexact->exact (/ (log z) divisor)))))
1297 (define (parse-simple-duration duration-string)
1298 "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a (log dots) list."
1299 (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string)))
1300 (if (and match (string=? duration-string (match:substring match 0)))
1301 (let ((len (match:substring match 1))
1302 (dots (match:substring match 2)))
1303 (list (cond ((string=? len "breve") -1)
1304 ((string=? len "longa") -2)
1305 ((string=? len "maxima") -3)
1306 (else (log2 (string->number len))))
1307 (if dots (string-length dots) 0)))
1308 (ly:error (_ "not a valid duration string: ~a") duration-string))))
1310 (define-builtin-markup-command (note layout props duration dir) (string? number?)
1311 "This produces a note with a stem pointing in @var{dir} direction, with
1312 the @var{duration} for the note head type and augmentation dots. For
1313 example, @code{\\note #\"4.\" #-0.75} creates a dotted quarter note, with
1314 a shortened down stem."
1315 (let ((parsed (parse-simple-duration duration)))
1316 (note-by-number-markup layout props (car parsed) (cadr parsed) dir)))
1319 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1321 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1323 (define-builtin-markup-command (lower layout props amount arg) (number? markup?)
1325 Lower @var{arg}, by the distance @var{amount}.
1326 A negative @var{amount} indicates raising, see also @code{\\raise}.
1328 (ly:stencil-translate-axis (interpret-markup layout props arg)
1332 (define-builtin-markup-command (translate-scaled layout props offset arg) (number-pair? markup?)
1333 "Translate @var{arg} by @var{offset}, scaling the offset by the @code{font-size}."
1336 ((factor (magstep (chain-assoc-get 'font-size props 0)))
1337 (scaled (cons (* factor (car offset))
1338 (* factor (cdr offset)))))
1340 (ly:stencil-translate (interpret-markup layout props arg)
1343 (define-builtin-markup-command (raise layout props amount arg) (number? markup?)
1345 Raise @var{arg}, by the distance @var{amount}.
1346 A negative @var{amount} indicates lowering, see also @code{\\lower}.
1348 @lilypond[verbatim,fragment,relative=1]
1349 c1^\\markup { C \\small \\raise #1.0 \\bold { \"9/7+\" }}
1351 The argument to @code{\\raise} is the vertical displacement amount,
1352 measured in (global) staff spaces. @code{\\raise} and @code{\\super}
1353 raise objects in relation to their surrounding markups.
1355 If the text object itself is positioned above or below the staff, then
1356 @code{\\raise} cannot be used to move it, since the mechanism that
1357 positions it next to the staff cancels any shift made with
1358 @code{\\raise}. For vertical positioning, use the @code{padding}
1359 and/or @code{extra-offset} properties. "
1360 (ly:stencil-translate-axis (interpret-markup layout props arg) amount Y))
1362 (define-builtin-markup-command (fraction layout props arg1 arg2) (markup? markup?)
1363 "Make a fraction of two markups."
1364 (let* ((m1 (interpret-markup layout props arg1))
1365 (m2 (interpret-markup layout props arg2))
1366 (factor (magstep (chain-assoc-get 'font-size props 0)))
1367 (boxdimen (cons (* factor -0.05) (* factor 0.05)))
1368 (padding (* factor 0.2))
1369 (baseline (* factor 0.6))
1370 (offset (* factor 0.75)))
1371 (set! m1 (ly:stencil-aligned-to m1 X CENTER))
1372 (set! m2 (ly:stencil-aligned-to m2 X CENTER))
1373 (let* ((x1 (ly:stencil-extent m1 X))
1374 (x2 (ly:stencil-extent m2 X))
1375 (line (ly:round-filled-box (interval-union x1 x2) boxdimen 0.0))
1376 ;; should stack mols separately, to maintain LINE on baseline
1377 (stack (stack-lines DOWN padding baseline (list m1 line m2))))
1379 (ly:stencil-aligned-to stack Y CENTER))
1381 (ly:stencil-aligned-to stack X LEFT))
1382 ;; should have EX dimension
1384 (ly:stencil-translate-axis stack offset Y))))
1390 (define-builtin-markup-command (normal-size-super layout props arg) (markup?)
1391 "Set @var{arg} in superscript with a normal font size."
1392 (ly:stencil-translate-axis
1393 (interpret-markup layout props arg)
1394 (* 0.5 (chain-assoc-get 'baseline-skip props)) Y))
1396 (define-builtin-markup-command (super layout props arg) (markup?)
1398 @cindex raising text
1399 @cindex lowering text
1401 @cindex translating text
1403 @cindex @code{\\super}
1406 Raising and lowering texts can be done with @code{\\super} and
1409 @lilypond[verbatim,fragment,relative=1]
1410 c1^\\markup { E \"=\" mc \\super \"2\" }
1414 (ly:stencil-translate-axis
1417 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
1419 (* 0.5 (chain-assoc-get 'baseline-skip props))
1422 (define-builtin-markup-command (translate layout props offset arg) (number-pair? markup?)
1423 "This translates an object. Its first argument is a cons of numbers
1425 A \\translate #(cons 2 -3) @{ B C @} D
1427 This moves `B C' 2 spaces to the right, and 3 down, relative to its
1428 surroundings. This command cannot be used to move isolated scripts
1429 vertically, for the same reason that @code{\\raise} cannot be used for
1433 (ly:stencil-translate (interpret-markup layout props arg)
1436 (define-builtin-markup-command (sub layout props arg) (markup?)
1437 "Set @var{arg} in subscript."
1438 (ly:stencil-translate-axis
1441 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
1443 (* -0.5 (chain-assoc-get 'baseline-skip props))
1446 (define-builtin-markup-command (normal-size-sub layout props arg) (markup?)
1447 "Set @var{arg} in subscript, in a normal font size."
1448 (ly:stencil-translate-axis
1449 (interpret-markup layout props arg)
1450 (* -0.5 (chain-assoc-get 'baseline-skip props))
1453 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1455 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1457 (define-builtin-markup-command (hbracket layout props arg) (markup?)
1458 "Draw horizontal brackets around @var{arg}."
1459 (let ((th 0.1) ;; todo: take from GROB.
1460 (m (interpret-markup layout props arg)))
1461 (bracketify-stencil m X th (* 2.5 th) th)))
1463 (define-builtin-markup-command (bracket layout props arg) (markup?)
1464 "Draw vertical brackets around @var{arg}."
1465 (let ((th 0.1) ;; todo: take from GROB.
1466 (m (interpret-markup layout props arg)))
1467 (bracketify-stencil m Y th (* 2.5 th) th)))
1470 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1471 ;; size indications arrow
1472 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;