" ; "
-(define-public (simple-markup grob props . rest)
- (Text_item::text_to_molecule grob props (car rest))
- )
+;;;;;;;;;;;;;;;;;
+;; TODO:
+;; each markup function should have a doc string with
+;; syntax, description and example.
+;;
+
+(define-public (simple-markup grob props . rest)
+ (Text_item::interpret_markup grob props (car rest)))
(define-public (stack-molecule-line space molecules)
(if (pair? molecules)
)
(define-public (line-markup grob props . rest)
+ "A horizontal line of markups. Syntax:
+\\line << MARKUPS >>
+"
+
(stack-molecule-line
(cdr (chain-assoc 'word-space props))
(map (lambda (x) (interpret-markup grob props x)) (car rest)))
(cadr rest))
))
-
(define-public (finger-markup grob props . rest)
(interpret-markup grob
(cons (list '(font-relative-size . -3)
props)
(car rest)))
-
(define-public fontsize-markup (set-property-markup 'font-relative-size))
(define-public magnify-markup (set-property-markup 'font-magnification))
(font-markup 'font-family 'dynamic))
(define-public italic-markup
(font-markup 'font-shape 'italic))
+(define-public typewriter-markup
+ (font-markup 'font-family 'typewriter))
;; TODO: baseline-skip should come from the font.
mols)
))
+(define-public (right-align-markup grob props . rest)
+ (let* ((m (interpret-markup grob props (car rest))))
+ (ly:molecule-align-to! m X RIGHT)
+ m))
+
+(define-public (halign-markup grob props . rest)
+ "Set horizontal alignment. Syntax: haling A MARKUP. A=-1 is LEFT,
+A=1 is right, values in between vary alignment accordingly."
+ (let* ((m (interpret-markup grob props (cadr rest))))
+ (ly:molecule-align-to! m X (car rest))
+ m))
+
+(define-public (left-align-markup grob props . rest)
+ (let* ((m (interpret-markup grob props (car rest))))
+ (ly:molecule-align-to! m X RIGHT)
+ m))
+
(define-public (musicglyph-markup grob props . rest)
(ly:find-glyph-by-name
(ly:get-font grob (cons '((font-family . music)) props))
grob
props
(cadr rest))
- (car rest) Y)
- )
+ (car rest) Y))
+
+(define-public (fraction-markup grob props . rest)
+ "Make a fraction of two markups.
+
+Syntax: \\fraction MARKUP1 MARKUP2."
+
+ (let*
+ ((m1 (interpret-markup grob props (car rest)))
+ (m2 (interpret-markup grob props (cadr rest))))
+
+ (ly:molecule-align-to! m1 X CENTER)
+ (ly:molecule-align-to! m2 X CENTER)
+
+ (let*
+ ((x1 (ly:molecule-get-extent m1 X))
+ (x2 (ly:molecule-get-extent m2 X))
+ (line (ly:round-filled-box (interval-union x1 x2) '(-0.05 . 0.05) 0.0))
+
+ ;; should stack mols separately, to maintain LINE on baseline
+ (stack (stack-lines -1 0.2 0.6 (list m1 line m2))))
+
+ (ly:molecule-align-to! stack Y CENTER)
+ (ly:molecule-align-to! stack X LEFT)
+ ;; should have EX dimension
+ ;; empirical anyway
+ (ly:molecule-translate-axis stack 0.75 Y)
+ )))
(define-public (note-markup grob props . rest)
0))
(attachy (* dir 0.28))
(stemgl (if (> log 0)
- (ly:round-filled-box (cons
+ (ly:round-filled-box
(cons attachx (+ attachx stemth))
(cons (min stemy attachy)
- (max stemy attachy)))
+ (max stemy attachy))
(/ stemth 3)
) #f))
(dot (ly:find-glyph-by-name font "dots-dot"))
)
(define-public (hbracket-markup grob props . rest)
+ "Horizontal brackets around its single argument. Syntax \\hbracket MARKUP."
+
(let*
(
(th 0.1) ;; todo: take from GROB.
))
(define-public (bracket-markup grob props . rest)
+ "Vertical brackets around its single argument. Syntax \\bracket MARKUP."
(let*
(
(th 0.1) ;; todo: take from GROB.
(box-molecule m th pad)
))
+
+(define-public (strut-markup grob props . rest)
+ "Syntax: \strut
+
+ A box of the same height as the space.
+"
+
+ (let*
+ ((m (Text_item::interpret_markup grob props " ")))
+
+ (ly:molecule-set-extent! m 0 '(1000 . -1000))
+ m))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
(define (markup-signature-to-keyword sig)
" (A B C) -> a0-b1-c2 "
(cons finger-markup (list markup?))
(cons bold-markup (list markup?))
(cons italic-markup (list markup?))
+ (cons typewriter-markup (list markup?))
(cons roman-markup (list markup?))
(cons number-markup (list markup?))
(cons hbracket-markup (list markup?))
(cons bracket-markup (list markup?))
(cons note-markup (list integer? integer? ly:dir?))
+ (cons fraction-markup (list markup? markup?))
(cons column-markup (list markup-list?))
(cons dir-column-markup (list markup-list?))
(cons center-markup (list markup-list?))
(cons line-markup (list markup-list?))
+ (cons right-align-markup (list markup?))
+ (cons left-align-markup (list markup?))
+ (cons halign-markup (list number? markup?))
+
(cons combine-markup (list markup? markup?))
(cons simple-markup (list string?))
(cons musicglyph-markup (list scheme?))
(cons fontsize-markup (list number? markup?))
(cons box-markup (list markup?))
- )
- )
+ (cons strut-markup '())
+ ))
(define markup-module (current-module))
"
(let*
- (
- (arglen (length args))
+ ((arglen (length args))
(siglen (length signature))
(error-msg
(if (and (> siglen 0) (> arglen 0))
- (markup-argument-list-error signature args 1)))
- )
+ (markup-argument-list-error signature args 1)
+ #f)))
(if (or (not (= arglen siglen)) (< siglen 0) (< arglen 0))
markup-module
)
+;;
+;; TODO: add module argument so user-defined markups can also be
+;; processed.
+;;
(define-public (lookup-markup-command code)
(let*
- ( (sym (string->symbol (string-append code "-markup")))
- (var (module-local-variable markup-module sym))
- )
+ ((sym (string->symbol (string-append code "-markup")))
+ (var (module-local-variable markup-module sym))
+ )
(if (eq? var #f)
#f
(cons (variable-ref var) (object-property (variable-ref var) 'markup-keyword))
))
-(define-public (brew-new-markup-molecule grob)
- (let*
- ((t (ly:get-grob-property grob 'text))
- (chain (Font_interface::get_property_alist_chain grob)))
- (if (markup? t)
- (interpret-markup grob chain t)
- (Text_item::text_to_molecule grob t chain)
- )))
+(define-public brew-new-markup-molecule Text_item::brew_molecule)
(define-public empty-markup (make-simple-markup ""))
-(define-public (interpret-markup grob props markup)
- (if (string? markup)
- (simple-markup grob props markup)
- (let*
- (
- (func (car markup))
- (args (cdr markup))
- )
-
- (apply func (cons grob (cons props args)) )
- )))
+(define-public interpret-markup Text_item::interpret_markup)
;;;;;;;;;;;;;;;;