1 ;;;; define-markup-commands.scm -- markup commands
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2000--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
9 ;;; Markup commands and markup-list commands definitions.
11 ;;; Markup commands which are part of LilyPond, are defined
12 ;;; in the (lily) module, which is the current module in this file,
13 ;;; using the `define-builtin-markup-command' macro.
17 ;;; (define-builtin-markup-command (command-name layout props args...)
21 ;;; documentation-string
26 ;;; the name of the markup command
29 ;;; arguments that are automatically passed to the command when it
31 ;;; `layout' is an output def, which properties can be accessed
32 ;;; using `ly:output-def-lookup'.
33 ;;; `props' is a list of property settings which can be accessed
34 ;;; using `chain-assoc-get' (more on that below)
37 ;;; the command arguments. There are restrictions on the
38 ;;; possible arguments for a markup command.
39 ;;; First, arguments are distingued according to their type:
40 ;;; 1) a markup (or a string), corresponding to type predicate `markup?'
41 ;;; 2) a list of markups, corresponding to type predicate `markup-list?'
42 ;;; 3) any scheme object, corresponding to type predicates such as
43 ;;; `list?', 'number?', 'boolean?', etc.
44 ;;; The supported arrangements of arguments, according to their type, are:
52 ;;; - scheme, scheme, markup
53 ;;; - scheme, scheme, markup, markup
54 ;;; - scheme, markup, markup
55 ;;; - scheme, scheme, scheme
56 ;;; This combinations are hard-coded in the lexer and in the parser
57 ;;; (lily/lexer.ll and lily/parser.yy)
60 ;;; the arguments signature, i.e. a list of type predicates which
61 ;;; are used to type check the arguments, and also to define the general
62 ;;; argument types (markup, markup-list, scheme) that the command is
64 ;;; For instance, if a command expects a number, then a markup, the
65 ;;; signature would be: (number? markup?)
68 ;;; for documentation purpose, builtin markup commands are grouped by
69 ;;; category. This can be any symbol. When documentation is generated,
70 ;;; the symbol is converted to a capitalized string, where hyphens are
71 ;;; replaced by spaces.
74 ;;; this is used both for documentation generation, and to ease
75 ;;; programming the command itself. It is list of
76 ;;; (property-name default-value)
77 ;;; or (property-name)
78 ;;; elements. Each property is looked-up in the `props' argument, and
79 ;;; the symbol naming the property is bound to its value.
80 ;;; When the property is not found in `props', then the symbol is bound
81 ;;; to the given default value. When no default value is given, #f is
83 ;;; Thus, using the following property bindings:
86 ;;; is equivalent to writing:
87 ;;; (let ((thickness (chain-assoc-get 'thickness props 0.1))
88 ;;; (font-size (chain-assoc-get 'font-size props 0)))
90 ;;; When a command `B' internally calls an other command `A', it may
91 ;;; desirable to see in `B' documentation all the properties and
92 ;;; default values used by `A'. In that case, add `A-markup' to the
93 ;;; property-bindings of B. (This is used when generating
94 ;;; documentation, but won't create bindings.)
96 ;;; documentation-string
97 ;;; the command documentation string (used to generate manuals)
100 ;;; the command body. The function is supposed to return a stencil.
102 ;;; Each markup command definition shall have a documentation string
103 ;;; with description, syntax and example.
105 (use-modules (ice-9 regex))
107 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
109 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
111 (define-public empty-stencil (ly:make-stencil '() '(1 . -1) '(1 . -1)))
112 (define-public point-stencil (ly:make-stencil "" '(0 . 0) '(0 . 0)))
114 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
116 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
118 (define-builtin-markup-command (draw-line layout props dest)
123 @cindex drawing lines within text
126 @lilypond[verbatim,quote]
128 \\draw-line #'(4 . 4)
129 \\override #'(thickness . 5)
130 \\draw-line #'(-3 . 0)
133 (let ((th (* (ly:output-def-lookup layout 'line-thickness)
137 (make-line-stencil th 0 0 x y)))
139 (define-builtin-markup-command (draw-circle layout props radius thickness filled)
140 (number? number? boolean?)
144 @cindex drawing circles within text
146 A circle of radius @var{radius} and thickness @var{thickness},
149 @lilypond[verbatim,quote]
151 \\draw-circle #2 #0.5 ##f
153 \\draw-circle #2 #0 ##t
156 (make-circle-stencil radius thickness filled))
158 (define-builtin-markup-command (triangle layout props filled)
165 @cindex drawing triangles within text
167 A triangle, either filled or empty.
169 @lilypond[verbatim,quote]
176 (let ((ex (* (magstep font-size) 0.8 baseline-skip)))
185 (cons 0 (* .86 ex)))))
187 (define-builtin-markup-command (circle layout props arg)
192 (circle-padding 0.2))
194 @cindex circling text
196 Draw a circle around @var{arg}. Use @code{thickness},
197 @code{circle-padding} and @code{font-size} properties to determine line
198 thickness and padding around the markup.
200 @lilypond[verbatim,quote]
207 (let ((th (* (ly:output-def-lookup layout 'line-thickness)
209 (pad (* (magstep font-size) circle-padding))
210 (m (interpret-markup layout props arg)))
211 (circle-stencil m th pad)))
213 (define-builtin-markup-command (with-url layout props url arg)
218 @cindex inserting URL links into text
220 Add a link to URL @var{url} around @var{arg}. This only works in
223 @lilypond[verbatim,quote]
225 \\with-url #\"http://lilypond.org/web/\" {
226 LilyPond ... \\italic {
227 music notation for everyone
232 (let* ((stil (interpret-markup layout props arg))
233 (xextent (ly:stencil-extent stil X))
234 (yextent (ly:stencil-extent stil Y))
235 (old-expr (ly:stencil-expr stil))
236 (url-expr (list 'url-link url `(quote ,xextent) `(quote ,yextent))))
238 (ly:stencil-add (ly:make-stencil url-expr xextent yextent) stil)))
240 (define-builtin-markup-command (beam layout props width slope thickness)
241 (number? number? number?)
245 @cindex drawing beams within text
247 Create a beam with the specified parameters.
248 @lilypond[verbatim,quote]
253 (let* ((y (* slope width))
254 (yext (cons (min 0 y) (max 0 y)))
255 (half (/ thickness 2)))
260 width (+ (* width slope) (/ thickness -2))
261 width (+ (* width slope) (/ thickness 2))
263 ,(ly:output-def-lookup layout 'blot-diameter)
266 (cons (+ (- half) (car yext))
267 (+ half (cdr yext))))))
269 (define-builtin-markup-command (underline layout props arg)
274 @cindex underlining text
276 Underline @var{arg}. Looks at @code{thickness} to determine line
277 thickness and y-offset.
279 @lilypond[verbatim,quote]
283 \\override #'(thickness . 2)
289 (let* ((thick (* (ly:output-def-lookup layout 'line-thickness)
291 (markup (interpret-markup layout props arg))
292 (x1 (car (ly:stencil-extent markup X)))
293 (x2 (cdr (ly:stencil-extent markup X)))
295 (line (make-line-stencil thick x1 y x2 y)))
296 (ly:stencil-add markup line)))
298 (define-builtin-markup-command (box layout props arg)
305 @cindex enclosing text within a box
307 Draw a box round @var{arg}. Looks at @code{thickness},
308 @code{box-padding} and @code{font-size} properties to determine line
309 thickness and padding around the markup.
311 @lilypond[verbatim,quote]
313 \\override #'(box-padding . 0.5)
318 (let* ((th (* (ly:output-def-lookup layout 'line-thickness)
320 (pad (* (magstep font-size) box-padding))
321 (m (interpret-markup layout props arg)))
322 (box-stencil m th pad)))
324 (define-builtin-markup-command (filled-box layout props xext yext blot)
325 (number-pair? number-pair? number?)
329 @cindex drawing solid boxes within text
330 @cindex drawing boxes with rounded corners
332 Draw a box with rounded corners of dimensions @var{xext} and
333 @var{yext}. For example,
335 \\filled-box #'(-.3 . 1.8) #'(-.3 . 1.8) #0
337 creates a box extending horizontally from -0.3 to 1.8 and
338 vertically from -0.3 up to 1.8, with corners formed from a
339 circle of diameter@tie{}0 (i.e., sharp corners).
341 @lilypond[verbatim,quote]
343 \\filled-box #'(0 . 4) #'(0 . 4) #0
344 \\filled-box #'(0 . 2) #'(-4 . 2) #0.4
345 \\filled-box #'(1 . 8) #'(0 . 7) #0.2
347 \\filled-box #'(-4.5 . -2.5) #'(3.5 . 5.5) #0.7
353 (define-builtin-markup-command (rounded-box layout props arg)
360 "@cindex enclosing text in a box with rounded corners
361 @cindex drawing boxes with rounded corners around text
362 Draw a box with rounded corners around @var{arg}. Looks at @code{thickness},
363 @code{box-padding} and @code{font-size} properties to determine line
364 thickness and padding around the markup; the @code{corner-radius} property
365 makes it possible to define another shape for the corners (default is 1).
367 @lilypond[quote,verbatim,relative=2]
375 (let ((th (* (ly:output-def-lookup layout 'line-thickness)
377 (pad (* (magstep font-size) box-padding))
378 (m (interpret-markup layout props arg)))
379 (ly:stencil-add (rounded-box-stencil m th pad corner-radius)
382 (define-builtin-markup-command (rotate layout props ang arg)
387 @cindex rotating text
389 Rotate object with @var{ang} degrees around its center.
391 @lilypond[verbatim,quote]
401 (let* ((stil (interpret-markup layout props arg)))
402 (ly:stencil-rotate stil ang 0 0)))
404 (define-builtin-markup-command (whiteout layout props arg)
409 @cindex adding a white background to text
411 Provide a white background for @var{arg}.
413 @lilypond[verbatim,quote]
416 \\filled-box #'(-1 . 10) #'(-3 . 4) #1
420 (stencil-whiteout (interpret-markup layout props arg)))
422 (define-builtin-markup-command (pad-markup layout props amount arg)
428 @cindex putting space around text
430 Add space around a markup object.
432 @lilypond[verbatim,quote]
446 ((stil (interpret-markup layout props arg))
447 (xext (ly:stencil-extent stil X))
448 (yext (ly:stencil-extent stil Y)))
451 (ly:stencil-expr stil)
452 (interval-widen xext amount)
453 (interval-widen yext amount))))
455 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
457 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
459 (define-builtin-markup-command (strut layout props)
464 @cindex creating vertical spaces in text
466 Create a box of the same height as the space in the current font."
467 (let ((m (ly:text-interface::interpret-markup layout props " ")))
468 (ly:make-stencil (ly:stencil-expr m)
470 (ly:stencil-extent m X)
473 ;; todo: fix negative space
474 (define-builtin-markup-command (hspace layout props amount)
479 @cindex creating horizontal spaces in text
481 Create an invisible object taking up horizontal space @var{amount}.
483 @lilypond[verbatim,quote]
493 (ly:make-stencil "" (cons 0 amount) '(-1 . 1))
494 (ly:make-stencil "" (cons amount amount) '(-1 . 1))))
496 ;; todo: fix negative space
497 (define-builtin-markup-command (vspace layout props amount)
502 @cindex creating vertical spaces in text
504 Create an invisible object taking up vertical space
505 of @var{amount} multiplied by 3.
507 @lilypond[verbatim,quote]
518 (let ((amount (* amount 3.0)))
520 (ly:make-stencil "" (cons -1 1) (cons 0 amount))
521 (ly:make-stencil "" (cons -1 1) (cons amount amount)))))
524 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
525 ;; importing graphics.
526 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
528 (define-builtin-markup-command (stencil layout props stil)
533 @cindex importing stencils into text
535 Use a stencil as markup.
537 @lilypond[verbatim,quote]
539 \\stencil #(make-circle-stencil 2 0 #t)
545 (make-regexp "%%BoundingBox:[ \t]+([0-9-]+)[ \t]+([0-9-]+)[ \t]+([0-9-]+)[ \t]+([0-9-]+)"))
547 (define (get-postscript-bbox string)
548 "Extract the bbox from STRING, or return #f if not present."
550 ((match (regexp-exec bbox-regexp string)))
554 (string->number (match:substring match x)))
559 (define-builtin-markup-command (epsfile layout props axis size file-name)
560 (number? number? string?)
564 @cindex inlining an Encapsulated PostScript image
566 Inline an EPS image. The image is scaled along @var{axis} to
569 @lilypond[verbatim,quote]
571 \\general-align #Y #DOWN {
572 \\epsfile #X #20 #\"context-example.eps\"
573 \\epsfile #Y #20 #\"context-example.eps\"
577 (if (ly:get-option 'safe)
578 (interpret-markup layout props "not allowed in safe")
579 (eps-file->stencil axis size file-name)
582 (define-builtin-markup-command (postscript layout props str)
587 @cindex inserting PostScript directly into text
588 This inserts @var{str} directly into the output as a PostScript
591 @lilypond[verbatim,quote]
595 0.4 0.6 0.5 0 361 arc
597 1.0 0.6 0.5 0 361 arc
602 \\with-dimensions #'(-0.2 . 1.6) #'(0 . 1.2)
603 \\postscript #ringsps
615 gsave currentpoint translate
623 (define-builtin-markup-command (score layout props score)
628 @cindex inserting music into text
630 Inline an image of music.
632 @lilypond[verbatim,quote]
636 \\new Staff \\relative c' {
639 \\mark \\markup { Allegro }
645 \\new Staff \\relative c {
659 \\override RehearsalMark #'break-align-symbols =
660 #'(time-signature key-signature)
661 \\override RehearsalMark #'self-alignment-X = #LEFT
665 \\override TimeSignature #'break-align-anchor-alignment = #LEFT
671 (let ((output (ly:score-embedded-format score layout)))
673 (if (ly:music-output? output)
674 (stack-stencils Y DOWN baseline-skip
675 (map paper-system-stencil
677 (ly:paper-score-paper-systems output))))
679 (ly:warning (_"no systems found in \\score markup, does it have a \\layout block?"))
682 (define-builtin-markup-command (null layout props)
687 @cindex creating empty text objects
689 An empty markup with extents of a single point.
691 @lilypond[verbatim,quote]
698 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
700 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
702 (define-builtin-markup-command (simple layout props str)
707 @cindex simple text strings
709 A simple text string; @code{\\markup @{ foo @}} is equivalent with
710 @code{\\markup @{ \\simple #\"foo\" @}}.
712 Note: for creating standard text markup or defining new markup commands,
713 the use of @code{\\simple} is unnecessary.
715 @lilypond[verbatim,quote]
719 \\simple #\"strings\"
722 (interpret-markup layout props str))
724 (define-builtin-markup-command (tied-lyric layout props str)
729 @cindex simple text strings with tie characters
731 Like simple-markup, but use tie characters for @q{~} tilde symbols.
733 @lilypond[verbatim,quote]
735 \\tied-lyric #\"Lasciate~i monti\"
738 (if (string-contains str "~")
740 ((parts (string-split str #\~))
741 (tie-str (ly:wide-char->utf-8 #x203f))
742 (joined (list-join parts tie-str))
743 (join-stencil (interpret-markup layout props tie-str))
746 (interpret-markup layout
749 (/ (interval-length (ly:stencil-extent join-stencil X)) -3.5)
751 (make-line-markup joined)))
752 ;(map (lambda (s) (interpret-markup layout props s)) parts))
753 (interpret-markup layout props str)))
755 (define-public empty-markup
756 (make-simple-markup ""))
758 ;; helper for justifying lines.
759 (define (get-fill-space word-count line-width text-widths)
760 "Calculate the necessary paddings between each two adjacent texts.
761 The lengths of all texts are stored in @var{text-widths}.
762 The normal formula for the padding between texts a and b is:
763 padding = line-width/(word-count - 1) - (length(a) + length(b))/2
764 The first and last padding have to be calculated specially using the
765 whole length of the first or last text.
766 Return a list of paddings."
768 ((null? text-widths) '())
770 ;; special case first padding
771 ((= (length text-widths) word-count)
773 (- (- (/ line-width (1- word-count)) (car text-widths))
774 (/ (car (cdr text-widths)) 2))
775 (get-fill-space word-count line-width (cdr text-widths))))
776 ;; special case last padding
777 ((= (length text-widths) 2)
778 (list (- (/ line-width (1- word-count))
779 (+ (/ (car text-widths) 2) (car (cdr text-widths)))) 0))
782 (- (/ line-width (1- word-count))
783 (/ (+ (car text-widths) (car (cdr text-widths))) 2))
784 (get-fill-space word-count line-width (cdr text-widths))))))
786 (define-builtin-markup-command (fill-line layout props args)
789 ((text-direction RIGHT)
792 "Put @var{markups} in a horizontal line of width @var{line-width}.
793 The markups are spaced or flushed to fill the entire line.
794 If there are no arguments, return an empty stencil.
796 @lilypond[verbatim,quote]
800 Words evenly spaced across the page
804 \\line { Text markups }
806 \\italic { evenly spaced }
808 \\line { across the page }
813 (let* ((orig-stencils (interpret-markup-list layout props args))
816 (if (ly:stencil-empty? stc)
818 stc)) orig-stencils))
821 (if (ly:stencil-empty? stc)
823 (interval-length (ly:stencil-extent stc X))))
825 (text-width (apply + text-widths))
826 (word-count (length stencils))
827 (prop-line-width (chain-assoc-get 'line-width props #f))
828 (line-width (or line-width (ly:output-def-lookup layout 'line-width)))
833 (/ (- line-width text-width) 2)
834 (/ (- line-width text-width) 2)))
837 (- line-width text-width)))
839 (get-fill-space word-count line-width text-widths))))
847 (line-stencils (if (= word-count 1)
854 (if (= text-direction LEFT)
855 (set! line-stencils (reverse line-stencils)))
857 (if (null? (remove ly:stencil-empty? orig-stencils))
859 (stack-stencils-padding-list X
860 RIGHT fill-space-normal line-stencils))))
862 (define-builtin-markup-command (line layout props args)
866 (text-direction RIGHT))
867 "Put @var{args} in a horizontal line. The property @code{word-space}
868 determines the space between markups in @var{args}.
870 @lilypond[verbatim,quote]
877 (let ((stencils (interpret-markup-list layout props args)))
878 (if (= text-direction LEFT)
879 (set! stencils (reverse stencils)))
882 (remove ly:stencil-empty? stencils))))
884 (define-builtin-markup-command (concat layout props args)
889 @cindex concatenating text
890 @cindex ligatures in text
892 Concatenate @var{args} in a horizontal line, without spaces in between.
893 Strings and simple markups are concatenated on the input level, allowing
894 ligatures. For example, @code{\\concat @{ \"f\" \\simple #\"i\" @}} is
895 equivalent to @code{\"fi\"}.
897 @lilypond[verbatim,quote]
906 (define (concat-string-args arg-list)
907 (fold-right (lambda (arg result-list)
908 (let ((result (if (pair? result-list)
911 (if (and (pair? arg) (eqv? (car arg) simple-markup))
912 (set! arg (cadr arg)))
913 (if (and (string? result) (string? arg))
914 (cons (string-append arg result) (cdr result-list))
915 (cons arg result-list))))
919 (interpret-markup layout
920 (prepend-alist-chain 'word-space 0 props)
921 (make-line-markup (if (markup-command-list? args)
923 (concat-string-args args)))))
925 (define (wordwrap-stencils stencils
926 justify base-space line-width text-dir)
927 "Perform simple wordwrap, return stencil of each line."
928 (define space (if justify
929 ;; justify only stretches lines.
932 (define (take-list width space stencils
933 accumulator accumulated-width)
934 "Return (head-list . tail) pair, with head-list fitting into width"
936 (cons accumulator stencils)
937 (let* ((first (car stencils))
938 (first-wid (cdr (ly:stencil-extent (car stencils) X)))
939 (newwid (+ space first-wid accumulated-width)))
940 (if (or (null? accumulator)
942 (take-list width space
944 (cons first accumulator)
946 (cons accumulator stencils)))))
947 (let loop ((lines '())
949 (let* ((line-break (take-list line-width space todo
951 (line-stencils (car line-break))
952 (space-left (- line-width
953 (apply + (map (lambda (x) (cdr (ly:stencil-extent x X)))
955 (line-word-space (cond ((not justify) space)
956 ;; don't stretch last line of paragraph.
957 ;; hmmm . bug - will overstretch the last line in some case.
958 ((null? (cdr line-break))
960 ((null? line-stencils) 0.0)
961 ((null? (cdr line-stencils)) 0.0)
962 (else (/ space-left (1- (length line-stencils))))))
963 (line (stack-stencil-line line-word-space
964 (if (= text-dir RIGHT)
965 (reverse line-stencils)
967 (if (pair? (cdr line-break))
968 (loop (cons line lines)
971 (if (= text-dir LEFT)
973 (ly:stencil-translate-axis
975 (- line-width (interval-end (ly:stencil-extent line X)))
977 (reverse (cons line lines)))))))
979 (define-builtin-markup-list-command (wordwrap-internal layout props justify args)
980 (boolean? markup-list?)
983 (text-direction RIGHT))
984 "Internal markup list command used to define @code{\\justify} and @code{\\wordwrap}."
985 (wordwrap-stencils (remove ly:stencil-empty?
986 (interpret-markup-list layout props args))
990 (ly:output-def-lookup layout 'line-width))
993 (define-builtin-markup-command (justify layout props args)
997 wordwrap-internal-markup-list)
999 @cindex justifying text
1001 Like @code{\\wordwrap}, but with lines stretched to justify the margins.
1002 Use @code{\\override #'(line-width . @var{X})} to set the line width;
1003 @var{X}@tie{}is the number of staff spaces.
1005 @lilypond[verbatim,quote]
1008 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
1009 do eiusmod tempor incididunt ut labore et dolore magna aliqua.
1010 Ut enim ad minim veniam, quis nostrud exercitation ullamco
1011 laboris nisi ut aliquip ex ea commodo consequat.
1015 (stack-lines DOWN 0.0 baseline-skip
1016 (wordwrap-internal-markup-list layout props #t args)))
1018 (define-builtin-markup-command (wordwrap layout props args)
1022 wordwrap-internal-markup-list)
1023 "Simple wordwrap. Use @code{\\override #'(line-width . @var{X})} to set
1024 the line width, where @var{X} is the number of staff spaces.
1026 @lilypond[verbatim,quote]
1029 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
1030 do eiusmod tempor incididunt ut labore et dolore magna aliqua.
1031 Ut enim ad minim veniam, quis nostrud exercitation ullamco
1032 laboris nisi ut aliquip ex ea commodo consequat.
1036 (stack-lines DOWN 0.0 baseline-skip
1037 (wordwrap-internal-markup-list layout props #f args)))
1039 (define-builtin-markup-list-command (wordwrap-string-internal layout props justify arg)
1043 (text-direction RIGHT))
1044 "Internal markup list command used to define @code{\\justify-string} and
1045 @code{\\wordwrap-string}."
1046 (let* ((para-strings (regexp-split
1047 (string-regexp-substitute
1049 (string-regexp-substitute "\r\n" "\n" arg))
1050 "\n[ \t\n]*\n[ \t\n]*"))
1051 (list-para-words (map (lambda (str)
1052 (regexp-split str "[ \t\n]+"))
1054 (para-lines (map (lambda (words)
1056 (remove ly:stencil-empty?
1058 (interpret-markup layout props x))
1060 (wordwrap-stencils stencils
1062 line-width text-direction)))
1064 (apply append para-lines)))
1066 (define-builtin-markup-command (wordwrap-string layout props arg)
1070 wordwrap-string-internal-markup-list)
1071 "Wordwrap a string. Paragraphs may be separated with double newlines.
1073 @lilypond[verbatim,quote]
1075 \\override #'(line-width . 40)
1076 \\wordwrap-string #\"Lorem ipsum dolor sit amet, consectetur
1077 adipisicing elit, sed do eiusmod tempor incididunt ut labore
1078 et dolore magna aliqua.
1081 Ut enim ad minim veniam, quis nostrud exercitation ullamco
1082 laboris nisi ut aliquip ex ea commodo consequat.
1085 Excepteur sint occaecat cupidatat non proident, sunt in culpa
1086 qui officia deserunt mollit anim id est laborum\"
1089 (stack-lines DOWN 0.0 baseline-skip
1090 (wordwrap-string-internal-markup-list layout props #f arg)))
1092 (define-builtin-markup-command (justify-string layout props arg)
1096 wordwrap-string-internal-markup-list)
1097 "Justify a string. Paragraphs may be separated with double newlines
1099 @lilypond[verbatim,quote]
1101 \\override #'(line-width . 40)
1102 \\justify-string #\"Lorem ipsum dolor sit amet, consectetur
1103 adipisicing elit, sed do eiusmod tempor incididunt ut labore
1104 et dolore magna aliqua.
1107 Ut enim ad minim veniam, quis nostrud exercitation ullamco
1108 laboris nisi ut aliquip ex ea commodo consequat.
1111 Excepteur sint occaecat cupidatat non proident, sunt in culpa
1112 qui officia deserunt mollit anim id est laborum\"
1115 (stack-lines DOWN 0.0 baseline-skip
1116 (wordwrap-string-internal-markup-list layout props #t arg)))
1118 (define-builtin-markup-command (wordwrap-field layout props symbol)
1122 "Wordwrap the data which has been assigned to @var{symbol}.
1124 @lilypond[verbatim,quote]
1126 title = \"My title\"
1127 myText = \"Lorem ipsum dolor sit amet, consectetur adipisicing
1128 elit, sed do eiusmod tempor incididunt ut labore et dolore magna
1129 aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
1130 laboris nisi ut aliquip ex ea commodo consequat.\"
1134 bookTitleMarkup = \\markup {
1136 \\fill-line { \\fromproperty #'header:title }
1138 \\wordwrap-field #'header:myText
1147 (let* ((m (chain-assoc-get symbol props)))
1149 (wordwrap-string-markup layout props m)
1152 (define-builtin-markup-command (justify-field layout props symbol)
1156 "Justify the data which has been assigned to @var{symbol}.
1158 @lilypond[verbatim,quote]
1160 title = \"My title\"
1161 myText = \"Lorem ipsum dolor sit amet, consectetur adipisicing
1162 elit, sed do eiusmod tempor incididunt ut labore et dolore magna
1163 aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
1164 laboris nisi ut aliquip ex ea commodo consequat.\"
1168 bookTitleMarkup = \\markup {
1170 \\fill-line { \\fromproperty #'header:title }
1172 \\justify-field #'header:myText
1181 (let* ((m (chain-assoc-get symbol props)))
1183 (justify-string-markup layout props m)
1186 (define-builtin-markup-command (combine layout props arg1 arg2)
1191 @cindex merging text
1193 Print two markups on top of each other.
1195 Note: @code{\\combine} cannot take a list of markups enclosed in
1196 curly braces as an argument; the follow example will not compile:
1199 \\combine @{ a list @}
1202 @lilypond[verbatim,quote]
1205 \\override #'(thickness . 2)
1207 \\draw-line #'(0 . 4)
1208 \\arrow-head #Y #DOWN ##f
1211 (let* ((s1 (interpret-markup layout props arg1))
1212 (s2 (interpret-markup layout props arg2)))
1213 (ly:stencil-add s1 s2)))
1216 ;; TODO: should extract baseline-skip from each argument somehow..
1218 (define-builtin-markup-command (column layout props args)
1223 @cindex stacking text in a column
1225 Stack the markups in @var{args} vertically. The property
1226 @code{baseline-skip} determines the space between markups
1229 @lilypond[verbatim,quote]
1238 (let ((arg-stencils (interpret-markup-list layout props args)))
1239 (stack-lines -1 0.0 baseline-skip
1240 (remove ly:stencil-empty? arg-stencils))))
1242 (define-builtin-markup-command (dir-column layout props args)
1248 @cindex changing direction of text columns
1250 Make a column of @var{args}, going up or down, depending on the
1251 setting of the @code{direction} layout property.
1253 @lilypond[verbatim,quote]
1255 \\override #`(direction . ,UP) {
1265 \\override #'(direction . 1) {
1272 (stack-lines (if (number? direction) direction -1)
1275 (interpret-markup-list layout props args)))
1277 (define (general-column align-dir baseline mols)
1278 "Stack @var{mols} vertically, aligned to @var{align-dir} horizontally."
1280 (let* ((aligned-mols (map (lambda (x) (ly:stencil-aligned-to x X align-dir)) mols)))
1281 (stack-lines -1 0.0 baseline aligned-mols)))
1283 (define-builtin-markup-command (center-column layout props args)
1288 @cindex centering a column of text
1290 Put @code{args} in a centered column.
1292 @lilypond[verbatim,quote]
1301 (general-column CENTER baseline-skip (interpret-markup-list layout props args)))
1303 (define-builtin-markup-command (left-column layout props args)
1308 @cindex text columns, left-aligned
1310 Put @code{args} in a left-aligned column.
1312 @lilypond[verbatim,quote]
1321 (general-column LEFT baseline-skip (interpret-markup-list layout props args)))
1323 (define-builtin-markup-command (right-column layout props args)
1328 @cindex text columns, right-aligned
1330 Put @code{args} in a right-aligned column.
1332 @lilypond[verbatim,quote]
1341 (general-column RIGHT baseline-skip (interpret-markup-list layout props args)))
1343 (define-builtin-markup-command (vcenter layout props arg)
1348 @cindex vertically centering text
1350 Align @code{arg} to its Y@tie{}center.
1352 @lilypond[verbatim,quote]
1360 (let* ((mol (interpret-markup layout props arg)))
1361 (ly:stencil-aligned-to mol Y CENTER)))
1363 (define-builtin-markup-command (center-align layout props arg)
1368 @cindex horizontally centering text
1370 Align @code{arg} to its X@tie{}center.
1372 @lilypond[verbatim,quote]
1382 (let* ((mol (interpret-markup layout props arg)))
1383 (ly:stencil-aligned-to mol X CENTER)))
1385 (define-builtin-markup-command (right-align layout props arg)
1390 @cindex right aligning text
1392 Align @var{arg} on its right edge.
1394 @lilypond[verbatim,quote]
1404 (let* ((m (interpret-markup layout props arg)))
1405 (ly:stencil-aligned-to m X RIGHT)))
1407 (define-builtin-markup-command (left-align layout props arg)
1412 @cindex left aligning text
1414 Align @var{arg} on its left edge.
1416 @lilypond[verbatim,quote]
1426 (let* ((m (interpret-markup layout props arg)))
1427 (ly:stencil-aligned-to m X LEFT)))
1429 (define-builtin-markup-command (general-align layout props axis dir arg)
1430 (integer? number? markup?)
1434 @cindex controlling general text alignment
1436 Align @var{arg} in @var{axis} direction to the @var{dir} side.
1438 @lilypond[verbatim,quote]
1442 \\general-align #X #LEFT
1447 \\general-align #X #CENTER
1453 \\general-align #Y #UP
1460 \\general-align #Y #3.2
1467 (let* ((m (interpret-markup layout props arg)))
1468 (ly:stencil-aligned-to m axis dir)))
1470 (define-builtin-markup-command (halign layout props dir arg)
1475 @cindex setting horizontal text alignment
1477 Set horizontal alignment. If @var{dir} is @code{-1}, then it is
1478 left-aligned, while @code{+1} is right. Values in between interpolate
1479 alignment accordingly.
1481 @lilypond[verbatim,quote]
1506 (let* ((m (interpret-markup layout props arg)))
1507 (ly:stencil-aligned-to m X dir)))
1509 (define-builtin-markup-command (with-dimensions layout props x y arg)
1510 (number-pair? number-pair? markup?)
1514 @cindex setting extent of text objects
1516 Set the dimensions of @var{arg} to @var{x} and@tie{}@var{y}."
1517 (let* ((m (interpret-markup layout props arg)))
1518 (ly:make-stencil (ly:stencil-expr m) x y)))
1520 (define-builtin-markup-command (pad-around layout props amount arg)
1524 "Add padding @var{amount} all around @var{arg}.
1526 @lilypond[verbatim,quote]
1539 (let* ((m (interpret-markup layout props arg))
1540 (x (ly:stencil-extent m X))
1541 (y (ly:stencil-extent m Y)))
1542 (ly:make-stencil (ly:stencil-expr m)
1543 (interval-widen x amount)
1544 (interval-widen y amount))))
1546 (define-builtin-markup-command (pad-x layout props amount arg)
1551 @cindex padding text horizontally
1553 Add padding @var{amount} around @var{arg} in the X@tie{}direction.
1555 @lilypond[verbatim,quote]
1568 (let* ((m (interpret-markup layout props arg))
1569 (x (ly:stencil-extent m X))
1570 (y (ly:stencil-extent m Y)))
1571 (ly:make-stencil (ly:stencil-expr m)
1572 (interval-widen x amount)
1575 (define-builtin-markup-command (put-adjacent layout props axis dir arg1 arg2)
1576 (integer? ly:dir? markup? markup?)
1579 "Put @var{arg2} next to @var{arg1}, without moving @var{arg1}."
1580 (let ((m1 (interpret-markup layout props arg1))
1581 (m2 (interpret-markup layout props arg2)))
1582 (ly:stencil-combine-at-edge m1 axis dir m2 0.0)))
1584 (define-builtin-markup-command (transparent layout props arg)
1588 "Make @var{arg} transparent.
1590 @lilypond[verbatim,quote]
1597 (let* ((m (interpret-markup layout props arg))
1598 (x (ly:stencil-extent m X))
1599 (y (ly:stencil-extent m Y)))
1600 (ly:make-stencil "" x y)))
1602 (define-builtin-markup-command (pad-to-box layout props x-ext y-ext arg)
1603 (number-pair? number-pair? markup?)
1606 "Make @var{arg} take at least @var{x-ext}, @var{y-ext} space.
1608 @lilypond[verbatim,quote]
1615 \\pad-to-box #'(0 . 10) #'(0 . 3) {
1621 (let* ((m (interpret-markup layout props arg))
1622 (x (ly:stencil-extent m X))
1623 (y (ly:stencil-extent m Y)))
1624 (ly:make-stencil (ly:stencil-expr m)
1625 (interval-union x-ext x)
1626 (interval-union y-ext y))))
1628 (define-builtin-markup-command (hcenter-in layout props length arg)
1632 "Center @var{arg} horizontally within a box of extending
1633 @var{length}/2 to the left and right.
1635 @lilypond[quote,verbatim]
1638 \\set Staff.instrumentName = \\markup {
1645 \\set Staff.instrumentName = \\markup {
1654 (interpret-markup layout props
1655 (make-pad-to-box-markup
1656 (cons (/ length -2) (/ length 2))
1658 (make-center-align-markup arg))))
1660 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1662 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1664 (define-builtin-markup-command (fromproperty layout props symbol)
1668 "Read the @var{symbol} from property settings, and produce a stencil
1669 from the markup contained within. If @var{symbol} is not defined, it
1670 returns an empty markup.
1672 @lilypond[verbatim,quote]
1674 myTitle = \"myTitle\"
1678 \\fromproperty #'header:myTitle
1685 (let ((m (chain-assoc-get symbol props)))
1687 (interpret-markup layout props m)
1690 (define-builtin-markup-command (on-the-fly layout props procedure arg)
1694 "Apply the @var{procedure} markup command to @var{arg}.
1695 @var{procedure} should take a single argument."
1696 (let ((anonymous-with-signature (lambda (layout props arg) (procedure layout props arg))))
1697 (set-object-property! anonymous-with-signature
1700 (interpret-markup layout props (list anonymous-with-signature arg))))
1702 (define-builtin-markup-command (override layout props new-prop arg)
1707 @cindex overriding properties within text markup
1709 Add the argument @var{new-prop} to the property list. Properties
1710 may be any property supported by @rinternals{font-interface},
1711 @rinternals{text-interface} and
1712 @rinternals{instrument-specific-markup-interface}.
1714 @lilypond[verbatim,quote]
1722 \\override #'(baseline-skip . 4) {
1731 (interpret-markup layout (cons (list new-prop) props) arg))
1733 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1735 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1737 (define-builtin-markup-command (verbatim-file layout props name)
1741 "Read the contents of file @var{name}, and include it verbatim.
1743 @lilypond[verbatim,quote]
1745 \\verbatim-file #\"simple.ly\"
1748 (interpret-markup layout props
1749 (if (ly:get-option 'safe)
1750 "verbatim-file disabled in safe mode"
1751 (let* ((str (ly:gulp-file name))
1752 (lines (string-split str #\nl)))
1753 (make-typewriter-markup
1754 (make-column-markup lines))))))
1756 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1758 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1761 (define-builtin-markup-command (smaller layout props arg)
1765 "Decrease the font size relative to the current setting.
1767 @lilypond[verbatim,quote]
1780 (interpret-markup layout props
1781 `(,fontsize-markup -1 ,arg)))
1783 (define-builtin-markup-command (larger layout props arg)
1787 "Increase the font size relative to the current setting.
1789 @lilypond[verbatim,quote]
1797 (interpret-markup layout props
1798 `(,fontsize-markup 1 ,arg)))
1800 (define-builtin-markup-command (finger layout props arg)
1804 "Set @var{arg} as small numbers.
1806 @lilypond[verbatim,quote]
1813 (interpret-markup layout
1814 (cons '((font-size . -5) (font-encoding . fetaNumber)) props)
1817 (define-builtin-markup-command (abs-fontsize layout props size arg)
1821 "Use @var{size} as the absolute font size to display @var{arg}.
1822 Adjusts @code{baseline-skip} and @code{word-space} accordingly.
1824 @lilypond[verbatim,quote]
1826 default text font size
1828 \\abs-fontsize #16 { text font size 16 }
1830 \\abs-fontsize #12 { text font size 12 }
1833 (let* ((ref-size (ly:output-def-lookup layout 'text-font-size 12))
1834 (text-props (list (ly:output-def-lookup layout 'text-font-defaults)))
1835 (ref-word-space (chain-assoc-get 'word-space text-props 0.6))
1836 (ref-baseline (chain-assoc-get 'baseline-skip text-props 3))
1837 (magnification (/ size ref-size)))
1838 (interpret-markup layout
1839 (cons `((baseline-skip . ,(* magnification ref-baseline))
1840 (word-space . ,(* magnification ref-word-space))
1841 (font-size . ,(magnification->font-size magnification)))
1845 (define-builtin-markup-command (fontsize layout props increment arg)
1851 "Add @var{increment} to the font-size. Adjusts @code{baseline-skip}
1854 @lilypond[verbatim,quote]
1862 (let ((entries (list
1863 (cons 'baseline-skip (* baseline-skip (magstep increment)))
1864 (cons 'word-space (* word-space (magstep increment)))
1865 (cons 'font-size (+ font-size increment)))))
1866 (interpret-markup layout (cons entries props) arg)))
1868 (define-builtin-markup-command (magnify layout props sz arg)
1873 @cindex magnifying text
1875 Set the font magnification for its argument. In the following
1876 example, the middle@tie{}A is 10% larger:
1879 A \\magnify #1.1 @{ A @} A
1882 Note: Magnification only works if a font name is explicitly selected.
1883 Use @code{\\fontsize} otherwise.
1885 @lilypond[verbatim,quote]
1896 (prepend-alist-chain 'font-size (magnification->font-size sz) props)
1899 (define-builtin-markup-command (bold layout props arg)
1903 "Switch to bold font-series.
1905 @lilypond[verbatim,quote]
1913 (interpret-markup layout (prepend-alist-chain 'font-series 'bold props) arg))
1915 (define-builtin-markup-command (sans layout props arg)
1919 "Switch to the sans serif font family.
1921 @lilypond[verbatim,quote]
1930 (interpret-markup layout (prepend-alist-chain 'font-family 'sans props) arg))
1932 (define-builtin-markup-command (number layout props arg)
1936 "Set font family to @code{number}, which yields the font used for
1937 time signatures and fingerings. This font contains numbers and
1938 some punctuation; it has no letters.
1940 @lilypond[verbatim,quote]
1943 0 1 2 3 4 5 6 7 8 9 . ,
1947 (interpret-markup layout (prepend-alist-chain 'font-encoding 'fetaNumber props) arg))
1949 (define-builtin-markup-command (roman layout props arg)
1953 "Set font family to @code{roman}.
1955 @lilypond[verbatim,quote]
1961 text in roman font family
1968 (interpret-markup layout (prepend-alist-chain 'font-family 'roman props) arg))
1970 (define-builtin-markup-command (huge layout props arg)
1974 "Set font size to +2.
1976 @lilypond[verbatim,quote]
1984 (interpret-markup layout (prepend-alist-chain 'font-size 2 props) arg))
1986 (define-builtin-markup-command (large layout props arg)
1990 "Set font size to +1.
1992 @lilypond[verbatim,quote]
2000 (interpret-markup layout (prepend-alist-chain 'font-size 1 props) arg))
2002 (define-builtin-markup-command (normalsize layout props arg)
2006 "Set font size to default.
2008 @lilypond[verbatim,quote]
2021 (interpret-markup layout (prepend-alist-chain 'font-size 0 props) arg))
2023 (define-builtin-markup-command (small layout props arg)
2027 "Set font size to -1.
2029 @lilypond[verbatim,quote]
2037 (interpret-markup layout (prepend-alist-chain 'font-size -1 props) arg))
2039 (define-builtin-markup-command (tiny layout props arg)
2043 "Set font size to -2.
2045 @lilypond[verbatim,quote]
2053 (interpret-markup layout (prepend-alist-chain 'font-size -2 props) arg))
2055 (define-builtin-markup-command (teeny layout props arg)
2059 "Set font size to -3.
2061 @lilypond[verbatim,quote]
2069 (interpret-markup layout (prepend-alist-chain 'font-size -3 props) arg))
2071 (define-builtin-markup-command (fontCaps layout props arg)
2075 "Set @code{font-shape} to @code{caps}
2077 Note: @code{\\fontCaps} requires the installation and selection of
2078 fonts which support the @code{caps} font shape."
2079 (interpret-markup layout (prepend-alist-chain 'font-shape 'caps props) arg))
2082 (define-builtin-markup-command (smallCaps layout props arg)
2086 "Emit @var{arg} as small caps.
2088 Note: @code{\\smallCaps} does not support accented characters.
2090 @lilypond[verbatim,quote]
2099 (define (char-list->markup chars lower)
2100 (let ((final-string (string-upcase (reverse-list->string chars))))
2102 (markup #:fontsize -2 final-string)
2104 (define (make-small-caps rest-chars currents current-is-lower prev-result)
2105 (if (null? rest-chars)
2107 (reverse! (cons (char-list->markup currents current-is-lower)
2109 (let* ((ch (car rest-chars))
2110 (is-lower (char-lower-case? ch)))
2111 (if (or (and current-is-lower is-lower)
2112 (and (not current-is-lower) (not is-lower)))
2113 (make-small-caps (cdr rest-chars)
2117 (make-small-caps (cdr rest-chars)
2120 (if (null? currents)
2122 (cons (char-list->markup
2123 currents current-is-lower)
2125 (interpret-markup layout props
2127 (make-small-caps (string->list arg) (list) #f (list))
2130 (define-builtin-markup-command (caps layout props arg)
2134 "Copy of the @code{\\smallCaps} command.
2136 @lilypond[verbatim,quote]
2145 (interpret-markup layout props (make-smallCaps-markup arg)))
2147 (define-builtin-markup-command (dynamic layout props arg)
2151 "Use the dynamic font. This font only contains @b{s}, @b{f}, @b{m},
2152 @b{z}, @b{p}, and @b{r}. When producing phrases, like
2153 @q{pi@`{u}@tie{}@b{f}}, the normal words (like @q{pi@`{u}}) should be
2154 done in a different font. The recommended font for this is bold and italic.
2155 @lilypond[verbatim,quote]
2163 layout (prepend-alist-chain 'font-encoding 'fetaDynamic props) arg))
2165 (define-builtin-markup-command (text layout props arg)
2169 "Use a text font instead of music symbol or music alphabet font.
2171 @lilypond[verbatim,quote]
2184 (interpret-markup layout (prepend-alist-chain 'font-encoding 'latin1 props)
2187 (define-builtin-markup-command (italic layout props arg)
2191 "Use italic @code{font-shape} for @var{arg}.
2193 @lilypond[verbatim,quote]
2201 (interpret-markup layout (prepend-alist-chain 'font-shape 'italic props) arg))
2203 (define-builtin-markup-command (typewriter layout props arg)
2207 "Use @code{font-family} typewriter for @var{arg}.
2209 @lilypond[verbatim,quote]
2218 layout (prepend-alist-chain 'font-family 'typewriter props) arg))
2220 (define-builtin-markup-command (upright layout props arg)
2224 "Set @code{font-shape} to @code{upright}. This is the opposite
2227 @lilypond[verbatim,quote]
2241 layout (prepend-alist-chain 'font-shape 'upright props) arg))
2243 (define-builtin-markup-command (medium layout props arg)
2247 "Switch to medium font-series (in contrast to bold).
2249 @lilypond[verbatim,quote]
2262 (interpret-markup layout (prepend-alist-chain 'font-series 'medium props)
2265 (define-builtin-markup-command (normal-text layout props arg)
2269 "Set all font related properties (except the size) to get the default
2270 normal text font, no matter what font was used earlier.
2272 @lilypond[verbatim,quote]
2274 \\huge \\bold \\sans \\caps {
2275 Some text with font overrides
2278 Default text, same font-size
2286 (interpret-markup layout
2287 (cons '((font-family . roman) (font-shape . upright)
2288 (font-series . medium) (font-encoding . latin1))
2292 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2294 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2296 (define-builtin-markup-command (doublesharp layout props)
2300 "Draw a double sharp symbol.
2302 @lilypond[verbatim,quote]
2307 (interpret-markup layout props (markup #:musicglyph (assoc-get 1 standard-alteration-glyph-name-alist ""))))
2309 (define-builtin-markup-command (sesquisharp layout props)
2313 "Draw a 3/2 sharp symbol.
2315 @lilypond[verbatim,quote]
2320 (interpret-markup layout props (markup #:musicglyph (assoc-get 3/4 standard-alteration-glyph-name-alist ""))))
2322 (define-builtin-markup-command (sharp layout props)
2326 "Draw a sharp symbol.
2328 @lilypond[verbatim,quote]
2333 (interpret-markup layout props (markup #:musicglyph (assoc-get 1/2 standard-alteration-glyph-name-alist ""))))
2335 (define-builtin-markup-command (semisharp layout props)
2339 "Draw a semisharp symbol.
2341 @lilypond[verbatim,quote]
2346 (interpret-markup layout props (markup #:musicglyph (assoc-get 1/4 standard-alteration-glyph-name-alist ""))))
2348 (define-builtin-markup-command (natural layout props)
2352 "Draw a natural symbol.
2354 @lilypond[verbatim,quote]
2359 (interpret-markup layout props (markup #:musicglyph (assoc-get 0 standard-alteration-glyph-name-alist ""))))
2361 (define-builtin-markup-command (semiflat layout props)
2365 "Draw a semiflat symbol.
2367 @lilypond[verbatim,quote]
2372 (interpret-markup layout props (markup #:musicglyph (assoc-get -1/4 standard-alteration-glyph-name-alist ""))))
2374 (define-builtin-markup-command (flat layout props)
2378 "Draw a flat symbol.
2380 @lilypond[verbatim,quote]
2385 (interpret-markup layout props (markup #:musicglyph (assoc-get -1/2 standard-alteration-glyph-name-alist ""))))
2387 (define-builtin-markup-command (sesquiflat layout props)
2391 "Draw a 3/2 flat symbol.
2393 @lilypond[verbatim,quote]
2398 (interpret-markup layout props (markup #:musicglyph (assoc-get -3/4 standard-alteration-glyph-name-alist ""))))
2400 (define-builtin-markup-command (doubleflat layout props)
2404 "Draw a double flat symbol.
2406 @lilypond[verbatim,quote]
2411 (interpret-markup layout props (markup #:musicglyph (assoc-get -1 standard-alteration-glyph-name-alist ""))))
2413 (define-builtin-markup-command (with-color layout props color arg)
2418 @cindex coloring text
2420 Draw @var{arg} in color specified by @var{color}.
2422 @lilypond[verbatim,quote]
2434 (let ((stil (interpret-markup layout props arg)))
2435 (ly:make-stencil (list 'color color (ly:stencil-expr stil))
2436 (ly:stencil-extent stil X)
2437 (ly:stencil-extent stil Y))))
2439 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2441 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2443 (define-builtin-markup-command (arrow-head layout props axis dir filled)
2444 (integer? ly:dir? boolean?)
2447 "Produce an arrow head in specified direction and axis.
2448 Use the filled head if @var{filled} is specified.
2449 @lilypond[verbatim,quote]
2452 \\general-align #Y #DOWN {
2453 \\arrow-head #Y #UP ##t
2454 \\arrow-head #Y #DOWN ##f
2456 \\arrow-head #X #RIGHT ##f
2457 \\arrow-head #X #LEFT ##f
2463 ((name (format "arrowheads.~a.~a~a"
2470 (ly:paper-get-font layout (cons '((font-encoding . fetaMusic))
2474 (define-builtin-markup-command (musicglyph layout props glyph-name)
2478 "@var{glyph-name} is converted to a musical symbol; for example,
2479 @code{\\musicglyph #\"accidentals.natural\"} selects the natural sign from
2480 the music font. See @ruser{The Feta font} for a complete listing of
2481 the possible glyphs.
2483 @lilypond[verbatim,quote]
2486 \\musicglyph #\"rests.2\"
2487 \\musicglyph #\"clefs.G_change\"
2490 (let* ((font (ly:paper-get-font layout
2491 (cons '((font-encoding . fetaMusic)
2495 (glyph (ly:font-get-glyph font glyph-name)))
2496 (if (null? (ly:stencil-expr glyph))
2497 (ly:warning (_ "Cannot find glyph ~a") glyph-name))
2502 (define-builtin-markup-command (lookup layout props glyph-name)
2506 "Lookup a glyph by name.
2508 @lilypond[verbatim,quote]
2510 \\override #'(font-encoding . fetaBraces) {
2511 \\lookup #\"brace200\"
2514 \\lookup #\"brace180\"
2518 (ly:font-get-glyph (ly:paper-get-font layout props)
2521 (define-builtin-markup-command (char layout props num)
2525 "Produce a single character. Characters encoded in hexadecimal
2526 format require the prefix @code{#x}.
2528 @lilypond[verbatim,quote]
2530 \\char #65 \\char ##x00a9
2533 (ly:text-interface::interpret-markup layout props (ly:wide-char->utf-8 num)))
2535 (define number->mark-letter-vector (make-vector 25 #\A))
2540 (if (= i (- (char->integer #\I) (char->integer #\A)))
2542 (vector-set! number->mark-letter-vector j
2543 (integer->char (+ i (char->integer #\A)))))
2545 (define number->mark-alphabet-vector (list->vector
2546 (map (lambda (i) (integer->char (+ i (char->integer #\A)))) (iota 26))))
2548 (define (number->markletter-string vec n)
2549 "Double letters for big marks."
2550 (let* ((lst (vector-length vec)))
2553 (string-append (number->markletter-string vec (1- (quotient n lst)))
2554 (number->markletter-string vec (remainder n lst)))
2555 (make-string 1 (vector-ref vec n)))))
2557 (define-builtin-markup-command (markletter layout props num)
2561 "Make a markup letter for @var{num}. The letters start with A to@tie{}Z
2562 (skipping letter@tie{}I), and continue with double letters.
2564 @lilypond[verbatim,quote]
2571 (ly:text-interface::interpret-markup layout props
2572 (number->markletter-string number->mark-letter-vector num)))
2574 (define-builtin-markup-command (markalphabet layout props num)
2578 "Make a markup letter for @var{num}. The letters start with A to@tie{}Z
2579 and continue with double letters.
2581 @lilypond[verbatim,quote]
2588 (ly:text-interface::interpret-markup layout props
2589 (number->markletter-string number->mark-alphabet-vector num)))
2591 (define-public (horizontal-slash-interval num forward number-interval mag)
2593 (cond ;((= num 6) (interval-widen number-interval (* mag 0.5)))
2594 ;((= num 5) (interval-widen number-interval (* mag 0.5)))
2595 (else (interval-widen number-interval (* mag 0.25))))
2596 (cond ((= num 6) (interval-widen number-interval (* mag 0.5)))
2597 ;((= num 5) (interval-widen number-interval (* mag 0.5)))
2598 (else (interval-widen number-interval (* mag 0.25))))
2601 (define-public (adjust-slash-stencil num forward stencil mag)
2604 (ly:stencil-translate stencil (cons (* mag -0.00) (* mag 0.2))))
2606 (ly:stencil-translate stencil (cons (* mag -0.00) (* mag 0.2))))
2608 ;(ly:stencil-translate stencil (cons (* mag -0.00) (* mag -0.07))))
2610 ; (ly:stencil-translate stencil (cons (* mag -0.00) (* mag -0.15))))
2613 (ly:stencil-translate stencil (cons (* mag -0.00) (* mag 0.15))))
2615 ; (ly:stencil-translate stencil (cons (* mag -0.00) (* mag -0.15))))
2620 (define (slashed-digit-internal layout props num forward font-size thickness)
2621 (let* ((mag (magstep font-size))
2623 (ly:output-def-lookup layout 'line-thickness)
2625 ; backward slashes might use slope and point in the other direction!
2626 (dy (* mag (if forward 0.4 -0.4)))
2627 (number-stencil (interpret-markup layout
2628 (prepend-alist-chain 'font-encoding 'fetaNumber props)
2629 (number->string num)))
2630 (num-x (horizontal-slash-interval num forward (ly:stencil-extent number-stencil X) mag))
2631 (center (interval-center (ly:stencil-extent number-stencil Y)))
2632 ; Use the real extents of the slash, not the whole number, because we
2633 ; might translate the slash later on!
2634 (num-y (interval-widen (cons center center) (abs dy)))
2635 (is-sane (and (interval-sane? num-x) (interval-sane? num-y)))
2636 (slash-stencil (if is-sane
2637 (make-line-stencil thickness
2638 (car num-x) (- (interval-center num-y) dy)
2639 (cdr num-x) (+ (interval-center num-y) dy))
2641 (if (ly:stencil? slash-stencil)
2643 ; for some numbers we need to shift the slash/backslash up or down to make
2644 ; the slashed digit look better
2645 (set! slash-stencil (adjust-slash-stencil num forward slash-stencil mag))
2646 (set! number-stencil
2647 (ly:stencil-add number-stencil slash-stencil)))
2648 (ly:warning "Unable to create slashed digit ~a" num))
2652 (define-builtin-markup-command (slashed-digit layout props num)
2658 @cindex slashed digits
2660 A feta number, with slash. This is for use in the context of
2661 figured bass notation.
2662 @lilypond[verbatim,quote]
2666 \\override #'(thickness . 3)
2670 (slashed-digit-internal layout props num #t font-size thickness))
2672 (define-builtin-markup-command (backslashed-digit layout props num)
2678 @cindex backslashed digits
2680 A feta number, with backslash. This is for use in the context of
2681 figured bass notation.
2682 @lilypond[verbatim,quote]
2684 \\backslashed-digit #5
2686 \\override #'(thickness . 3)
2687 \\backslashed-digit #7
2690 (slashed-digit-internal layout props num #f font-size thickness))
2693 (define eyeglassesps
2698 0.7 0.7 0.5 0 361 arc
2700 2.20 0.70 0.50 0 361 arc
2702 1.45 0.85 0.30 0 180 arc
2706 0.92 2.26 1.30 2.40 1.15 1.70 curveto
2710 3.42 2.26 3.80 2.40 3.65 1.70 curveto
2713 (define-builtin-markup-command (eyeglasses layout props) () other ()
2714 "Prints out eyeglasses, indicating strongly to look at the conductor.
2715 @lilypond[verbatim,quote]
2716 \\markup { \\eyeglasses }
2718 (interpret-markup layout props
2719 (make-with-dimensions-markup '(-0.61 . 3.22) '(0.2 . 2.41)
2720 (make-postscript-markup eyeglassesps))))
2722 (define-builtin-markup-command (left-brace layout props size)
2727 A feta brace in point size @var{size}.
2729 @lilypond[verbatim,quote]
2736 (let* ((font (ly:paper-get-font layout
2737 (cons '((font-encoding . fetaBraces)
2740 (glyph-count (1- (ly:otf-glyph-count font)))
2741 (scale (ly:output-def-lookup layout 'output-scale))
2742 (scaled-size (/ (ly:pt size) scale))
2744 (ly:font-get-glyph font (string-append "brace"
2745 (number->string n)))))
2746 (get-y-from-brace (lambda (brace)
2748 (ly:stencil-extent (glyph brace) Y))))
2749 (find-brace (binary-search 0 glyph-count get-y-from-brace scaled-size))
2750 (glyph-found (glyph find-brace)))
2752 (if (or (null? (ly:stencil-expr glyph-found))
2753 (< scaled-size (interval-length (ly:stencil-extent (glyph 0) Y)))
2754 (> scaled-size (interval-length
2755 (ly:stencil-extent (glyph glyph-count) Y))))
2757 (ly:warning (_ "no brace found for point size ~S ") size)
2758 (ly:warning (_ "defaulting to ~S pt")
2759 (/ (* scale (interval-length
2760 (ly:stencil-extent glyph-found Y)))
2764 (define-builtin-markup-command (right-brace layout props size)
2769 A feta brace in point size @var{size}, rotated 180 degrees.
2771 @lilypond[verbatim,quote]
2778 (interpret-markup layout props (markup #:rotate 180 #:left-brace size)))
2780 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2781 ;; the note command.
2782 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2784 ;; TODO: better syntax.
2786 (define-builtin-markup-command (note-by-number layout props log dot-count dir)
2787 (number? number? number?)
2792 @cindex notes within text by log and dot-count
2794 Construct a note symbol, with stem. By using fractional values for
2795 @var{dir}, longer or shorter stems can be obtained.
2797 @lilypond[verbatim,quote]
2799 \\note-by-number #3 #0 #DOWN
2801 \\note-by-number #1 #2 #0.8
2804 (define (get-glyph-name-candidates dir log style)
2805 (map (lambda (dir-name)
2806 (format "noteheads.~a~a~a" dir-name (min log 2)
2807 (if (and (symbol? style)
2808 (not (equal? 'default style)))
2809 (symbol->string style)
2811 (list (if (= dir UP) "u" "d")
2814 (define (get-glyph-name font cands)
2817 (if (ly:stencil-empty? (ly:font-get-glyph font (car cands)))
2818 (get-glyph-name font (cdr cands))
2821 (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) props)))
2822 (size-factor (magstep font-size))
2823 (stem-length (* size-factor (max 3 (- log 1))))
2824 (head-glyph-name (get-glyph-name font (get-glyph-name-candidates (sign dir) log style)))
2825 (head-glyph (ly:font-get-glyph font head-glyph-name))
2826 (attach-indices (ly:note-head::stem-attachment font head-glyph-name))
2827 (stem-thickness (* size-factor 0.13))
2828 (stemy (* dir stem-length))
2829 (attach-off (cons (interval-index
2830 (ly:stencil-extent head-glyph X)
2831 (* (sign dir) (car attach-indices)))
2832 (* (sign dir) ; fixme, this is inconsistent between X & Y.
2834 (ly:stencil-extent head-glyph Y)
2835 (cdr attach-indices)))))
2836 (stem-glyph (and (> log 0)
2837 (ly:round-filled-box
2838 (ordered-cons (car attach-off)
2839 (+ (car attach-off) (* (- (sign dir)) stem-thickness)))
2840 (cons (min stemy (cdr attach-off))
2841 (max stemy (cdr attach-off)))
2842 (/ stem-thickness 3))))
2844 (dot (ly:font-get-glyph font "dots.dot"))
2845 (dotwid (interval-length (ly:stencil-extent dot X)))
2846 (dots (and (> dot-count 0)
2847 (apply ly:stencil-add
2849 (ly:stencil-translate-axis
2850 dot (* 2 x dotwid) X))
2851 (iota dot-count)))))
2852 (flaggl (and (> log 2)
2853 (ly:stencil-translate
2854 (ly:font-get-glyph font
2855 (string-append "flags."
2856 (if (> dir 0) "u" "d")
2857 (number->string log)))
2858 (cons (+ (car attach-off) (if (< dir 0) stem-thickness 0)) stemy)))))
2860 ; If there is a flag on an upstem and the stem is short, move the dots to avoid the flag.
2861 ; 16th notes get a special case because their flags hang lower than any other flags.
2862 (if (and dots (> dir 0) (> log 2) (or (< dir 1.15) (and (= log 4) (< dir 1.3))))
2863 (set! dots (ly:stencil-translate-axis dots 0.5 X)))
2865 (set! stem-glyph (ly:stencil-add flaggl stem-glyph)))
2866 (if (ly:stencil? stem-glyph)
2867 (set! stem-glyph (ly:stencil-add stem-glyph head-glyph))
2868 (set! stem-glyph head-glyph))
2869 (if (ly:stencil? dots)
2872 (ly:stencil-translate-axis
2874 (+ (cdr (ly:stencil-extent head-glyph X)) dotwid)
2880 (let ((divisor (log 2)))
2881 (lambda (z) (inexact->exact (/ (log z) divisor)))))
2883 (define (parse-simple-duration duration-string)
2884 "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a (log dots) list."
2885 (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string)))
2886 (if (and match (string=? duration-string (match:substring match 0)))
2887 (let ((len (match:substring match 1))
2888 (dots (match:substring match 2)))
2889 (list (cond ((string=? len "breve") -1)
2890 ((string=? len "longa") -2)
2891 ((string=? len "maxima") -3)
2892 (else (log2 (string->number len))))
2893 (if dots (string-length dots) 0)))
2894 (ly:error (_ "not a valid duration string: ~a") duration-string))))
2896 (define-builtin-markup-command (note layout props duration dir)
2899 (note-by-number-markup)
2901 @cindex notes within text by string
2903 This produces a note with a stem pointing in @var{dir} direction, with
2904 the @var{duration} for the note head type and augmentation dots. For
2905 example, @code{\\note #\"4.\" #-0.75} creates a dotted quarter note, with
2906 a shortened down stem.
2908 @lilypond[verbatim,quote]
2910 \\override #'(style . cross) {
2914 \\note #\"breve\" #0
2917 (let ((parsed (parse-simple-duration duration)))
2918 (note-by-number-markup layout props (car parsed) (cadr parsed) dir)))
2920 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2922 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2924 (define-builtin-markup-command (lower layout props amount arg)
2929 @cindex lowering text
2931 Lower @var{arg} by the distance @var{amount}.
2932 A negative @var{amount} indicates raising; see also @code{\\raise}.
2934 @lilypond[verbatim,quote]
2942 (ly:stencil-translate-axis (interpret-markup layout props arg)
2945 (define-builtin-markup-command (translate-scaled layout props offset arg)
2946 (number-pair? markup?)
2950 @cindex translating text
2951 @cindex scaling text
2953 Translate @var{arg} by @var{offset}, scaling the offset by the
2956 @lilypond[verbatim,quote]
2959 * \\translate #'(2 . 3) translate
2961 * \\translate-scaled #'(2 . 3) translate-scaled
2965 (let* ((factor (magstep font-size))
2966 (scaled (cons (* factor (car offset))
2967 (* factor (cdr offset)))))
2968 (ly:stencil-translate (interpret-markup layout props arg)
2971 (define-builtin-markup-command (raise layout props amount arg)
2976 @cindex raising text
2978 Raise @var{arg} by the distance @var{amount}.
2979 A negative @var{amount} indicates lowering, see also @code{\\lower}.
2981 The argument to @code{\\raise} is the vertical displacement amount,
2982 measured in (global) staff spaces. @code{\\raise} and @code{\\super}
2983 raise objects in relation to their surrounding markups.
2985 If the text object itself is positioned above or below the staff, then
2986 @code{\\raise} cannot be used to move it, since the mechanism that
2987 positions it next to the staff cancels any shift made with
2988 @code{\\raise}. For vertical positioning, use the @code{padding}
2989 and/or @code{extra-offset} properties.
2991 @lilypond[verbatim,quote]
3000 (ly:stencil-translate-axis (interpret-markup layout props arg) amount Y))
3002 (define-builtin-markup-command (fraction layout props arg1 arg2)
3007 @cindex creating text fractions
3009 Make a fraction of two markups.
3010 @lilypond[verbatim,quote]
3016 (let* ((m1 (interpret-markup layout props arg1))
3017 (m2 (interpret-markup layout props arg2))
3018 (factor (magstep font-size))
3019 (boxdimen (cons (* factor -0.05) (* factor 0.05)))
3020 (padding (* factor 0.2))
3021 (baseline (* factor 0.6))
3022 (offset (* factor 0.75)))
3023 (set! m1 (ly:stencil-aligned-to m1 X CENTER))
3024 (set! m2 (ly:stencil-aligned-to m2 X CENTER))
3025 (let* ((x1 (ly:stencil-extent m1 X))
3026 (x2 (ly:stencil-extent m2 X))
3027 (line (ly:round-filled-box (interval-union x1 x2) boxdimen 0.0))
3028 ;; should stack mols separately, to maintain LINE on baseline
3029 (stack (stack-lines DOWN padding baseline (list m1 line m2))))
3031 (ly:stencil-aligned-to stack Y CENTER))
3033 (ly:stencil-aligned-to stack X LEFT))
3034 ;; should have EX dimension
3036 (ly:stencil-translate-axis stack offset Y))))
3038 (define-builtin-markup-command (normal-size-super layout props arg)
3043 @cindex setting superscript in standard font size
3045 Set @var{arg} in superscript with a normal font size.
3047 @lilypond[verbatim,quote]
3050 \\normal-size-super {
3051 superscript in standard size
3055 (ly:stencil-translate-axis
3056 (interpret-markup layout props arg)
3057 (* 0.5 baseline-skip) Y))
3059 (define-builtin-markup-command (super layout props arg)
3065 @cindex superscript text
3067 Set @var{arg} in superscript.
3069 @lilypond[verbatim,quote]
3079 (ly:stencil-translate-axis
3082 (cons `((font-size . ,(- font-size 3))) props)
3084 (* 0.5 baseline-skip)
3087 (define-builtin-markup-command (translate layout props offset arg)
3088 (number-pair? markup?)
3092 @cindex translating text
3094 Translate @var{arg} relative to its surroundings. @var{offset}
3095 is a pair of numbers representing the displacement in the X and Y axis.
3097 @lilypond[verbatim,quote]
3100 \\translate #'(2 . 3)
3101 \\line { translated two spaces right, three up }
3104 (ly:stencil-translate (interpret-markup layout props arg)
3107 (define-builtin-markup-command (sub layout props arg)
3113 @cindex subscript text
3115 Set @var{arg} in subscript.
3117 @lilypond[verbatim,quote]
3128 (ly:stencil-translate-axis
3131 (cons `((font-size . ,(- font-size 3))) props)
3133 (* -0.5 baseline-skip)
3136 (define-builtin-markup-command (normal-size-sub layout props arg)
3141 @cindex setting subscript in standard font size
3143 Set @var{arg} in subscript with a normal font size.
3145 @lilypond[verbatim,quote]
3149 subscript in standard size
3153 (ly:stencil-translate-axis
3154 (interpret-markup layout props arg)
3155 (* -0.5 baseline-skip)
3158 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3160 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3162 (define-builtin-markup-command (hbracket layout props arg)
3167 @cindex placing horizontal brackets around text
3169 Draw horizontal brackets around @var{arg}.
3171 @lilypond[verbatim,quote]
3180 (let ((th 0.1) ;; todo: take from GROB.
3181 (m (interpret-markup layout props arg)))
3182 (bracketify-stencil m X th (* 2.5 th) th)))
3184 (define-builtin-markup-command (bracket layout props arg)
3189 @cindex placing vertical brackets around text
3191 Draw vertical brackets around @var{arg}.
3193 @lilypond[verbatim,quote]
3200 (let ((th 0.1) ;; todo: take from GROB.
3201 (m (interpret-markup layout props arg)))
3202 (bracketify-stencil m Y th (* 2.5 th) th)))
3204 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3205 ;; Delayed markup evaluation
3206 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3208 (define-builtin-markup-command (page-ref layout props label gauge default)
3209 (symbol? markup? markup?)
3213 @cindex referencing page numbers in text
3215 Reference to a page number. @var{label} is the label set on the referenced
3216 page (using the @code{\\label} command), @var{gauge} a markup used to estimate
3217 the maximum width of the page number, and @var{default} the value to display
3218 when @var{label} is not found."
3219 (let* ((gauge-stencil (interpret-markup layout props gauge))
3220 (x-ext (ly:stencil-extent gauge-stencil X))
3221 (y-ext (ly:stencil-extent gauge-stencil Y)))
3223 `(delay-stencil-evaluation
3224 ,(delay (ly:stencil-expr
3225 (let* ((table (ly:output-def-lookup layout 'label-page-table))
3226 (page-number (if (list? table)
3227 (assoc-get label table)
3229 (page-markup (if page-number (format "~a" page-number) default))
3230 (page-stencil (interpret-markup layout props page-markup))
3231 (gap (- (interval-length x-ext)
3232 (interval-length (ly:stencil-extent page-stencil X)))))
3233 (interpret-markup layout props
3234 (markup #:concat (#:hspace gap page-markup)))))))
3238 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3239 ;; Markup list commands
3240 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3242 (define-public (space-lines baseline stils)
3243 (let space-stil ((stils stils)
3247 (let* ((stil (car stils))
3248 (dy-top (max (- (/ baseline 1.5)
3249 (interval-bound (ly:stencil-extent stil Y) UP))
3251 (dy-bottom (max (+ (/ baseline 3.0)
3252 (interval-bound (ly:stencil-extent stil Y) DOWN))
3254 (new-stil (ly:make-stencil
3255 (ly:stencil-expr stil)
3256 (ly:stencil-extent stil X)
3257 (cons (- (interval-bound (ly:stencil-extent stil Y) DOWN)
3259 (+ (interval-bound (ly:stencil-extent stil Y) UP)
3261 (space-stil (cdr stils) (cons new-stil result))))))
3263 (define-builtin-markup-list-command (justified-lines layout props args)
3266 wordwrap-internal-markup-list)
3268 @cindex justifying lines of text
3270 Like @code{\\justify}, but return a list of lines instead of a single markup.
3271 Use @code{\\override-lines #'(line-width . @var{X})} to set the line width;
3272 @var{X}@tie{}is the number of staff spaces."
3273 (space-lines baseline-skip
3274 (interpret-markup-list layout props
3275 (make-wordwrap-internal-markup-list #t args))))
3277 (define-builtin-markup-list-command (wordwrap-lines layout props args)
3280 wordwrap-internal-markup-list)
3281 "Like @code{\\wordwrap}, but return a list of lines instead of a single markup.
3282 Use @code{\\override-lines #'(line-width . @var{X})} to set the line width,
3283 where @var{X} is the number of staff spaces."
3284 (space-lines baseline-skip
3285 (interpret-markup-list layout props
3286 (make-wordwrap-internal-markup-list #f args))))
3288 (define-builtin-markup-list-command (column-lines layout props args)
3291 "Like @code{\\column}, but return a list of lines instead of a single markup.
3292 @code{baseline-skip} determines the space between each markup in @var{args}."
3293 (space-lines (chain-assoc-get 'baseline-skip props)
3294 (interpret-markup-list layout props args)))
3296 (define-builtin-markup-list-command (override-lines layout props new-prop args)
3297 (pair? markup-list?)
3299 "Like @code{\\override}, for markup lists."
3300 (interpret-markup-list layout (cons (list new-prop) props) args))