1 ;;; pdftex.scm -- implement Scheme output routines for PDFTeX
3 ;;; source file of the GNU LilyPond music typesetter
4 ;;; modified from the existing tex.scm
6 ;;; (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
7 ;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 ;;; Stephen Peters <portnoy@portnoy.org>
11 ;; TODO: port this to the new module framework.
13 (define-module (scm pdftex))
19 (define (select-font name-mag-pair)
22 (c (assoc name-mag-pair font-name-alist))
28 (display (object-type (car name-mag-pair)))
29 (display (object-type (caaar font-name-alist)))
31 (ly-warn (string-append
32 "Programming error: No such font known "
33 (car name-mag-pair) " "
34 (ly-number->string (cdr name-mag-pair))
36 "") ; issue no command
37 (string-append "\\" (cddr c)))
42 (define (beam width slope thick)
43 (embedded-pdf ((pdf-scm 'beam) width slope thick)))
45 (define (bracket arch_angle arch_width arch_height height arch_thick thick)
46 (embedded-pdf ((pdf-scm 'bracket) arch_angle arch_width arch_height height arch_thick thick)))
48 (define (dashed-slur thick dash l)
49 (embedded-pdf ((pdf-scm 'dashed-slur) thick dash l)))
51 (define (hairpin thick w sh eh)
52 (embedded-pdf ((pdf-scm 'hairpin) thick w sh eh)))
55 (string-append "\\char" (inexact->string i 10) " "))
57 (define (dashed-line thick on off dx dy)
58 (embedded-pdf ((pdf-scm 'dashed-line) thick on off dx dy)))
60 (define (font-load-command name-mag command)
62 "\\font\\" command "="
65 (ly-number->string (inexact->exact (* 1000 (cdr name-mag))))
68 (define (ez-ball c l b)
69 (embedded-pdf ((pdf-scm 'ez-ball) c l b)))
71 (define (embedded-pdf s)
72 (string-append "\\embeddedpdf{ " s "}"))
75 (string-append "% " s))
79 ; uncomment for some stats about lily memory
80 ; (display (gc-stats))
81 (string-append "\n\\EndLilyPondOutput"
85 (define (experimental-on)
88 (define (repeat-slash w a t)
89 (embedded-pdf ((pdf-scm 'repeat-slash) w a t)))
91 (define (font-switch i)
95 (define (font-def i s)
97 "\\font" (font-switch i) "=" s "\n"))
101 "\\input lilyponddefs\\newdimen\\outputscale \\outputscale=\\lilypondpaperoutputscale pt"
103 "\\pdfcompresslevel=0"))
105 ;; Note: this string must match the string in ly2dvi.py!!!
106 (define (header creator generate)
108 "% Generated automatically by: " creator generate "\n"))
110 (define (invoke-char s i)
112 "\n\\" s "{" (inexact->string i 10) "}" ))
115 ;; need to do something to make this really safe.
117 (define (output-tex-string s)
118 (if security-paranoia
120 (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
121 (begin (display "warning: not paranoid") (newline) s))
124 (define (lily-def key val)
127 (regexp-substitute/global
128 #f "_" (output-tex-string key) 'pre "X" 'post)
129 (output-tex-string key)))
130 (tex-val (output-tex-string val)))
131 (if (equal? (sans-surrounding-whitespace tex-val) "")
132 (string-append "\\let\\" tex-key "\\undefined\n")
133 (string-append "\\def\\" tex-key "{" tex-val "}\n"))))
135 (define (number->dim x)
137 ;;ugh ly-* in backend needs compatibility func for standalone output
138 (ly-number->string x) " \\outputscale "))
140 (define (placebox x y s)
143 (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
145 (define (bezier-sandwich l thick)
146 (embedded-pdf ((pdf-scm 'bezier-sandwich) l thick)))
148 (define (start-system ht)
149 (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
151 (define (stop-system)
152 "}\\vss}\\interscoreline\n")
153 (define (stop-last-system)
155 (define (filledbox breapth width depth height)
157 "\\kern" (number->dim (- breapth))
158 "\\vrule width " (number->dim (+ breapth width))
159 "depth " (number->dim depth)
160 "height " (number->dim height) " "))
162 (define (roundfilledbox x width y height blotdiam)
163 (embedded-pdf ((pdf-scm 'roundfilledbox) x width y height blotdiam)))
166 (string-append "\\hbox{" (output-tex-string s) "}"))
168 (define (tuplet ht gapx dx dy thick dir)
169 (embedded-pdf ((pdf-scm 'tuplet) ht gapx dx dy thick dir)))
171 (define (volta h w thick vert_start vert_end)
172 (embedded-pdf ((pdf-scm 'volta) h w thick vert_start vert_end)))
174 (define (define-origin file line col)
175 (if (procedure? point-and-click)
176 (string-append "\\special{src:\\string:"
177 (point-and-click line col file)
182 ; no-origin not supported in PDFTeX
183 (define (no-origin) "")
186 (define (scm-pdftex-output)
187 (primitive-eval (pdftex-scm 'all-definitions)))