1 ;;;; tex.scm -- implement Scheme output routines for TeX
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 ;; (debug-enable 'backtrace)
11 ;; the public interface is tight.
12 ;; It has to be, because user-code is evalled with this module.
14 (define-module (scm output-tex)
42 (use-modules (ice-9 regex)
64 (define (dot x y radius)
65 (embedded-ps (list 'dot x y radius)))
67 (define (beam width slope thick blot)
68 (embedded-ps (list 'beam width slope thick blot)))
70 (define (bracket arch_angle arch_width arch_height height arch_thick thick)
71 (embedded-ps (list 'bracket arch_angle arch_width arch_height height arch_thick thick)))
73 (define (dashed-slur thick dash l)
74 (embedded-ps (list 'dashed-slur thick dash `(quote ,l))))
77 (string-append "\\" (tex-font-command font)
78 "\\char" (ly:inexact->string i 10) " "))
80 (define (dashed-line thick on off dx dy)
81 (embedded-ps (list 'dashed-line thick on off dx dy)))
83 (define (zigzag-line centre? zzw zzh thick dx dy)
84 (embedded-ps (list 'zigzag-line centre? zzw zzh thick dx dy)))
86 (define (symmetric-x-triangle t w h)
87 (embedded-ps (list 'symmetric-x-triangle t w h)))
90 (define (ez-ball c l b)
91 (embedded-ps (list 'ez-ball c l b)))
95 (define (embedded-ps expr)
97 (with-output-to-string
98 (lambda () (ps-output-expression expr (current-output-port))))))
99 (string-append "\\embeddedps{" ps-string "}")))
102 (define (repeat-slash w a t)
103 (embedded-ps (list 'repeat-slash w a t)))
107 (define (number->dim x)
109 ;;ugh ly:* in backend needs compatibility func for standalone output
110 (ly:number->string x) " \\outputscale "))
112 (define (placebox x y s)
114 "\\lyitem{" (ly:number->string x) "}{" (ly:number->string y) "}{" s "}%\n"))
116 (define (bezier-sandwich l thick)
117 (embedded-ps (list 'bezier-sandwich `(quote ,l) thick)))
119 ;; WTF is this in every backend?
120 (define (horizontal-line x1 x2 th)
121 (filledbox (- x1) (- x2 x1) (* .5 th) (* .5 th)))
123 (define (filledbox breapth width depth height)
124 (if (and #f (defined? 'ps-testing))
126 (string-append (ly:numbers->string (list breapth width depth height))
128 (string-append "\\lyvrule{"
129 (ly:number->string (- breapth)) "}{"
130 (ly:number->string (+ breapth width)) "}{"
131 (ly:number->string depth) "}{"
132 (ly:number->string height) "}")))
134 (define (round-filled-box x y width height blotdiam)
135 (embedded-ps (list 'round-filled-box x y width height blotdiam)))
137 (define (text font s)
139 ((mapping #f) ;; (assoc-get 'char-mapping (ly:font-encoding-alist font))))
142 ;; TODO: we'd better do this for PS only
143 ;; LaTeX gets in the way, and we need to remap
144 ;; nonprintable chars.
146 (input-enc-name #f) ;; (assoc-get 'input-name (ly:font-encoding-alist font) ))
149 (string-append "\\hbox{\\" (tex-font-command font)
150 (if (string? input-enc-name)
151 (string-append "\\inputencoding{" input-enc-name "}")
154 (if (vector? mapping)
155 (reencode-string mapping s)
160 (define (tuplet ht gapx dx dy thick dir)
161 (embedded-ps (list 'tuplet ht gapx dx dy thick dir)))
163 (define (polygon points blotdiameter)
164 (embedded-ps (list 'polygon `(quote ,points) blotdiameter)))
166 (define (draw-line thick fx fy tx ty)
167 (embedded-ps (list 'draw-line thick fx fy tx ty)))
169 (define (define-origin file line col)
170 (if (procedure? point-and-click)
171 (string-append "\\special{src:" ;;; \\string ?
172 (point-and-click line col file)
176 ;; no-origin not yet supported by Xdvi
177 (define (no-origin) "")