1 ;;;; output-lib.scm -- implement Scheme output helper functions
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 (define (arg->string arg)
10 (cond ((number? arg) (inexact->string arg 10))
11 ((string? arg) (string-append "\"" arg "\""))
12 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
15 (define (func name . args)
21 (map (lambda (x) (string-append " " (arg->string x))) args)))
25 ;;(define (mm-to-pt x)
26 ;; (* (/ 72.27 25.40) x))
28 ;; do nothing in .scm output
29 (define (comment s) "")
31 (define (numbers->string l)
32 (apply string-append (map ly-number->string l)))
34 ; (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
36 (define (number->octal-string x)
37 (let* ((n (inexact->exact x))
39 (n8 (quotient (- n (* n64 64)) 8)))
43 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
45 (define (inexact->string x radix)
46 (let ((n (inexact->exact x)))
47 (number->string n radix)))
50 (define (control->string c)
51 (string-append (number->string (car c)) " "
52 (number->string (cdr c)) " "))
57 (make-string 1 (integer->char (+ (char->integer #\A) i)))))
59 (define (scm-scm action-name)
64 (define (find-notehead-symbol duration style)
66 ((xcircle) "2xcircle")
67 ((harmonic) "0mensural")
69 (string-append (number->string duration)
70 (if (< duration 0) "mensural" "")))
71 ((default) (number->string duration))
73 (string-append (number->string (max 0 duration)) (symbol->string style)))))
76 (define (note-head-style->attachment-coordinates style)
77 "Return pair (X . Y), containing multipliers for the note head
78 bounding box, where to attach the stem. e.g.: X==0 means horizontally
79 centered, X==1 is at the right, X == -1 is at the left."
82 ((default) '(1.0 . 0.5))
83 ((cross) '(1.0 . 0.75))
84 ((mensural) '(0.0 . 0.6))
85 ((diamond) '(1.0 . 0.8))
86 ((transparent) '(1.0 . 1.0))
87 ((slash) '(1.0 . 1.0))
88 ((harmonic) '(1.0 0.0))
93 (define (string-encode-integer i)
96 ((< i 0) (string-append "n" (string-encode-integer (- i))))
98 (make-string 1 (integer->char (+ 65 (modulo i 26))))
99 (string-encode-integer (quotient i 26))))))
102 (define (tex-encoded-fontswitch name-mag)
103 (let* ((iname-mag (car name-mag))
104 (ename-mag (cdr name-mag)))
107 (string-append "magfont"
108 (string-encode-integer
109 (hashq (car ename-mag) 1000000))
111 (string-encode-integer
112 (inexact->exact (* 1000 (cdr ename-mag)))))))))
114 (define (define-fonts internal-external-name-mag-pairs)
115 (set! font-name-alist (map tex-encoded-fontswitch
116 internal-external-name-mag-pairs))
119 (font-load-command (car x) (cdr x)))
120 (map cdr font-name-alist))))
122 (define (fontify name-mag-pair exp)
123 (string-append (select-font name-mag-pair)