X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Foutput-tex.scm;h=41d48ef03bcdfbe6ccd9f08c009a67918638098c;hb=84f8fad65295bbb2324b59de7c6c71084c817810;hp=7c7a104f25c255ca905e82dda529dc3a1b6dd678;hpb=12186b6828aee7aa298076d684835d629b757f2a;p=lilypond.git diff --git a/scm/output-tex.scm b/scm/output-tex.scm index 7c7a104f25..41d48ef03b 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -1,24 +1,36 @@ -;;; tex.scm -- implement Scheme output routines for TeX -;;; -;;; source file of the GNU LilyPond music typesetter -;;; -;;; (c) 1998--2004 Jan Nieuwenhuizen -;;; Han-Wen Nienhuys - - -(define-module (scm output-tex) ) -; (debug-enable 'backtrace) -(use-modules (scm output-ps) - (ice-9 regex) +;;;; tex.scm -- implement Scheme output routines for TeX +;;;; +;;;; source file of the GNU LilyPond music typesetter +;;;; +;;;; (c) 1998--2004 Jan Nieuwenhuizen +;;;; Han-Wen Nienhuys + + +;; (debug-enable 'backtrace) +(define-module (scm output-tex)) +(use-modules (ice-9 regex) (ice-9 string-fun) (ice-9 format) (guile) (srfi srfi-13) - (lily) - ) + (lily)) (define this-module (current-module)) +;; dumper-compatibility +(define output-ps #f) +(define (ps-output-expression expr port) + (if (not output-ps) + (let ((ps-module (resolve-module '(scm output-ps)))) + (eval '(use-modules (guile) (ice-9 regex) (srfi srfi-13) (lily)) + ps-module) + (set! output-ps ps-module))) + (display (eval expr output-ps) port)) + +;;; Output interface entry +(define-public (tex-output-expression expr port) + (display (eval expr this-module) port )) + ;;;;;;;; ;;;;;;;; DOCUMENT ME! ;;;;;;;; @@ -46,11 +58,11 @@ (font-load-command (car x) (cdr x))) (map cdr font-name-alist)))) - - +;; ;; urg, how can exp be #unspecified? -- in sketch output ;; ;; set! returns # --hwn +;; (define (fontify name-mag-pair exp) (string-append (select-font name-mag-pair) exp)) @@ -99,9 +111,10 @@ (module-map (lambda (sym var) (let ((val (variable-ref var)) + ;;(val (if (variable-bound? var) (variable-ref var) '"")) (tex-key (symbol->string sym))) - (if (memq sym fields) + (if (and (memq sym fields) (string? val)) (header-to-file basename sym val)) (cond @@ -120,37 +133,13 @@ (define (select-font name-mag-pair) (let ((c (assoc name-mag-pair font-name-alist))) - (if c (string-append "\\" (cddr c)) (begin - (ly:warn (string-append - "Programming error: No such font known " - (car name-mag-pair) " " - (ly:number->string (cdr name-mag-pair)))) - - (display "FAILED\n" (current-error-port)) - (if #f ;(pair? name-mag-pair)) - (display (object-type (car name-mag-pair)) (current-error-port)) - (write name-mag-pair (current-error-port))) - (if #f ; (pair? font-name-alist) - (display - (object-type (caaar font-name-alist)) (current-error-port)) - (write font-name-alist (current-error-port))) - - ;; (format #f "\n%FAILED: (select-font ~S)\n" name-mag-pair)) + (ly:warn + (format "Programming error: No such font: ~S" name-mag-pair)) "")))) -;; top-of-file, wtf? ugh: tagline? -(define (top-of-file) - (string-append - "% generated by LilyPond " - (lilypond-version) " (http://lilypond.org).\n" - "\\def\\lilypondtagline{Engraved by LilyPond (version " - (lilypond-version) - ")}\n" - )) - (define (blank) "") @@ -219,12 +208,12 @@ (define (end-output) (begin - ; uncomment for some stats about lily memory - ; (display (gc-stats)) + ;; uncomment for some stats about lily memory + ;; (display (gc-stats)) (string-append "\\lilypondend\n" - ; Put GC stats here. - ))) + ;; Put GC stats here. + ))) (define (experimental-on) "") @@ -249,20 +238,21 @@ "\\lilypondspecial\n" "\\lilypondpostscript\n")) -;; Note: this string must match the string in lilypond.py!!! -(define (header creator generate) +(define (header creator time-stamp page-count) (string-append - "% Generated automatically by: " creator generate "\n")) + "% Generated by " creator "\n" + "% at " time-stamp "\n" + ;; FIXME: duplicated in every backend + "\\def\\lilypondtagline{Engraved by LilyPond (version " + (lilypond-version)")}\n")) (define (invoke-char s i) (string-append "\n\\" s "{" (inexact->string i 10) "}" )) -;; -;; need to do something to make this really safe. -;; +;; FIXME: explain ploblem: need to do something to make this really safe. (define-public (output-tex-string s) - (if security-paranoia + (if safe-mode? (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post) s)) @@ -349,7 +339,10 @@ ;; no-origin not yet supported by Xdvi (define (no-origin) "") -(define-public (tex-output-expression expr port) - (display (eval expr this-module) port )) - +(define (start-page) + "\n%\\vbox{\n") +(define (stop-page last?) + (if last? + "\n%}\n" + "\n%}\n\\newpage\n"))