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 (line-width (or line-width (ly:output-def-lookup layout 'line-width)))
832 (/ (- line-width text-width) 2)
833 (/ (- line-width text-width) 2)))
836 (- line-width text-width)))
838 (get-fill-space word-count line-width text-widths))))
846 (line-stencils (if (= word-count 1)
853 (if (= text-direction LEFT)
854 (set! line-stencils (reverse line-stencils)))
856 (if (null? (remove ly:stencil-empty? orig-stencils))
858 (stack-stencils-padding-list X
859 RIGHT fill-space-normal line-stencils))))
861 (define-builtin-markup-command (line layout props args)
865 (text-direction RIGHT))
866 "Put @var{args} in a horizontal line. The property @code{word-space}
867 determines the space between markups in @var{args}.
869 @lilypond[verbatim,quote]
876 (let ((stencils (interpret-markup-list layout props args)))
877 (if (= text-direction LEFT)
878 (set! stencils (reverse stencils)))
881 (remove ly:stencil-empty? stencils))))
883 (define-builtin-markup-command (concat layout props args)
888 @cindex concatenating text
889 @cindex ligatures in text
891 Concatenate @var{args} in a horizontal line, without spaces in between.
892 Strings and simple markups are concatenated on the input level, allowing
893 ligatures. For example, @code{\\concat @{ \"f\" \\simple #\"i\" @}} is
894 equivalent to @code{\"fi\"}.
896 @lilypond[verbatim,quote]
905 (define (concat-string-args arg-list)
906 (fold-right (lambda (arg result-list)
907 (let ((result (if (pair? result-list)
910 (if (and (pair? arg) (eqv? (car arg) simple-markup))
911 (set! arg (cadr arg)))
912 (if (and (string? result) (string? arg))
913 (cons (string-append arg result) (cdr result-list))
914 (cons arg result-list))))
918 (interpret-markup layout
919 (prepend-alist-chain 'word-space 0 props)
920 (make-line-markup (if (markup-command-list? args)
922 (concat-string-args args)))))
924 (define (wordwrap-stencils stencils
925 justify base-space line-width text-dir)
926 "Perform simple wordwrap, return stencil of each line."
927 (define space (if justify
928 ;; justify only stretches lines.
931 (define (take-list width space stencils
932 accumulator accumulated-width)
933 "Return (head-list . tail) pair, with head-list fitting into width"
935 (cons accumulator stencils)
936 (let* ((first (car stencils))
937 (first-wid (cdr (ly:stencil-extent (car stencils) X)))
938 (newwid (+ space first-wid accumulated-width)))
939 (if (or (null? accumulator)
941 (take-list width space
943 (cons first accumulator)
945 (cons accumulator stencils)))))
946 (let loop ((lines '())
948 (let* ((line-break (take-list line-width space todo
950 (line-stencils (car line-break))
951 (space-left (- line-width
952 (apply + (map (lambda (x) (cdr (ly:stencil-extent x X)))
954 (line-word-space (cond ((not justify) space)
955 ;; don't stretch last line of paragraph.
956 ;; hmmm . bug - will overstretch the last line in some case.
957 ((null? (cdr line-break))
959 ((null? line-stencils) 0.0)
960 ((null? (cdr line-stencils)) 0.0)
961 (else (/ space-left (1- (length line-stencils))))))
962 (line (stack-stencil-line line-word-space
963 (if (= text-dir RIGHT)
964 (reverse line-stencils)
966 (if (pair? (cdr line-break))
967 (loop (cons line lines)
970 (if (= text-dir LEFT)
972 (ly:stencil-translate-axis
974 (- line-width (interval-end (ly:stencil-extent line X)))
976 (reverse (cons line lines)))))))
978 (define-builtin-markup-list-command (wordwrap-internal layout props justify args)
979 (boolean? markup-list?)
982 (text-direction RIGHT))
983 "Internal markup list command used to define @code{\\justify} and @code{\\wordwrap}."
984 (wordwrap-stencils (remove ly:stencil-empty?
985 (interpret-markup-list layout props args))
989 (ly:output-def-lookup layout 'line-width))
992 (define-builtin-markup-command (justify layout props args)
996 wordwrap-internal-markup-list)
998 @cindex justifying text
1000 Like @code{\\wordwrap}, but with lines stretched to justify the margins.
1001 Use @code{\\override #'(line-width . @var{X})} to set the line width;
1002 @var{X}@tie{}is the number of staff spaces.
1004 @lilypond[verbatim,quote]
1007 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
1008 do eiusmod tempor incididunt ut labore et dolore magna aliqua.
1009 Ut enim ad minim veniam, quis nostrud exercitation ullamco
1010 laboris nisi ut aliquip ex ea commodo consequat.
1014 (stack-lines DOWN 0.0 baseline-skip
1015 (wordwrap-internal-markup-list layout props #t args)))
1017 (define-builtin-markup-command (wordwrap layout props args)
1021 wordwrap-internal-markup-list)
1022 "Simple wordwrap. Use @code{\\override #'(line-width . @var{X})} to set
1023 the line width, where @var{X} is the number of staff spaces.
1025 @lilypond[verbatim,quote]
1028 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
1029 do eiusmod tempor incididunt ut labore et dolore magna aliqua.
1030 Ut enim ad minim veniam, quis nostrud exercitation ullamco
1031 laboris nisi ut aliquip ex ea commodo consequat.
1035 (stack-lines DOWN 0.0 baseline-skip
1036 (wordwrap-internal-markup-list layout props #f args)))
1038 (define-builtin-markup-list-command (wordwrap-string-internal layout props justify arg)
1042 (text-direction RIGHT))
1043 "Internal markup list command used to define @code{\\justify-string} and
1044 @code{\\wordwrap-string}."
1045 (let* ((para-strings (regexp-split
1046 (string-regexp-substitute
1048 (string-regexp-substitute "\r\n" "\n" arg))
1049 "\n[ \t\n]*\n[ \t\n]*"))
1050 (list-para-words (map (lambda (str)
1051 (regexp-split str "[ \t\n]+"))
1053 (para-lines (map (lambda (words)
1055 (remove ly:stencil-empty?
1057 (interpret-markup layout props x))
1059 (wordwrap-stencils stencils
1061 line-width text-direction)))
1063 (apply append para-lines)))
1065 (define-builtin-markup-command (wordwrap-string layout props arg)
1069 wordwrap-string-internal-markup-list)
1070 "Wordwrap a string. Paragraphs may be separated with double newlines.
1072 @lilypond[verbatim,quote]
1074 \\override #'(line-width . 40)
1075 \\wordwrap-string #\"Lorem ipsum dolor sit amet, consectetur
1076 adipisicing elit, sed do eiusmod tempor incididunt ut labore
1077 et dolore magna aliqua.
1080 Ut enim ad minim veniam, quis nostrud exercitation ullamco
1081 laboris nisi ut aliquip ex ea commodo consequat.
1084 Excepteur sint occaecat cupidatat non proident, sunt in culpa
1085 qui officia deserunt mollit anim id est laborum\"
1088 (stack-lines DOWN 0.0 baseline-skip
1089 (wordwrap-string-internal-markup-list layout props #f arg)))
1091 (define-builtin-markup-command (justify-string layout props arg)
1095 wordwrap-string-internal-markup-list)
1096 "Justify a string. Paragraphs may be separated with double newlines
1098 @lilypond[verbatim,quote]
1100 \\override #'(line-width . 40)
1101 \\justify-string #\"Lorem ipsum dolor sit amet, consectetur
1102 adipisicing elit, sed do eiusmod tempor incididunt ut labore
1103 et dolore magna aliqua.
1106 Ut enim ad minim veniam, quis nostrud exercitation ullamco
1107 laboris nisi ut aliquip ex ea commodo consequat.
1110 Excepteur sint occaecat cupidatat non proident, sunt in culpa
1111 qui officia deserunt mollit anim id est laborum\"
1114 (stack-lines DOWN 0.0 baseline-skip
1115 (wordwrap-string-internal-markup-list layout props #t arg)))
1117 (define-builtin-markup-command (wordwrap-field layout props symbol)
1121 "Wordwrap the data which has been assigned to @var{symbol}.
1123 @lilypond[verbatim,quote]
1125 title = \"My title\"
1126 myText = \"Lorem ipsum dolor sit amet, consectetur adipisicing
1127 elit, sed do eiusmod tempor incididunt ut labore et dolore magna
1128 aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
1129 laboris nisi ut aliquip ex ea commodo consequat.\"
1133 bookTitleMarkup = \\markup {
1135 \\fill-line { \\fromproperty #'header:title }
1137 \\wordwrap-field #'header:myText
1146 (let* ((m (chain-assoc-get symbol props)))
1148 (wordwrap-string-markup layout props m)
1151 (define-builtin-markup-command (justify-field layout props symbol)
1155 "Justify the data which has been assigned to @var{symbol}.
1157 @lilypond[verbatim,quote]
1159 title = \"My title\"
1160 myText = \"Lorem ipsum dolor sit amet, consectetur adipisicing
1161 elit, sed do eiusmod tempor incididunt ut labore et dolore magna
1162 aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
1163 laboris nisi ut aliquip ex ea commodo consequat.\"
1167 bookTitleMarkup = \\markup {
1169 \\fill-line { \\fromproperty #'header:title }
1171 \\justify-field #'header:myText
1180 (let* ((m (chain-assoc-get symbol props)))
1182 (justify-string-markup layout props m)
1185 (define-builtin-markup-command (combine layout props arg1 arg2)
1190 @cindex merging text
1192 Print two markups on top of each other.
1194 Note: @code{\\combine} cannot take a list of markups enclosed in
1195 curly braces as an argument; the follow example will not compile:
1198 \\combine @{ a list @}
1201 @lilypond[verbatim,quote]
1204 \\override #'(thickness . 2)
1206 \\draw-line #'(0 . 4)
1207 \\arrow-head #Y #DOWN ##f
1210 (let* ((s1 (interpret-markup layout props arg1))
1211 (s2 (interpret-markup layout props arg2)))
1212 (ly:stencil-add s1 s2)))
1215 ;; TODO: should extract baseline-skip from each argument somehow..
1217 (define-builtin-markup-command (column layout props args)
1222 @cindex stacking text in a column
1224 Stack the markups in @var{args} vertically. The property
1225 @code{baseline-skip} determines the space between markups
1228 @lilypond[verbatim,quote]
1237 (let ((arg-stencils (interpret-markup-list layout props args)))
1238 (stack-lines -1 0.0 baseline-skip
1239 (remove ly:stencil-empty? arg-stencils))))
1241 (define-builtin-markup-command (dir-column layout props args)
1247 @cindex changing direction of text columns
1249 Make a column of @var{args}, going up or down, depending on the
1250 setting of the @code{direction} layout property.
1252 @lilypond[verbatim,quote]
1254 \\override #`(direction . ,UP) {
1264 \\override #'(direction . 1) {
1271 (stack-lines (if (number? direction) direction -1)
1274 (interpret-markup-list layout props args)))
1276 (define (general-column align-dir baseline mols)
1277 "Stack @var{mols} vertically, aligned to @var{align-dir} horizontally."
1279 (let* ((aligned-mols (map (lambda (x) (ly:stencil-aligned-to x X align-dir)) mols)))
1280 (stack-lines -1 0.0 baseline aligned-mols)))
1282 (define-builtin-markup-command (center-column layout props args)
1287 @cindex centering a column of text
1289 Put @code{args} in a centered column.
1291 @lilypond[verbatim,quote]
1300 (general-column CENTER baseline-skip (interpret-markup-list layout props args)))
1302 (define-builtin-markup-command (left-column layout props args)
1307 @cindex text columns, left-aligned
1309 Put @code{args} in a left-aligned column.
1311 @lilypond[verbatim,quote]
1320 (general-column LEFT baseline-skip (interpret-markup-list layout props args)))
1322 (define-builtin-markup-command (right-column layout props args)
1327 @cindex text columns, right-aligned
1329 Put @code{args} in a right-aligned column.
1331 @lilypond[verbatim,quote]
1340 (general-column RIGHT baseline-skip (interpret-markup-list layout props args)))
1342 (define-builtin-markup-command (vcenter layout props arg)
1347 @cindex vertically centering text
1349 Align @code{arg} to its Y@tie{}center.
1351 @lilypond[verbatim,quote]
1359 (let* ((mol (interpret-markup layout props arg)))
1360 (ly:stencil-aligned-to mol Y CENTER)))
1362 (define-builtin-markup-command (center-align layout props arg)
1367 @cindex horizontally centering text
1369 Align @code{arg} to its X@tie{}center.
1371 @lilypond[verbatim,quote]
1381 (let* ((mol (interpret-markup layout props arg)))
1382 (ly:stencil-aligned-to mol X CENTER)))
1384 (define-builtin-markup-command (right-align layout props arg)
1389 @cindex right aligning text
1391 Align @var{arg} on its right edge.
1393 @lilypond[verbatim,quote]
1403 (let* ((m (interpret-markup layout props arg)))
1404 (ly:stencil-aligned-to m X RIGHT)))
1406 (define-builtin-markup-command (left-align layout props arg)
1411 @cindex left aligning text
1413 Align @var{arg} on its left edge.
1415 @lilypond[verbatim,quote]
1425 (let* ((m (interpret-markup layout props arg)))
1426 (ly:stencil-aligned-to m X LEFT)))
1428 (define-builtin-markup-command (general-align layout props axis dir arg)
1429 (integer? number? markup?)
1433 @cindex controlling general text alignment
1435 Align @var{arg} in @var{axis} direction to the @var{dir} side.
1437 @lilypond[verbatim,quote]
1441 \\general-align #X #LEFT
1446 \\general-align #X #CENTER
1452 \\general-align #Y #UP
1459 \\general-align #Y #3.2
1466 (let* ((m (interpret-markup layout props arg)))
1467 (ly:stencil-aligned-to m axis dir)))
1469 (define-builtin-markup-command (halign layout props dir arg)
1474 @cindex setting horizontal text alignment
1476 Set horizontal alignment. If @var{dir} is @code{-1}, then it is
1477 left-aligned, while @code{+1} is right. Values in between interpolate
1478 alignment accordingly.
1480 @lilypond[verbatim,quote]
1505 (let* ((m (interpret-markup layout props arg)))
1506 (ly:stencil-aligned-to m X dir)))
1508 (define-builtin-markup-command (with-dimensions layout props x y arg)
1509 (number-pair? number-pair? markup?)
1513 @cindex setting extent of text objects
1515 Set the dimensions of @var{arg} to @var{x} and@tie{}@var{y}."
1516 (let* ((m (interpret-markup layout props arg)))
1517 (ly:make-stencil (ly:stencil-expr m) x y)))
1519 (define-builtin-markup-command (pad-around layout props amount arg)
1523 "Add padding @var{amount} all around @var{arg}.
1525 @lilypond[verbatim,quote]
1538 (let* ((m (interpret-markup layout props arg))
1539 (x (ly:stencil-extent m X))
1540 (y (ly:stencil-extent m Y)))
1541 (ly:make-stencil (ly:stencil-expr m)
1542 (interval-widen x amount)
1543 (interval-widen y amount))))
1545 (define-builtin-markup-command (pad-x layout props amount arg)
1550 @cindex padding text horizontally
1552 Add padding @var{amount} around @var{arg} in the X@tie{}direction.
1554 @lilypond[verbatim,quote]
1567 (let* ((m (interpret-markup layout props arg))
1568 (x (ly:stencil-extent m X))
1569 (y (ly:stencil-extent m Y)))
1570 (ly:make-stencil (ly:stencil-expr m)
1571 (interval-widen x amount)
1574 (define-builtin-markup-command (put-adjacent layout props axis dir arg1 arg2)
1575 (integer? ly:dir? markup? markup?)
1578 "Put @var{arg2} next to @var{arg1}, without moving @var{arg1}."
1579 (let ((m1 (interpret-markup layout props arg1))
1580 (m2 (interpret-markup layout props arg2)))
1581 (ly:stencil-combine-at-edge m1 axis dir m2 0.0)))
1583 (define-builtin-markup-command (transparent layout props arg)
1587 "Make @var{arg} transparent.
1589 @lilypond[verbatim,quote]
1596 (let* ((m (interpret-markup layout props arg))
1597 (x (ly:stencil-extent m X))
1598 (y (ly:stencil-extent m Y)))
1599 (ly:make-stencil "" x y)))
1601 (define-builtin-markup-command (pad-to-box layout props x-ext y-ext arg)
1602 (number-pair? number-pair? markup?)
1605 "Make @var{arg} take at least @var{x-ext}, @var{y-ext} space.
1607 @lilypond[verbatim,quote]
1614 \\pad-to-box #'(0 . 10) #'(0 . 3) {
1620 (let* ((m (interpret-markup layout props arg))
1621 (x (ly:stencil-extent m X))
1622 (y (ly:stencil-extent m Y)))
1623 (ly:make-stencil (ly:stencil-expr m)
1624 (interval-union x-ext x)
1625 (interval-union y-ext y))))
1627 (define-builtin-markup-command (hcenter-in layout props length arg)
1631 "Center @var{arg} horizontally within a box of extending
1632 @var{length}/2 to the left and right.
1634 @lilypond[quote,verbatim]
1637 \\set Staff.instrumentName = \\markup {
1644 \\set Staff.instrumentName = \\markup {
1653 (interpret-markup layout props
1654 (make-pad-to-box-markup
1655 (cons (/ length -2) (/ length 2))
1657 (make-center-align-markup arg))))
1659 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1661 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1663 (define-builtin-markup-command (fromproperty layout props symbol)
1667 "Read the @var{symbol} from property settings, and produce a stencil
1668 from the markup contained within. If @var{symbol} is not defined, it
1669 returns an empty markup.
1671 @lilypond[verbatim,quote]
1673 myTitle = \"myTitle\"
1677 \\fromproperty #'header:myTitle
1684 (let ((m (chain-assoc-get symbol props)))
1686 (interpret-markup layout props m)
1689 (define-builtin-markup-command (on-the-fly layout props procedure arg)
1693 "Apply the @var{procedure} markup command to @var{arg}.
1694 @var{procedure} should take a single argument."
1695 (let ((anonymous-with-signature (lambda (layout props arg) (procedure layout props arg))))
1696 (set-object-property! anonymous-with-signature
1699 (interpret-markup layout props (list anonymous-with-signature arg))))
1701 (define-builtin-markup-command (override layout props new-prop arg)
1706 @cindex overriding properties within text markup
1708 Add the argument @var{new-prop} to the property list. Properties
1709 may be any property supported by @rinternals{font-interface},
1710 @rinternals{text-interface} and
1711 @rinternals{instrument-specific-markup-interface}.
1713 @lilypond[verbatim,quote]
1721 \\override #'(baseline-skip . 4) {
1730 (interpret-markup layout (cons (list new-prop) props) arg))
1732 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1734 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1736 (define-builtin-markup-command (verbatim-file layout props name)
1740 "Read the contents of file @var{name}, and include it verbatim.
1742 @lilypond[verbatim,quote]
1744 \\verbatim-file #\"simple.ly\"
1747 (interpret-markup layout props
1748 (if (ly:get-option 'safe)
1749 "verbatim-file disabled in safe mode"
1750 (let* ((str (ly:gulp-file name))
1751 (lines (string-split str #\nl)))
1752 (make-typewriter-markup
1753 (make-column-markup lines))))))
1755 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1757 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1760 (define-builtin-markup-command (smaller layout props arg)
1764 "Decrease the font size relative to the current setting.
1766 @lilypond[verbatim,quote]
1779 (interpret-markup layout props
1780 `(,fontsize-markup -1 ,arg)))
1782 (define-builtin-markup-command (larger layout props arg)
1786 "Increase the font size relative to the current setting.
1788 @lilypond[verbatim,quote]
1796 (interpret-markup layout props
1797 `(,fontsize-markup 1 ,arg)))
1799 (define-builtin-markup-command (finger layout props arg)
1803 "Set @var{arg} as small numbers.
1805 @lilypond[verbatim,quote]
1812 (interpret-markup layout
1813 (cons '((font-size . -5) (font-encoding . fetaNumber)) props)
1816 (define-builtin-markup-command (abs-fontsize layout props size arg)
1820 "Use @var{size} as the absolute font size to display @var{arg}.
1821 Adjusts @code{baseline-skip} and @code{word-space} accordingly.
1823 @lilypond[verbatim,quote]
1825 default text font size
1827 \\abs-fontsize #16 { text font size 16 }
1829 \\abs-fontsize #12 { text font size 12 }
1832 (let* ((ref-size (ly:output-def-lookup layout 'text-font-size 12))
1833 (text-props (list (ly:output-def-lookup layout 'text-font-defaults)))
1834 (ref-word-space (chain-assoc-get 'word-space text-props 0.6))
1835 (ref-baseline (chain-assoc-get 'baseline-skip text-props 3))
1836 (magnification (/ size ref-size)))
1837 (interpret-markup layout
1838 (cons `((baseline-skip . ,(* magnification ref-baseline))
1839 (word-space . ,(* magnification ref-word-space))
1840 (font-size . ,(magnification->font-size magnification)))
1844 (define-builtin-markup-command (fontsize layout props increment arg)
1850 "Add @var{increment} to the font-size. Adjusts @code{baseline-skip}
1853 @lilypond[verbatim,quote]
1861 (let ((entries (list
1862 (cons 'baseline-skip (* baseline-skip (magstep increment)))
1863 (cons 'word-space (* word-space (magstep increment)))
1864 (cons 'font-size (+ font-size increment)))))
1865 (interpret-markup layout (cons entries props) arg)))
1867 (define-builtin-markup-command (magnify layout props sz arg)
1872 @cindex magnifying text
1874 Set the font magnification for its argument. In the following
1875 example, the middle@tie{}A is 10% larger:
1878 A \\magnify #1.1 @{ A @} A
1881 Note: Magnification only works if a font name is explicitly selected.
1882 Use @code{\\fontsize} otherwise.
1884 @lilypond[verbatim,quote]
1895 (prepend-alist-chain 'font-size (magnification->font-size sz) props)
1898 (define-builtin-markup-command (bold layout props arg)
1902 "Switch to bold font-series.
1904 @lilypond[verbatim,quote]
1912 (interpret-markup layout (prepend-alist-chain 'font-series 'bold props) arg))
1914 (define-builtin-markup-command (sans layout props arg)
1918 "Switch to the sans serif font family.
1920 @lilypond[verbatim,quote]
1929 (interpret-markup layout (prepend-alist-chain 'font-family 'sans props) arg))
1931 (define-builtin-markup-command (number layout props arg)
1935 "Set font family to @code{number}, which yields the font used for
1936 time signatures and fingerings. This font contains numbers and
1937 some punctuation; it has no letters.
1939 @lilypond[verbatim,quote]
1942 0 1 2 3 4 5 6 7 8 9 . ,
1946 (interpret-markup layout (prepend-alist-chain 'font-encoding 'fetaNumber props) arg))
1948 (define-builtin-markup-command (roman layout props arg)
1952 "Set font family to @code{roman}.
1954 @lilypond[verbatim,quote]
1960 text in roman font family
1967 (interpret-markup layout (prepend-alist-chain 'font-family 'roman props) arg))
1969 (define-builtin-markup-command (huge layout props arg)
1973 "Set font size to +2.
1975 @lilypond[verbatim,quote]
1983 (interpret-markup layout (prepend-alist-chain 'font-size 2 props) arg))
1985 (define-builtin-markup-command (large layout props arg)
1989 "Set font size to +1.
1991 @lilypond[verbatim,quote]
1999 (interpret-markup layout (prepend-alist-chain 'font-size 1 props) arg))
2001 (define-builtin-markup-command (normalsize layout props arg)
2005 "Set font size to default.
2007 @lilypond[verbatim,quote]
2020 (interpret-markup layout (prepend-alist-chain 'font-size 0 props) arg))
2022 (define-builtin-markup-command (small layout props arg)
2026 "Set font size to -1.
2028 @lilypond[verbatim,quote]
2036 (interpret-markup layout (prepend-alist-chain 'font-size -1 props) arg))
2038 (define-builtin-markup-command (tiny layout props arg)
2042 "Set font size to -2.
2044 @lilypond[verbatim,quote]
2052 (interpret-markup layout (prepend-alist-chain 'font-size -2 props) arg))
2054 (define-builtin-markup-command (teeny layout props arg)
2058 "Set font size to -3.
2060 @lilypond[verbatim,quote]
2068 (interpret-markup layout (prepend-alist-chain 'font-size -3 props) arg))
2070 (define-builtin-markup-command (fontCaps layout props arg)
2074 "Set @code{font-shape} to @code{caps}
2076 Note: @code{\\fontCaps} requires the installation and selection of
2077 fonts which support the @code{caps} font shape."
2078 (interpret-markup layout (prepend-alist-chain 'font-shape 'caps props) arg))
2081 (define-builtin-markup-command (smallCaps layout props arg)
2085 "Emit @var{arg} as small caps.
2087 Note: @code{\\smallCaps} does not support accented characters.
2089 @lilypond[verbatim,quote]
2098 (define (char-list->markup chars lower)
2099 (let ((final-string (string-upcase (reverse-list->string chars))))
2101 (markup #:fontsize -2 final-string)
2103 (define (make-small-caps rest-chars currents current-is-lower prev-result)
2104 (if (null? rest-chars)
2106 (reverse! (cons (char-list->markup currents current-is-lower)
2108 (let* ((ch (car rest-chars))
2109 (is-lower (char-lower-case? ch)))
2110 (if (or (and current-is-lower is-lower)
2111 (and (not current-is-lower) (not is-lower)))
2112 (make-small-caps (cdr rest-chars)
2116 (make-small-caps (cdr rest-chars)
2119 (if (null? currents)
2121 (cons (char-list->markup
2122 currents current-is-lower)
2124 (interpret-markup layout props
2126 (make-small-caps (string->list arg) (list) #f (list))
2129 (define-builtin-markup-command (caps layout props arg)
2133 "Copy of the @code{\\smallCaps} command.
2135 @lilypond[verbatim,quote]
2144 (interpret-markup layout props (make-smallCaps-markup arg)))
2146 (define-builtin-markup-command (dynamic layout props arg)
2150 "Use the dynamic font. This font only contains @b{s}, @b{f}, @b{m},
2151 @b{z}, @b{p}, and @b{r}. When producing phrases, like
2152 @q{pi@`{u}@tie{}@b{f}}, the normal words (like @q{pi@`{u}}) should be
2153 done in a different font. The recommended font for this is bold and italic.
2154 @lilypond[verbatim,quote]
2162 layout (prepend-alist-chain 'font-encoding 'fetaDynamic props) arg))
2164 (define-builtin-markup-command (text layout props arg)
2168 "Use a text font instead of music symbol or music alphabet font.
2170 @lilypond[verbatim,quote]
2183 (interpret-markup layout (prepend-alist-chain 'font-encoding 'latin1 props)
2186 (define-builtin-markup-command (italic layout props arg)
2190 "Use italic @code{font-shape} for @var{arg}.
2192 @lilypond[verbatim,quote]
2200 (interpret-markup layout (prepend-alist-chain 'font-shape 'italic props) arg))
2202 (define-builtin-markup-command (typewriter layout props arg)
2206 "Use @code{font-family} typewriter for @var{arg}.
2208 @lilypond[verbatim,quote]
2217 layout (prepend-alist-chain 'font-family 'typewriter props) arg))
2219 (define-builtin-markup-command (upright layout props arg)
2223 "Set @code{font-shape} to @code{upright}. This is the opposite
2226 @lilypond[verbatim,quote]
2240 layout (prepend-alist-chain 'font-shape 'upright props) arg))
2242 (define-builtin-markup-command (medium layout props arg)
2246 "Switch to medium font-series (in contrast to bold).
2248 @lilypond[verbatim,quote]
2261 (interpret-markup layout (prepend-alist-chain 'font-series 'medium props)
2264 (define-builtin-markup-command (normal-text layout props arg)
2268 "Set all font related properties (except the size) to get the default
2269 normal text font, no matter what font was used earlier.
2271 @lilypond[verbatim,quote]
2273 \\huge \\bold \\sans \\caps {
2274 Some text with font overrides
2277 Default text, same font-size
2285 (interpret-markup layout
2286 (cons '((font-family . roman) (font-shape . upright)
2287 (font-series . medium) (font-encoding . latin1))
2291 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2293 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2295 (define-builtin-markup-command (doublesharp layout props)
2299 "Draw a double sharp symbol.
2301 @lilypond[verbatim,quote]
2306 (interpret-markup layout props (markup #:musicglyph (assoc-get 1 standard-alteration-glyph-name-alist ""))))
2308 (define-builtin-markup-command (sesquisharp layout props)
2312 "Draw a 3/2 sharp symbol.
2314 @lilypond[verbatim,quote]
2319 (interpret-markup layout props (markup #:musicglyph (assoc-get 3/4 standard-alteration-glyph-name-alist ""))))
2321 (define-builtin-markup-command (sharp layout props)
2325 "Draw a sharp symbol.
2327 @lilypond[verbatim,quote]
2332 (interpret-markup layout props (markup #:musicglyph (assoc-get 1/2 standard-alteration-glyph-name-alist ""))))
2334 (define-builtin-markup-command (semisharp layout props)
2338 "Draw a semisharp symbol.
2340 @lilypond[verbatim,quote]
2345 (interpret-markup layout props (markup #:musicglyph (assoc-get 1/4 standard-alteration-glyph-name-alist ""))))
2347 (define-builtin-markup-command (natural layout props)
2351 "Draw a natural symbol.
2353 @lilypond[verbatim,quote]
2358 (interpret-markup layout props (markup #:musicglyph (assoc-get 0 standard-alteration-glyph-name-alist ""))))
2360 (define-builtin-markup-command (semiflat layout props)
2364 "Draw a semiflat symbol.
2366 @lilypond[verbatim,quote]
2371 (interpret-markup layout props (markup #:musicglyph (assoc-get -1/4 standard-alteration-glyph-name-alist ""))))
2373 (define-builtin-markup-command (flat layout props)
2377 "Draw a flat symbol.
2379 @lilypond[verbatim,quote]
2384 (interpret-markup layout props (markup #:musicglyph (assoc-get -1/2 standard-alteration-glyph-name-alist ""))))
2386 (define-builtin-markup-command (sesquiflat layout props)
2390 "Draw a 3/2 flat symbol.
2392 @lilypond[verbatim,quote]
2397 (interpret-markup layout props (markup #:musicglyph (assoc-get -3/4 standard-alteration-glyph-name-alist ""))))
2399 (define-builtin-markup-command (doubleflat layout props)
2403 "Draw a double flat symbol.
2405 @lilypond[verbatim,quote]
2410 (interpret-markup layout props (markup #:musicglyph (assoc-get -1 standard-alteration-glyph-name-alist ""))))
2412 (define-builtin-markup-command (with-color layout props color arg)
2417 @cindex coloring text
2419 Draw @var{arg} in color specified by @var{color}.
2421 @lilypond[verbatim,quote]
2433 (let ((stil (interpret-markup layout props arg)))
2434 (ly:make-stencil (list 'color color (ly:stencil-expr stil))
2435 (ly:stencil-extent stil X)
2436 (ly:stencil-extent stil Y))))
2438 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2440 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2442 (define-builtin-markup-command (arrow-head layout props axis dir filled)
2443 (integer? ly:dir? boolean?)
2446 "Produce an arrow head in specified direction and axis.
2447 Use the filled head if @var{filled} is specified.
2448 @lilypond[verbatim,quote]
2451 \\general-align #Y #DOWN {
2452 \\arrow-head #Y #UP ##t
2453 \\arrow-head #Y #DOWN ##f
2455 \\arrow-head #X #RIGHT ##f
2456 \\arrow-head #X #LEFT ##f
2462 ((name (format "arrowheads.~a.~a~a"
2469 (ly:paper-get-font layout (cons '((font-encoding . fetaMusic))
2473 (define-builtin-markup-command (musicglyph layout props glyph-name)
2477 "@var{glyph-name} is converted to a musical symbol; for example,
2478 @code{\\musicglyph #\"accidentals.natural\"} selects the natural sign from
2479 the music font. See @ruser{The Feta font} for a complete listing of
2480 the possible glyphs.
2482 @lilypond[verbatim,quote]
2485 \\musicglyph #\"rests.2\"
2486 \\musicglyph #\"clefs.G_change\"
2489 (let* ((font (ly:paper-get-font layout
2490 (cons '((font-encoding . fetaMusic)
2494 (glyph (ly:font-get-glyph font glyph-name)))
2495 (if (null? (ly:stencil-expr glyph))
2496 (ly:warning (_ "Cannot find glyph ~a") glyph-name))
2501 (define-builtin-markup-command (lookup layout props glyph-name)
2505 "Lookup a glyph by name.
2507 @lilypond[verbatim,quote]
2509 \\override #'(font-encoding . fetaBraces) {
2510 \\lookup #\"brace200\"
2513 \\lookup #\"brace180\"
2517 (ly:font-get-glyph (ly:paper-get-font layout props)
2520 (define-builtin-markup-command (char layout props num)
2524 "Produce a single character. Characters encoded in hexadecimal
2525 format require the prefix @code{#x}.
2527 @lilypond[verbatim,quote]
2529 \\char #65 \\char ##x00a9
2532 (ly:text-interface::interpret-markup layout props (ly:wide-char->utf-8 num)))
2534 (define number->mark-letter-vector (make-vector 25 #\A))
2539 (if (= i (- (char->integer #\I) (char->integer #\A)))
2541 (vector-set! number->mark-letter-vector j
2542 (integer->char (+ i (char->integer #\A)))))
2544 (define number->mark-alphabet-vector (list->vector
2545 (map (lambda (i) (integer->char (+ i (char->integer #\A)))) (iota 26))))
2547 (define (number->markletter-string vec n)
2548 "Double letters for big marks."
2549 (let* ((lst (vector-length vec)))
2552 (string-append (number->markletter-string vec (1- (quotient n lst)))
2553 (number->markletter-string vec (remainder n lst)))
2554 (make-string 1 (vector-ref vec n)))))
2556 (define-builtin-markup-command (markletter layout props num)
2560 "Make a markup letter for @var{num}. The letters start with A to@tie{}Z
2561 (skipping letter@tie{}I), and continue with double letters.
2563 @lilypond[verbatim,quote]
2570 (ly:text-interface::interpret-markup layout props
2571 (number->markletter-string number->mark-letter-vector num)))
2573 (define-builtin-markup-command (markalphabet layout props num)
2577 "Make a markup letter for @var{num}. The letters start with A to@tie{}Z
2578 and continue with double letters.
2580 @lilypond[verbatim,quote]
2587 (ly:text-interface::interpret-markup layout props
2588 (number->markletter-string number->mark-alphabet-vector num)))
2590 (define-public (horizontal-slash-interval num forward number-interval mag)
2592 (cond ;((= num 6) (interval-widen number-interval (* mag 0.5)))
2593 ;((= num 5) (interval-widen number-interval (* mag 0.5)))
2594 (else (interval-widen number-interval (* mag 0.25))))
2595 (cond ((= num 6) (interval-widen number-interval (* mag 0.5)))
2596 ;((= num 5) (interval-widen number-interval (* mag 0.5)))
2597 (else (interval-widen number-interval (* mag 0.25))))
2600 (define-public (adjust-slash-stencil num forward stencil mag)
2603 (ly:stencil-translate stencil (cons (* mag -0.00) (* mag 0.2))))
2605 (ly:stencil-translate stencil (cons (* mag -0.00) (* mag 0.2))))
2607 ;(ly:stencil-translate stencil (cons (* mag -0.00) (* mag -0.07))))
2609 ; (ly:stencil-translate stencil (cons (* mag -0.00) (* mag -0.15))))
2612 (ly:stencil-translate stencil (cons (* mag -0.00) (* mag 0.15))))
2614 ; (ly:stencil-translate stencil (cons (* mag -0.00) (* mag -0.15))))
2619 (define (slashed-digit-internal layout props num forward font-size thickness)
2620 (let* ((mag (magstep font-size))
2622 (ly:output-def-lookup layout 'line-thickness)
2624 ; backward slashes might use slope and point in the other direction!
2625 (dy (* mag (if forward 0.4 -0.4)))
2626 (number-stencil (interpret-markup layout
2627 (prepend-alist-chain 'font-encoding 'fetaNumber props)
2628 (number->string num)))
2629 (num-x (horizontal-slash-interval num forward (ly:stencil-extent number-stencil X) mag))
2630 (center (interval-center (ly:stencil-extent number-stencil Y)))
2631 ; Use the real extents of the slash, not the whole number, because we
2632 ; might translate the slash later on!
2633 (num-y (interval-widen (cons center center) (abs dy)))
2634 (is-sane (and (interval-sane? num-x) (interval-sane? num-y)))
2635 (slash-stencil (if is-sane
2636 (make-line-stencil thickness
2637 (car num-x) (- (interval-center num-y) dy)
2638 (cdr num-x) (+ (interval-center num-y) dy))
2640 (if (ly:stencil? slash-stencil)
2642 ; for some numbers we need to shift the slash/backslash up or down to make
2643 ; the slashed digit look better
2644 (set! slash-stencil (adjust-slash-stencil num forward slash-stencil mag))
2645 (set! number-stencil
2646 (ly:stencil-add number-stencil slash-stencil)))
2647 (ly:warning "Unable to create slashed digit ~a" num))
2651 (define-builtin-markup-command (slashed-digit layout props num)
2657 @cindex slashed digits
2659 A feta number, with slash. This is for use in the context of
2660 figured bass notation.
2661 @lilypond[verbatim,quote]
2665 \\override #'(thickness . 3)
2669 (slashed-digit-internal layout props num #t font-size thickness))
2671 (define-builtin-markup-command (backslashed-digit layout props num)
2677 @cindex backslashed digits
2679 A feta number, with backslash. This is for use in the context of
2680 figured bass notation.
2681 @lilypond[verbatim,quote]
2683 \\backslashed-digit #5
2685 \\override #'(thickness . 3)
2686 \\backslashed-digit #7
2689 (slashed-digit-internal layout props num #f font-size thickness))
2692 (define eyeglassesps
2697 0.7 0.7 0.5 0 361 arc
2699 2.20 0.70 0.50 0 361 arc
2701 1.45 0.85 0.30 0 180 arc
2705 0.92 2.26 1.30 2.40 1.15 1.70 curveto
2709 3.42 2.26 3.80 2.40 3.65 1.70 curveto
2712 (define-builtin-markup-command (eyeglasses layout props) () other ()
2713 "Prints out eyeglasses, indicating strongly to look at the conductor.
2714 @lilypond[verbatim,quote]
2715 \\markup { \\eyeglasses }
2717 (interpret-markup layout props
2718 (make-with-dimensions-markup '(-0.61 . 3.22) '(0.2 . 2.41)
2719 (make-postscript-markup eyeglassesps))))
2721 (define-builtin-markup-command (left-brace layout props size)
2726 A feta brace in point size @var{size}.
2728 @lilypond[verbatim,quote]
2735 (let* ((font (ly:paper-get-font layout
2736 (cons '((font-encoding . fetaBraces)
2739 (glyph-count (1- (ly:otf-glyph-count font)))
2740 (scale (ly:output-def-lookup layout 'output-scale))
2741 (scaled-size (/ (ly:pt size) scale))
2743 (ly:font-get-glyph font (string-append "brace"
2744 (number->string n)))))
2745 (get-y-from-brace (lambda (brace)
2747 (ly:stencil-extent (glyph brace) Y))))
2748 (find-brace (binary-search 0 glyph-count get-y-from-brace scaled-size))
2749 (glyph-found (glyph find-brace)))
2751 (if (or (null? (ly:stencil-expr glyph-found))
2752 (< scaled-size (interval-length (ly:stencil-extent (glyph 0) Y)))
2753 (> scaled-size (interval-length
2754 (ly:stencil-extent (glyph glyph-count) Y))))
2756 (ly:warning (_ "no brace found for point size ~S ") size)
2757 (ly:warning (_ "defaulting to ~S pt")
2758 (/ (* scale (interval-length
2759 (ly:stencil-extent glyph-found Y)))
2763 (define-builtin-markup-command (right-brace layout props size)
2768 A feta brace in point size @var{size}, rotated 180 degrees.
2770 @lilypond[verbatim,quote]
2777 (interpret-markup layout props (markup #:rotate 180 #:left-brace size)))
2779 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2780 ;; the note command.
2781 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2783 ;; TODO: better syntax.
2785 (define-builtin-markup-command (note-by-number layout props log dot-count dir)
2786 (number? number? number?)
2791 @cindex notes within text by log and dot-count
2793 Construct a note symbol, with stem. By using fractional values for
2794 @var{dir}, longer or shorter stems can be obtained.
2796 @lilypond[verbatim,quote]
2798 \\note-by-number #3 #0 #DOWN
2800 \\note-by-number #1 #2 #0.8
2803 (define (get-glyph-name-candidates dir log style)
2804 (map (lambda (dir-name)
2805 (format "noteheads.~a~a~a" dir-name (min log 2)
2806 (if (and (symbol? style)
2807 (not (equal? 'default style)))
2808 (symbol->string style)
2810 (list (if (= dir UP) "u" "d")
2813 (define (get-glyph-name font cands)
2816 (if (ly:stencil-empty? (ly:font-get-glyph font (car cands)))
2817 (get-glyph-name font (cdr cands))
2820 (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) props)))
2821 (size-factor (magstep font-size))
2822 (stem-length (* size-factor (max 3 (- log 1))))
2823 (head-glyph-name (get-glyph-name font (get-glyph-name-candidates (sign dir) log style)))
2824 (head-glyph (ly:font-get-glyph font head-glyph-name))
2825 (attach-indices (ly:note-head::stem-attachment font head-glyph-name))
2826 (stem-thickness (* size-factor 0.13))
2827 (stemy (* dir stem-length))
2828 (attach-off (cons (interval-index
2829 (ly:stencil-extent head-glyph X)
2830 (* (sign dir) (car attach-indices)))
2831 (* (sign dir) ; fixme, this is inconsistent between X & Y.
2833 (ly:stencil-extent head-glyph Y)
2834 (cdr attach-indices)))))
2835 (stem-glyph (and (> log 0)
2836 (ly:round-filled-box
2837 (ordered-cons (car attach-off)
2838 (+ (car attach-off) (* (- (sign dir)) stem-thickness)))
2839 (cons (min stemy (cdr attach-off))
2840 (max stemy (cdr attach-off)))
2841 (/ stem-thickness 3))))
2843 (dot (ly:font-get-glyph font "dots.dot"))
2844 (dotwid (interval-length (ly:stencil-extent dot X)))
2845 (dots (and (> dot-count 0)
2846 (apply ly:stencil-add
2848 (ly:stencil-translate-axis
2849 dot (* 2 x dotwid) X))
2850 (iota dot-count)))))
2851 (flaggl (and (> log 2)
2852 (ly:stencil-translate
2853 (ly:font-get-glyph font
2854 (string-append "flags."
2855 (if (> dir 0) "u" "d")
2856 (number->string log)))
2857 (cons (+ (car attach-off) (if (< dir 0) stem-thickness 0)) stemy)))))
2859 ; If there is a flag on an upstem and the stem is short, move the dots to avoid the flag.
2860 ; 16th notes get a special case because their flags hang lower than any other flags.
2861 (if (and dots (> dir 0) (> log 2) (or (< dir 1.15) (and (= log 4) (< dir 1.3))))
2862 (set! dots (ly:stencil-translate-axis dots 0.5 X)))
2864 (set! stem-glyph (ly:stencil-add flaggl stem-glyph)))
2865 (if (ly:stencil? stem-glyph)
2866 (set! stem-glyph (ly:stencil-add stem-glyph head-glyph))
2867 (set! stem-glyph head-glyph))
2868 (if (ly:stencil? dots)
2871 (ly:stencil-translate-axis
2873 (+ (cdr (ly:stencil-extent head-glyph X)) dotwid)
2879 (let ((divisor (log 2)))
2880 (lambda (z) (inexact->exact (/ (log z) divisor)))))
2882 (define (parse-simple-duration duration-string)
2883 "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a (log dots) list."
2884 (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string)))
2885 (if (and match (string=? duration-string (match:substring match 0)))
2886 (let ((len (match:substring match 1))
2887 (dots (match:substring match 2)))
2888 (list (cond ((string=? len "breve") -1)
2889 ((string=? len "longa") -2)
2890 ((string=? len "maxima") -3)
2891 (else (log2 (string->number len))))
2892 (if dots (string-length dots) 0)))
2893 (ly:error (_ "not a valid duration string: ~a") duration-string))))
2895 (define-builtin-markup-command (note layout props duration dir)
2898 (note-by-number-markup)
2900 @cindex notes within text by string
2902 This produces a note with a stem pointing in @var{dir} direction, with
2903 the @var{duration} for the note head type and augmentation dots. For
2904 example, @code{\\note #\"4.\" #-0.75} creates a dotted quarter note, with
2905 a shortened down stem.
2907 @lilypond[verbatim,quote]
2909 \\override #'(style . cross) {
2913 \\note #\"breve\" #0
2916 (let ((parsed (parse-simple-duration duration)))
2917 (note-by-number-markup layout props (car parsed) (cadr parsed) dir)))
2919 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2921 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2923 (define-builtin-markup-command (lower layout props amount arg)
2928 @cindex lowering text
2930 Lower @var{arg} by the distance @var{amount}.
2931 A negative @var{amount} indicates raising; see also @code{\\raise}.
2933 @lilypond[verbatim,quote]
2941 (ly:stencil-translate-axis (interpret-markup layout props arg)
2944 (define-builtin-markup-command (translate-scaled layout props offset arg)
2945 (number-pair? markup?)
2949 @cindex translating text
2950 @cindex scaling text
2952 Translate @var{arg} by @var{offset}, scaling the offset by the
2955 @lilypond[verbatim,quote]
2958 * \\translate #'(2 . 3) translate
2960 * \\translate-scaled #'(2 . 3) translate-scaled
2964 (let* ((factor (magstep font-size))
2965 (scaled (cons (* factor (car offset))
2966 (* factor (cdr offset)))))
2967 (ly:stencil-translate (interpret-markup layout props arg)
2970 (define-builtin-markup-command (raise layout props amount arg)
2975 @cindex raising text
2977 Raise @var{arg} by the distance @var{amount}.
2978 A negative @var{amount} indicates lowering, see also @code{\\lower}.
2980 The argument to @code{\\raise} is the vertical displacement amount,
2981 measured in (global) staff spaces. @code{\\raise} and @code{\\super}
2982 raise objects in relation to their surrounding markups.
2984 If the text object itself is positioned above or below the staff, then
2985 @code{\\raise} cannot be used to move it, since the mechanism that
2986 positions it next to the staff cancels any shift made with
2987 @code{\\raise}. For vertical positioning, use the @code{padding}
2988 and/or @code{extra-offset} properties.
2990 @lilypond[verbatim,quote]
2999 (ly:stencil-translate-axis (interpret-markup layout props arg) amount Y))
3001 (define-builtin-markup-command (fraction layout props arg1 arg2)
3006 @cindex creating text fractions
3008 Make a fraction of two markups.
3009 @lilypond[verbatim,quote]
3015 (let* ((m1 (interpret-markup layout props arg1))
3016 (m2 (interpret-markup layout props arg2))
3017 (factor (magstep font-size))
3018 (boxdimen (cons (* factor -0.05) (* factor 0.05)))
3019 (padding (* factor 0.2))
3020 (baseline (* factor 0.6))
3021 (offset (* factor 0.75)))
3022 (set! m1 (ly:stencil-aligned-to m1 X CENTER))
3023 (set! m2 (ly:stencil-aligned-to m2 X CENTER))
3024 (let* ((x1 (ly:stencil-extent m1 X))
3025 (x2 (ly:stencil-extent m2 X))
3026 (line (ly:round-filled-box (interval-union x1 x2) boxdimen 0.0))
3027 ;; should stack mols separately, to maintain LINE on baseline
3028 (stack (stack-lines DOWN padding baseline (list m1 line m2))))
3030 (ly:stencil-aligned-to stack Y CENTER))
3032 (ly:stencil-aligned-to stack X LEFT))
3033 ;; should have EX dimension
3035 (ly:stencil-translate-axis stack offset Y))))
3037 (define-builtin-markup-command (normal-size-super layout props arg)
3042 @cindex setting superscript in standard font size
3044 Set @var{arg} in superscript with a normal font size.
3046 @lilypond[verbatim,quote]
3049 \\normal-size-super {
3050 superscript in standard size
3054 (ly:stencil-translate-axis
3055 (interpret-markup layout props arg)
3056 (* 0.5 baseline-skip) Y))
3058 (define-builtin-markup-command (super layout props arg)
3064 @cindex superscript text
3066 Set @var{arg} in superscript.
3068 @lilypond[verbatim,quote]
3078 (ly:stencil-translate-axis
3081 (cons `((font-size . ,(- font-size 3))) props)
3083 (* 0.5 baseline-skip)
3086 (define-builtin-markup-command (translate layout props offset arg)
3087 (number-pair? markup?)
3091 @cindex translating text
3093 Translate @var{arg} relative to its surroundings. @var{offset}
3094 is a pair of numbers representing the displacement in the X and Y axis.
3096 @lilypond[verbatim,quote]
3099 \\translate #'(2 . 3)
3100 \\line { translated two spaces right, three up }
3103 (ly:stencil-translate (interpret-markup layout props arg)
3106 (define-builtin-markup-command (sub layout props arg)
3112 @cindex subscript text
3114 Set @var{arg} in subscript.
3116 @lilypond[verbatim,quote]
3127 (ly:stencil-translate-axis
3130 (cons `((font-size . ,(- font-size 3))) props)
3132 (* -0.5 baseline-skip)
3135 (define-builtin-markup-command (normal-size-sub layout props arg)
3140 @cindex setting subscript in standard font size
3142 Set @var{arg} in subscript with a normal font size.
3144 @lilypond[verbatim,quote]
3148 subscript in standard size
3152 (ly:stencil-translate-axis
3153 (interpret-markup layout props arg)
3154 (* -0.5 baseline-skip)
3157 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3159 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3161 (define-builtin-markup-command (hbracket layout props arg)
3166 @cindex placing horizontal brackets around text
3168 Draw horizontal brackets around @var{arg}.
3170 @lilypond[verbatim,quote]
3179 (let ((th 0.1) ;; todo: take from GROB.
3180 (m (interpret-markup layout props arg)))
3181 (bracketify-stencil m X th (* 2.5 th) th)))
3183 (define-builtin-markup-command (bracket layout props arg)
3188 @cindex placing vertical brackets around text
3190 Draw vertical brackets around @var{arg}.
3192 @lilypond[verbatim,quote]
3199 (let ((th 0.1) ;; todo: take from GROB.
3200 (m (interpret-markup layout props arg)))
3201 (bracketify-stencil m Y th (* 2.5 th) th)))
3203 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3204 ;; Delayed markup evaluation
3205 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3207 (define-builtin-markup-command (page-ref layout props label gauge default)
3208 (symbol? markup? markup?)
3212 @cindex referencing page numbers in text
3214 Reference to a page number. @var{label} is the label set on the referenced
3215 page (using the @code{\\label} command), @var{gauge} a markup used to estimate
3216 the maximum width of the page number, and @var{default} the value to display
3217 when @var{label} is not found."
3218 (let* ((gauge-stencil (interpret-markup layout props gauge))
3219 (x-ext (ly:stencil-extent gauge-stencil X))
3220 (y-ext (ly:stencil-extent gauge-stencil Y)))
3222 `(delay-stencil-evaluation
3223 ,(delay (ly:stencil-expr
3224 (let* ((table (ly:output-def-lookup layout 'label-page-table))
3225 (page-number (if (list? table)
3226 (assoc-get label table)
3228 (page-markup (if page-number (format "~a" page-number) default))
3229 (page-stencil (interpret-markup layout props page-markup))
3230 (gap (- (interval-length x-ext)
3231 (interval-length (ly:stencil-extent page-stencil X)))))
3232 (interpret-markup layout props
3233 (markup #:concat (#:hspace gap page-markup)))))))
3237 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3238 ;; Markup list commands
3239 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3241 (define-public (space-lines baseline stils)
3242 (let space-stil ((stils stils)
3246 (let* ((stil (car stils))
3247 (dy-top (max (- (/ baseline 1.5)
3248 (interval-bound (ly:stencil-extent stil Y) UP))
3250 (dy-bottom (max (+ (/ baseline 3.0)
3251 (interval-bound (ly:stencil-extent stil Y) DOWN))
3253 (new-stil (ly:make-stencil
3254 (ly:stencil-expr stil)
3255 (ly:stencil-extent stil X)
3256 (cons (- (interval-bound (ly:stencil-extent stil Y) DOWN)
3258 (+ (interval-bound (ly:stencil-extent stil Y) UP)
3260 (space-stil (cdr stils) (cons new-stil result))))))
3262 (define-builtin-markup-list-command (justified-lines layout props args)
3265 wordwrap-internal-markup-list)
3267 @cindex justifying lines of text
3269 Like @code{\\justify}, but return a list of lines instead of a single markup.
3270 Use @code{\\override-lines #'(line-width . @var{X})} to set the line width;
3271 @var{X}@tie{}is the number of staff spaces."
3272 (space-lines baseline-skip
3273 (interpret-markup-list layout props
3274 (make-wordwrap-internal-markup-list #t args))))
3276 (define-builtin-markup-list-command (wordwrap-lines layout props args)
3279 wordwrap-internal-markup-list)
3280 "Like @code{\\wordwrap}, but return a list of lines instead of a single markup.
3281 Use @code{\\override-lines #'(line-width . @var{X})} to set the line width,
3282 where @var{X} is the number of staff spaces."
3283 (space-lines baseline-skip
3284 (interpret-markup-list layout props
3285 (make-wordwrap-internal-markup-list #f args))))
3287 (define-builtin-markup-list-command (column-lines layout props args)
3290 "Like @code{\\column}, but return a list of lines instead of a single markup.
3291 @code{baseline-skip} determines the space between each markup in @var{args}."
3292 (space-lines baseline-skip
3293 (interpret-markup-list layout props args)))
3295 (define-builtin-markup-list-command (override-lines layout props new-prop args)
3296 (pair? markup-list?)
3298 "Like @code{\\override}, for markup lists."
3299 (interpret-markup-list layout (cons (list new-prop) props) args))