2 Internally markup is stored as lists, whose head is a function.
4 (FUNCTION ARG1 ARG2 ... )
6 When the markup is formatted, then FUNCTION is called as follows
8 (FUNCTION GROB PROPS ARG1 ARG2 ... )
10 GROB is the current grob, PROPS is a list of alists, and ARG1.. are
11 the rest of the arguments.
13 The function should return a molecule (i.e. a formatted, ready to
17 To add a function, use the def-markup-command utility.
19 (def-markup-command (mycommand paper prop arg1 ...) (arg1-type? ...)
20 \"my command usage and description\"
23 The command is now available in markup mode, e.g.
26 \\markup { .... \\MYCOMMAND #1 argument ... }
30 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
31 ;;; markup definer utilities
32 ;;; `def-markup-command' can be used both for built-in markup
33 ;;; definitions and user defined markups.
35 (defmacro-public def-markup-command (command-and-args signature . body)
36 "Define a COMMAND-markup function after command-and-args and body,
37 register COMMAND-markup and its signature,
38 add COMMAND-markup to markup-function-list,
39 sets COMMAND-markup markup-signature and markup-keyword object properties,
40 define a make-COMMAND-markup function.
42 (def-markup-command (COMMAND paper props arg1 arg2 ...) (arg1-type? arg2-type? ...)
43 \"documentation string\"
46 (def-markup-command COMMAND (arg1-type? arg2-type? ...)
49 (let* ((command (if (pair? command-and-args) (car command-and-args) command-and-args))
50 (args (if (pair? command-and-args) (cdr command-and-args) '()))
51 (command-name (string->symbol (string-append (symbol->string command) "-markup")))
52 (make-markup-name (string->symbol (string-append "make-" (symbol->string command-name)))))
54 (define-public ,(if (pair? args)
55 (cons command-name args)
58 (set! (markup-command-signature ,command-name) (list ,@signature))
59 (if (not (member ,command-name markup-function-list))
60 (set! markup-function-list (cons ,command-name markup-function-list)))
61 (define-public (,make-markup-name . args)
62 (let ((sig (list ,@signature)))
63 (make-markup ,command-name ,(symbol->string make-markup-name) sig args))))))
65 (define-public (make-markup markup-function make-name signature args)
66 " Construct a markup object from MARKUP-FUNCTION and ARGS. Typecheck
67 against SIGNATURE, reporting MAKE-NAME as the user-invoked function.
69 (let* ((arglen (length args))
70 (siglen (length signature))
71 (error-msg (if (and (> siglen 0) (> arglen 0))
72 (markup-argument-list-error signature args 1)
74 (if (or (not (= arglen siglen)) (< siglen 0) (< arglen 0))
75 (scm-error 'markup-format make-name
76 "Expect ~A arguments for ~A. Found ~A: ~S"
77 (list siglen make-name arglen args)
80 (scm-error 'markup-format make-name
81 "Invalid argument in position ~A\nExpect: ~A\nFound: ~S."
83 (cons markup-function args))))
85 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
86 ;;; markup constructors
87 ;;; lilypond-like syntax for markup construction in scheme.
89 (use-modules (ice-9 optargs)
92 (defmacro*-public markup (#:rest body)
93 "The `markup' macro provides a lilypond-like syntax for building markups.
95 - #:COMMAND is used instead of \\COMMAND
96 - #:lines ( ... ) is used instead of { ... }
97 - #:center ( ... ) is used instead of \\center < ... >
102 \\raise #0.2 \\hbracket \\bold bar
103 \\override #'(baseline-skip . 4)
104 \\bracket \\column < baz bazr bla >
108 #:raise 0.2 #:hbracket #:bold \"bar\"
109 #:override '(baseline-skip . 4)
110 #:bracket #:column (\"baz\" \"bazr\" \"bla\"))
111 Use `markup*' in a \\notes block."
113 (car (compile-all-markup-expressions `(#:line ,body))))
115 (defmacro*-public markup* (#:rest body)
116 "Same as `markup', for use in a \\notes block."
117 `(ly:export (markup ,@body)))
120 (define (compile-all-markup-expressions expr)
121 "Return a list of canonical markups expressions, eg:
122 (#:COMMAND1 arg11 arg12 #:COMMAND2 arg21 arg22 arg23)
124 ((make-COMMAND1-markup arg11 arg12)
125 (make-COMMAND2-markup arg21 arg22 arg23) ...)"
126 (do ((rest expr rest)
128 ((null? rest) (reverse markps))
129 (receive (m r) (compile-markup-expression rest)
130 (set! markps (cons m markps))
133 (define (keyword->make-markup key)
134 "Transform a keyword, eg. #:COMMAND, in a make-COMMAND-markup symbol."
135 (string->symbol (string-append "make-" (symbol->string (keyword->symbol key)) "-markup")))
137 (define (compile-markup-expression expr)
138 "Return two values: the first complete canonical markup expression found in `expr',
139 eg (make-COMMAND-markup arg1 arg2 ...), and the rest expression."
140 (cond ((and (pair? expr)
141 (keyword? (car expr)))
142 ;; expr === (#:COMMAND arg1 ...)
143 (let* ((command (symbol->string (keyword->symbol (car expr))))
144 (sig (markup-command-signature (car (lookup-markup-command command))))
145 (sig-len (length sig)))
148 (rest (cdr expr) rest))
150 (values (cons (keyword->make-markup (car expr)) (reverse args)) rest))
151 (cond ((eqv? (list-ref sig i) markup-list?)
152 ;; (car rest) is a markup list
153 (set! args (cons `(list ,@(compile-all-markup-expressions (car rest))) args))
154 (set! rest (cdr rest)))
156 ;; pick up one arg in `rest'
157 (receive (a r) (compile-markup-arg rest)
158 (set! args (cons a args))
162 (keyword? (caar expr)))
163 ;; expr === ((#:COMMAND arg1 ...) ...)
164 (receive (m r) (compile-markup-expression (car expr))
165 (values m (cdr expr))))
167 ;; expr === (symbol ...) or ("string" ...) or ((funcall ...) ...)
171 (define (compile-all-markup-args expr)
172 "Transform `expr' into markup arguments"
173 (do ((rest expr rest)
175 ((null? rest) (reverse args))
176 (receive (a r) (compile-markup-arg rest)
177 (set! args (cons a args))
180 (define (compile-markup-arg expr)
181 "Return two values: the desired markup argument, and the rest arguments"
185 ((keyword? (car expr))
186 ;; expr === (#:COMMAND ...)
187 ;; ==> build and return the whole markup expression
188 (compile-markup-expression expr))
189 ((and (pair? (car expr))
190 (keyword? (caar expr)))
191 ;; expr === ((#:COMMAND ...) ...)
192 ;; ==> build and return the whole markup expression(s)
193 ;; found in (car expr)
194 (receive (markup-expr rest-expr) (compile-markup-expression (car expr))
195 (if (null? rest-expr)
196 (values markup-expr (cdr expr))
197 (values `(list ,markup-expr ,@(compile-all-markup-args rest-expr))
199 ((and (pair? (car expr))
201 ;; expr === (((foo ...) ...) ...)
202 (values (cons 'list (compile-all-markup-args (car expr))) (cdr expr)))
203 (else (values (car expr) (cdr expr)))))
206 ;;; Utilities for storing and accessing markup commands signature
210 ;;; (set! (markup-command-signature raise-markup) (list number? markup?))
211 ;;; ==> ((#<primitive-procedure number?> #<procedure markup? (obj)>) . scheme0-markup1)
213 ;;; (markup-command-signature raise-markup)
214 ;;; ==> (#<primitive-procedure number?> #<procedure markup? (obj)>)
216 ;;; (markup-command-keyword raise-markup) ==> "scheme0-markup1"
219 (define markup-command-signatures (make-hash-table 50))
221 (define (markup-command-signature-ref markup-command)
222 "Return markup-command's signature, e.g. (number? markup?).
223 markup-command may be a procedure."
224 (let ((sig-key (hashq-ref markup-command-signatures
226 (if sig-key (car sig-key) #f)))
228 (define-public (markup-command-keyword markup-command)
229 "Return markup-command's keyword, e.g. \"scheme0markup1\".
230 markup-command may be a procedure."
231 (let ((sig-key (hashq-ref markup-command-signatures
233 (if sig-key (cdr sig-key) #f)))
235 (define (markup-command-signatureset! markup-command signature)
236 "Set markup-command's signature. markup-command must be a named procedure.
237 Also set markup-signature and markup-keyword object properties."
238 (hashq-set! markup-command-signatures
240 (cons signature (markup-signature-to-keyword signature)))
241 ;; these object properties are still in use somewhere
242 (set-object-property! markup-command 'markup-signature signature)
243 (set-object-property! markup-command 'markup-keyword (markup-signature-to-keyword signature)))
245 (define-public markup-command-signature
246 (make-procedure-with-setter markup-command-signature-ref markup-command-signatureset!))
248 (define (markup-symbol-to-proc markup-sym)
249 "Return the markup command procedure which name is `markup-sym', if any."
250 (hash-fold (lambda (key val prev)
252 (if (eqv? (procedure-name key) markup-sym) key #f)))
254 markup-command-signatures))
256 (define-public markup-function-list '())
258 (define-public (markup-signature-to-keyword sig)
259 " (A B C) -> a0-b1-c2 "
262 (string->symbol (string-join (map
265 (set! count (+ count 1))
267 ;; for reasons I don't get,
268 ;; (case func ((markup?) .. )
271 ((eq? func markup?) "markup")
272 ((eq? func markup-list?) "markup-list")
274 (number->string (- count 1)))))
278 (define-public (lookup-markup-command code)
279 (let ((proc (markup-symbol-to-proc (string->symbol (string-append code "-markup")))))
280 (and proc (cons proc (markup-command-keyword proc)))))
282 ;;;;;;;;;;;;;;;;;;;;;;
283 ;;; markup type predicates
285 (define (markup-function? x)
286 (not (not (markup-command-signature x))))
288 (define (markup-list? arg)
289 (define (markup-list-inner? l)
291 (and (markup? (car l)) (markup-list-inner? (cdr l)))))
292 (and (list? arg) (markup-list-inner? arg)))
294 (define (markup-argument-list? signature arguments)
295 "Typecheck argument list."
296 (if (and (pair? signature) (pair? arguments))
297 (and ((car signature) (car arguments))
298 (markup-argument-list? (cdr signature) (cdr arguments)))
299 (and (null? signature) (null? arguments))))
302 (define (markup-argument-list-error signature arguments number)
303 "return (ARG-NR TYPE-EXPECTED ARG-FOUND) if an error is detected, or
304 #f is no error found.
306 (if (and (pair? signature) (pair? arguments))
307 (if (not ((car signature) (car arguments)))
308 (list number (type-name (car signature)) (car arguments))
309 (markup-argument-list-error (cdr signature) (cdr arguments) (+ 1 number)))
313 ;; full recursive typecheck.
315 (define (markup-typecheck? arg)
318 (markup-function? (car arg))
319 (markup-argument-list? (markup-command-signature (car arg))
323 ;; typecheck, and throw an error when something amiss.
325 (define (markup-thrower-typecheck arg)
326 (cond ((string? arg) #t)
328 (throw 'markup-format "Not a pair" arg))
329 ((not (markup-function? (car arg)))
330 (throw 'markup-format "Not a markup function " (car arg)))
331 ((not (markup-argument-list? (markup-command-signature (car arg))
333 (throw 'markup-format "Arguments failed typecheck for " arg)))
337 ;; good enough if you only use make-XXX-markup functions.
339 (define (cheap-markup? x)
342 (markup-function? (car x)))))
345 ;; replace by markup-thrower-typecheck for more detailed diagnostics.
347 (define-public markup? cheap-markup?)
351 (define (markup-join markups sep)
352 "Return line-markup of MARKUPS, joining them with markup SEP"
354 (make-line-markup (list-insert-separator markups sep))
358 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
361 ;; each markup function should have a doc string with
362 ;; syntax, description and example.
365 (define-public brew-new-markup-molecule Text_item::brew_molecule)
367 (define-public interpret-markup Text_item::interpret_markup)
369 (def-markup-command (simple paper props str) (string?)
370 "A simple text-string; @code{\\markup @{ foo @}} is equivalent with
371 @code{\\markup @{ \\simple #\"foo\" @}}.
373 (interpret-markup paper props str))
375 (define-public empty-markup (make-simple-markup ""))
377 (define-public (stack-molecule-line space molecules)
378 (if (pair? molecules)
379 (if (pair? (cdr molecules))
380 (let* ((tail (stack-molecule-line space (cdr molecules)))
381 (head (car molecules))
382 (xoff (+ space (cdr (ly:molecule-get-extent head X)))))
383 (ly:molecule-add head
384 (ly:molecule-translate-axis tail xoff X)))
388 (def-markup-command (line paper props markps) (markup-list?)
389 "A horizontal line of markups. Syntax:
393 (cdr (chain-assoc 'word-space props))
394 (map (lambda (m) (interpret-markup paper props m)) markps)))
396 (def-markup-command (combine paper props m1 m2) (markup? markup?)
397 "Overstrike two markups."
399 (interpret-markup paper props m1)
400 (interpret-markup paper props m2)))
402 (def-markup-command (finger paper props arg) (markup?)
403 (interpret-markup paper
404 (cons '((font-size . -4) (font-family . number)) props)
407 (define-public (set-property-markup qualifier)
408 (lambda (paper props qualifier-val markp)
409 (interpret-markup paper
410 (cons (cons `(,qualifier . ,qualifier-val) (car props)) (cdr props))
413 (def-markup-command fontsize (number? markup?)
414 (set-property-markup 'font-size))
416 (def-markup-command magnify (number? markup?)
417 (set-property-markup 'font-magnification))
419 (define (font-markup qualifier value)
420 (lambda (paper props markp)
421 (interpret-markup paper
422 (cons (cons `(,qualifier . ,value) (car props)) (cdr props))
425 (def-markup-command bold (markup?)
426 (font-markup 'font-series 'bold))
428 (def-markup-command sans (markup?)
429 (font-markup 'font-family 'sans))
431 (def-markup-command number (markup?)
432 (font-markup 'font-family 'number))
434 (def-markup-command roman (markup?)
435 (font-markup 'font-family 'roman))
437 (def-markup-command huge (markup?)
438 (font-markup 'font-size 2))
440 (def-markup-command large (markup?)
441 (font-markup 'font-size 1))
443 (def-markup-command normalsize (markup?)
444 (font-markup 'font-size 0))
446 (def-markup-command small (markup?)
447 (font-markup 'font-size -1))
449 (def-markup-command tiny (markup?)
450 (font-markup 'font-size -2))
452 (def-markup-command teeny (markup?)
453 (font-markup 'font-size -3))
455 (def-markup-command dynamic (markup?)
456 (font-markup 'font-family 'dynamic))
458 (def-markup-command italic (markup?)
459 (font-markup 'font-shape 'italic))
461 (def-markup-command typewriter (markup?)
462 (font-markup 'font-family 'typewriter))
464 (def-markup-command (column paper props mrkups) (markup-list?)
466 -1 0.0 (cdr (chain-assoc 'baseline-skip props))
467 (map (lambda (m) (interpret-markup paper props m)) mrkups)))
469 (def-markup-command (dir-column paper props mrkups) (markup-list?)
470 "Make a column of args, going up or down, depending on the setting
471 of the #'direction layout property."
472 (let* ((dir (cdr (chain-assoc 'direction props))))
474 (if (number? dir) dir -1)
476 (cdr (chain-assoc 'baseline-skip props))
477 (map (lambda (x) (interpret-markup paper props x)) mrkups))))
479 (def-markup-command (center paper props mrkups) (markup-list?)
480 (let* ((mols (map (lambda (x) (interpret-markup paper props x)) mrkups))
481 (cmols (map (lambda (x) (ly:molecule-align-to! x X CENTER)) mols)))
482 (stack-lines -1 0.0 (cdr (chain-assoc 'baseline-skip props)) mols)))
484 (def-markup-command (right-align paper props mrkup) (markup?)
485 (let* ((m (interpret-markup paper props mrkup)))
486 (ly:molecule-align-to! m X RIGHT)
489 (def-markup-command (left-align paper props mrkup) (markup?)
490 (let* ((m (interpret-markup paper props mrkup)))
491 (ly:molecule-align-to! m X LEFT)
494 (def-markup-command (halign paper props dir mrkup) (number? markup?)
495 "Set horizontal alignment. Syntax: halign A MARKUP. A=-1 is LEFT,
496 A=1 is right, values in between vary alignment accordingly."
497 (let* ((m (interpret-markup paper props mrkup)))
498 (ly:molecule-align-to! m X dir)
501 (def-markup-command (musicglyph paper props glyph-name) (string?)
502 (ly:find-glyph-by-name
503 (ly:paper-get-font paper (cons '((font-name . ())
506 (font-family . music))
511 (def-markup-command (lookup paper props glyph-name) (string?)
512 "Lookup a glyph by name."
513 (ly:find-glyph-by-name (ly:paper-get-font paper props)
516 (def-markup-command (char paper props num) (integer?)
517 "Syntax: \\char NUMBER. "
518 (ly:get-glyph (ly:paper-get-font paper props) num))
520 (def-markup-command (raise paper props amount mrkup) (number? markup?)
521 "Syntax: \\raise AMOUNT MARKUP. "
522 (ly:molecule-translate-axis (interpret-markup paper props mrkup)
525 (def-markup-command (fraction paper props mrkup1 mrkup2) (markup? markup?)
526 "Make a fraction of two markups.
528 Syntax: \\fraction MARKUP1 MARKUP2."
529 (let* ((m1 (interpret-markup paper props mrkup1))
530 (m2 (interpret-markup paper props mrkup2)))
531 (ly:molecule-align-to! m1 X CENTER)
532 (ly:molecule-align-to! m2 X CENTER)
533 (let* ((x1 (ly:molecule-get-extent m1 X))
534 (x2 (ly:molecule-get-extent m2 X))
535 (line (ly:round-filled-box (interval-union x1 x2) '(-0.05 . 0.05) 0.0))
536 ;; should stack mols separately, to maintain LINE on baseline
537 (stack (stack-lines -1 0.2 0.6 (list m1 line m2))))
538 (ly:molecule-align-to! stack Y CENTER)
539 (ly:molecule-align-to! stack X LEFT)
540 ;; should have EX dimension
542 (ly:molecule-translate-axis stack 0.75 Y))))
545 ;; TODO: better syntax.
547 (def-markup-command (note-by-number paper props log dot-count dir) (number? number? number?)
548 "Syntax: \\note-by-number #LOG #DOTS #DIR. By using fractional values
549 for DIR, you can obtain longer or shorter stems."
550 (let* ((font (ly:paper-get-font paper (cons '((font-family . music)) props)))
551 (stemlen (max 3 (- log 1)))
552 (headgl (ly:find-glyph-by-name
554 (string-append "noteheads-" (number->string (min log 2)))))
556 (stemy (* dir stemlen))
557 (attachx (if (> dir 0)
558 (- (cdr (ly:molecule-get-extent headgl X)) stemth)
560 (attachy (* dir 0.28))
561 (stemgl (and (> log 0)
563 (cons attachx (+ attachx stemth))
564 (cons (min stemy attachy)
567 (dot (ly:find-glyph-by-name font "dots-dot"))
568 (dotwid (interval-length (ly:molecule-get-extent dot X)))
569 (dots (and (> dot-count 0)
570 (apply ly:molecule-add
572 (ly:molecule-translate-axis
573 dot (* (+ 1 (* 2 x)) dotwid) X) )
574 (iota dot-count 1)))))
575 (flaggl (and (> log 2)
576 (ly:molecule-translate
577 (ly:find-glyph-by-name font
578 (string-append "flags-"
579 (if (> dir 0) "u" "d")
580 (number->string log)))
581 (cons (+ attachx (/ stemth 2)) stemy)))))
583 (set! stemgl (ly:molecule-add flaggl stemgl)))
584 (if (ly:molecule? stemgl)
585 (set! stemgl (ly:molecule-add stemgl headgl))
586 (set! stemgl headgl))
587 (if (ly:molecule? dots)
590 (ly:molecule-translate-axis dots
591 (+ (if (and (> dir 0) (> log 2))
594 ;; huh ? why not necessary?
595 ;;(cdr (ly:molecule-get-extent headgl X))
601 (use-modules (ice-9 regex))
604 (let ((divisor (log 2)))
605 (lambda (z) (inexact->exact (/ (log z) divisor)))))
607 (define (parse-simple-duration duration-string)
608 "Parse the `duration-string', eg ''4..'' or ''breve.'', and return a (log dots) list."
609 (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string)))
610 (if (and match (string=? duration-string (match:substring match 0)))
611 (let ((len (match:substring match 1))
612 (dots (match:substring match 2)))
613 (list (cond ((string=? len "breve") -1)
614 ((string=? len "longa") -2)
615 ((string=? len "maxima") -3)
616 (else (log2 (string->number len))))
617 (if dots (string-length dots) 0)))
618 (error "This is not a valid duration string:" duration-string))))
620 (def-markup-command (note paper props duration-string dir) (string? number?)
621 "This produces a note with a stem pointing in @var{dir} direction, with
622 the @var{duration} for the note head type and augmentation dots. For
623 example, @code{\note #\"4.\" #-0.75} creates a dotted quarter note, with
624 a shortened down stem."
625 (let ((parsed (parse-simple-duration duration-string)))
626 (note-by-number-markup paper props (car parsed) (cadr parsed) dir)))
628 (def-markup-command (normal-size-super paper props mrkup) (markup?)
629 (ly:molecule-translate-axis (interpret-markup
632 (* 0.5 (cdr (chain-assoc 'baseline-skip props)))
635 (def-markup-command (super paper props mrkup) (markup?)
636 "Syntax: \\super MARKUP. "
637 (ly:molecule-translate-axis
640 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
642 (* 0.5 (cdr (chain-assoc 'baseline-skip props)))
645 (def-markup-command (translate paper props offset mrkup) (number-pair? markup?)
646 "Syntax: \\translate OFFSET MARKUP. "
647 (ly:molecule-translate (interpret-markup paper props mrkup)
650 (def-markup-command (sub paper props mrkup) (markup?)
651 "Syntax: \\sub MARKUP."
652 (ly:molecule-translate-axis
655 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
657 (* -0.5 (cdr (chain-assoc 'baseline-skip props)))
660 (def-markup-command (normal-size-sub paper props mrkup) (markup?)
661 (ly:molecule-translate-axis
662 (interpret-markup paper props mrkup)
663 (* -0.5 (cdr (chain-assoc 'baseline-skip props)))
666 (def-markup-command (hbracket paper props mrkup) (markup?)
667 "Horizontal brackets around its single argument. Syntax \\hbracket MARKUP."
668 (let ((th 0.1) ;; todo: take from GROB.
669 (m (interpret-markup paper props mrkup)))
670 (bracketify-molecule m X th (* 2.5 th) th)))
672 (def-markup-command (bracket paper props mrkup) (markup?)
673 "Vertical brackets around its single argument. Syntax \\bracket MARKUP."
674 (let ((th 0.1) ;; todo: take from GROB.
675 (m (interpret-markup paper props mrkup)))
676 (bracketify-molecule m Y th (* 2.5 th) th)))
678 ;; todo: fix negative space
679 (def-markup-command (hspace paper props amount) (number?)
680 "Syntax: \\hspace NUMBER."
682 (ly:make-molecule "" (cons 0 amount) '(-1 . 1) )
683 (ly:make-molecule "" (cons amount amount) '(-1 . 1))))
685 (def-markup-command (override paper props new-prop mrkup) (pair? markup?)
686 "Add the first argument in to the property list. Properties may be
687 any sort of property supported by @ref{font-interface} and
688 @ref{text-interface}, for example
690 \\override #'(font-family . married) \"bla\"
692 (interpret-markup paper (cons (list new-prop) props) mrkup))
694 (def-markup-command (smaller paper props mrkup) (markup?)
695 "Syntax: \\smaller MARKUP"
696 (let* ((fs (chain-assoc-get 'font-size props 0))
697 (entry (cons 'font-size (- fs 1))))
698 (interpret-markup paper (cons (list entry) props) mrkup)))
701 (def-markup-command (bigger paper props mrkup) (markup?)
702 "Syntax: \\bigger MARKUP"
703 (let* ((fs (chain-assoc-get 'font-size props 0))
704 (entry (cons 'font-size (+ fs 1))))
705 (interpret-markup paper (cons (list entry) props) mrkup)))
707 (def-markup-command larger (markup?)
710 (def-markup-command (box paper props mrkup) (markup?)
711 "Syntax: \\box MARKUP"
714 (m (interpret-markup paper props mrkup)))
715 (box-molecule m th pad)))
717 (def-markup-command (strut paper props) ()
720 A box of the same height as the space.
722 (let ((m (Text_item::interpret_markup paper props " ")))
723 (ly:molecule-set-extent! m X '(1000 . -1000))
726 (define number->mark-letter-vector (make-vector 25 #\A))
731 (if (= i (- (char->integer #\I) (char->integer #\A)))
733 (vector-set! number->mark-letter-vector j
734 (integer->char (+ i (char->integer #\A)))))
736 (define (number->markletter-string n)
737 "Double letters for big marks."
739 ((l (vector-length number->mark-letter-vector)))
742 (string-append (number->markletter-string (1- (quotient n l)))
743 (number->markletter-string (remainder n l)))
744 (make-string 1 (vector-ref number->mark-letter-vector n)))))
747 (def-markup-command (markletter paper props num) (number?)
748 "Markup letters: skip I and do double letters for big marks.
749 Syntax: \\markletter #25"
750 (Text_item::interpret_markup paper props (number->markletter-string num)))
752 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
755 (define (typecheck-with-error x)
758 (lambda () (markup? x))
759 (lambda (key message arg)
760 (display "\nERROR: markup format error: \n")
763 (write arg (current-output-port))))))
765 ;; test make-foo-markup functions
770 (display (make-line-markup (list (make-simple-markup "FOO"))))
772 (make-line-markup (make-simple-markup "FOO"))
773 (make-line-markup (make-simple-markup "FOO") (make-simple-markup "foo"))
774 (make-raise-markup "foo" (make-simple-markup "foo"))))
777 ;; test typecheckers. Not wholly useful, because errors are detected
778 ;; in other places than they're made.
782 ;; To get error messages, see above to install the alternate
783 ;; typecheck routine for markup?.
784 (display (typecheck-with-error `(,simple-markup "foobar")))
785 (display (typecheck-with-error `(,simple-markup "foobar")))
786 (display (typecheck-with-error `(,simple-markup 1)))
788 (typecheck-with-error `(,line-markup ((,simple-markup "foobar"))
789 (,simple-markup 1))))
791 (typecheck-with-error `(,line-markup (,simple-markup "foobar")
792 (,simple-markup "bla"))))))