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)))
52 (string-append "\\char" (inexact->string i 10) " "))
54 (define (dashed-line thick on off dx dy)
55 (embedded-pdf ((pdf-scm 'dashed-line) thick on off dx dy)))
57 (define (font-load-command name-mag command)
59 "\\font\\" command "="
62 (ly-number->string (inexact->exact (* 1000 (cdr name-mag))))
65 (define (ez-ball c l b)
66 (embedded-pdf ((pdf-scm 'ez-ball) c l b)))
68 (define (embedded-pdf s)
69 (string-append "\\embeddedpdf{ " s "}"))
72 (string-append "% " s))
76 ; uncomment for some stats about lily memory
77 ; (display (gc-stats))
78 (string-append "\n\\EndLilyPondOutput"
82 (define (experimental-on)
85 (define (repeat-slash w a t)
86 (embedded-pdf ((pdf-scm 'repeat-slash) w a t)))
88 (define (font-switch i)
92 (define (font-def i s)
94 "\\font" (font-switch i) "=" s "\n"))
98 "\\input lilyponddefs\\newdimen\\outputscale \\outputscale=\\lilypondpaperoutputscale pt"
100 "\\pdfcompresslevel=0"))
102 ;; Note: this string must match the string in ly2dvi.py!!!
103 (define (header creator generate)
105 "% Generated automatically by: " creator generate "\n"))
107 (define (invoke-char s i)
109 "\n\\" s "{" (inexact->string i 10) "}" ))
112 ;; need to do something to make this really safe.
114 (define (output-tex-string s)
115 (if security-paranoia
117 (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
118 (begin (display "warning: not paranoid") (newline) s))
121 (define (lily-def key val)
124 (regexp-substitute/global
125 #f "_" (output-tex-string key) 'pre "X" 'post)
126 (output-tex-string key)))
127 (tex-val (output-tex-string val)))
128 (if (equal? (sans-surrounding-whitespace tex-val) "")
129 (string-append "\\let\\" tex-key "\\undefined\n")
130 (string-append "\\def\\" tex-key "{" tex-val "}\n"))))
132 (define (number->dim x)
134 ;;ugh ly-* in backend needs compatibility func for standalone output
135 (ly-number->string x) " \\outputscale "))
137 (define (placebox x y s)
140 (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
142 (define (bezier-sandwich l thick)
143 (embedded-pdf ((pdf-scm 'bezier-sandwich) l thick)))
145 (define (start-system ht)
146 (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
148 (define (stop-system)
149 "}\\vss}\\interscoreline\n")
150 (define (stop-last-system)
152 (define (filledbox breapth width depth height)
154 "\\kern" (number->dim (- breapth))
155 "\\vrule width " (number->dim (+ breapth width))
156 "depth " (number->dim depth)
157 "height " (number->dim height) " "))
159 (define (roundfilledbox x width y height blotdiam)
160 (embedded-pdf ((pdf-scm 'roundfilledbox) x width y height blotdiam)))
163 (string-append "\\hbox{" (output-tex-string s) "}"))
166 (define (define-origin file line col)
167 (if (procedure? point-and-click)
168 (string-append "\\special{src:\\string:"
169 (point-and-click line col file)
174 ; no-origin not supported in PDFTeX
175 (define (no-origin) "")
178 (define (scm-pdftex-output)
179 (primitive-eval (pdftex-scm 'all-definitions)))