X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Ftex.scm;h=ef95de07ef797f4e2c5d9fed6c4acd051fd1176b;hb=ffe6f890aaa8bcf7638682a2ced4411330b30144;hp=4f997945c4831e90e319c231383f17a6e752eabf;hpb=48631a04b6181cd7be65702574eaaa6c52284bd2;p=lilypond.git diff --git a/scm/tex.scm b/scm/tex.scm index 4f997945c4..ef95de07ef 100644 --- a/scm/tex.scm +++ b/scm/tex.scm @@ -1,8 +1,9 @@ + ;;; tex.scm -- implement Scheme output routines for TeX ;;; ;;; source file of the GNU LilyPond music typesetter ;;; -;;; (c) 1998--2001 Jan Nieuwenhuizen +;;; (c) 1998--2002 Jan Nieuwenhuizen ;;; Han-Wen Nienhuys @@ -13,13 +14,17 @@ (ice-9 string-fun) (ice-9 format) (guile) + (lily) ) (define this-module (current-module)) ;;;;;;;; ;;;;;;;; DOCUMENT ME! -;;;;;;;; +;;;;;;;; + +(define font-name-alist '()) + (define (tex-encoded-fontswitch name-mag) (let* ((iname-mag (car name-mag)) (ename-mag (cdr name-mag))) @@ -51,7 +56,7 @@ (define (unknown) - "%\n\\unknown%\n") + "%\n\\unknown\n") (define (select-font name-mag-pair) (let* @@ -65,10 +70,10 @@ (display (object-type (car name-mag-pair))) (display (object-type (caaar font-name-alist))) - (ly-warn (string-append + (ly:warn (string-append "Programming error: No such font known " (car name-mag-pair) " " - (ly-number->string (cdr name-mag-pair)) + (ly:number->string (cdr name-mag-pair)) )) "") ; issue no command (string-append "\\" (cddr c))) @@ -76,6 +81,12 @@ )) +(define (blank) + "") + +(define (dot x y radius) + (embedded-ps (list 'dot x y radius))) + (define (beam width slope thick) (embedded-ps (list 'beam width slope thick))) @@ -91,12 +102,18 @@ (define (dashed-line thick on off dx dy) (embedded-ps (list 'dashed-line thick on off dx dy))) +(define (zigzag-line centre? zzw zzh thick dx dy) + (embedded-ps (list 'zigzag-line centre? zzw zzh thick dx dy))) + +(define (symmetric-x-triangle t w h) + (embedded-ps (list 'symmetric-x-triangle t w h))) + (define (font-load-command name-mag command) (string-append "\\font\\" command "=" (car name-mag) " scaled " - (ly-number->string (inexact->exact (* 1000 (cdr name-mag)))) + (ly:number->string (inexact->exact (* 1000 (cdr name-mag)))) "\n")) (define (ez-ball c l b) @@ -142,7 +159,8 @@ (begin ; uncomment for some stats about lily memory ; (display (gc-stats)) - (string-append "\n\\EndLilyPondOutput" + (string-append + "\\lilypondend\n" ; Put GC stats here. ))) @@ -152,35 +170,22 @@ (define (repeat-slash w a t) (embedded-ps (list 'repeat-slash w a t))) -(define (font-switch i) - (string-append - "\\" (font i) "\n")) - -(define (font-def i s) - (string-append - "\\font" (font-switch i) "=" s "\n")) - (define (header-end) (string-append "\\def\\scaletounit{ " (number->string (cond - ((equal? (ly-unit) "mm") (/ 72.0 25.4)) - ((equal? (ly-unit) "pt") (/ 72.0 72.27)) - (else (error "unknown unit" (ly-unit))) + ((equal? (ly:unit) "mm") (/ 72.0 25.4)) + ((equal? (ly:unit) "pt") (/ 72.0 72.27)) + (else (error "unknown unit" (ly:unit))) )) - " mul }" - "\\special{\\string! " - - ;; URG: ly-gulp-file: now we can't use scm output without Lily - (if use-regex - ;; fixed in 1.3.4 for powerpc -- broken on Windows - (regexp-substitute/global #f "\n" - (ly-gulp-file "music-drawing-routines.ps") 'pre " %\n" 'post) - (ly-gulp-file "music-drawing-routines.ps")) -; (if (defined? 'ps-testing) "/testing true def%\n" "") - "}" - "\\input lilyponddefs \\outputscale=\\lilypondpaperoutputscale \\lilypondpaperunit" - "\\turnOnPostScript")) + " mul }%\n" + "\\ifx\\lilypondstart\\undefined\n" + " \\input lilyponddefs\n" + "\\fi\n" + "\\outputscale = \\lilypondpaperoutputscale\\lilypondpaperunit\n" + "\\lilypondstart\n" + "\\lilypondspecial\n" + "\\lilypondpostscript\n")) ;; Note: this string must match the string in ly2dvi.py!!! (define (header creator generate) @@ -196,32 +201,29 @@ ;; (define-public (output-tex-string s) (if security-paranoia - (if use-regex - (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post) - (begin (display "warning: not paranoid") (newline) s)) + (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post) s)) (define (lily-def key val) (let ((tex-key - (if use-regex - ;; fixed in 1.3.4 for powerpc -- broken on Windows - (regexp-substitute/global - #f "_" (output-tex-string key) 'pre "X" 'post) - (output-tex-string key))) + (regexp-substitute/global + #f "_" (output-tex-string key) 'pre "X" 'post)) + (tex-val (output-tex-string val))) (if (equal? (sans-surrounding-whitespace tex-val) "") (string-append "\\let\\" tex-key "\\undefined\n") - (string-append "\\def\\" tex-key "{" tex-val "}\n")))) + (string-append "\\def\\" tex-key "{" tex-val "}%\n")))) (define (number->dim x) (string-append - ;;ugh ly-* in backend needs compatibility func for standalone output - (ly-number->string x) " \\outputscale ")) + ;;ugh ly:* in backend needs compatibility func for standalone output + (ly:number->string x) " \\outputscale ")) (define (placebox x y s) - (string-append - "\\placebox{" - (number->dim y) "}{" (number->dim x) "}{" s "}%\n")) + (string-append "\\lyitem{" + (ly:number->string y) "}{" + (ly:number->string x) "}{" + s "}%\n")) (define (bezier-bow l thick) (embedded-ps (list 'bezier-bow `(quote ,l) thick))) @@ -229,25 +231,31 @@ (define (bezier-sandwich l thick) (embedded-ps (list 'bezier-sandwich `(quote ,l) thick))) -(define (start-system ht) - (string-append "\\vbox to " (number->dim ht) "{\\hbox{" - "%\n")) +(define (start-system wd ht) + (string-append "\\leavevmode\n" + "\\scoreshift = " (number->dim (* ht 0.5)) "\n" + "\\lilypondifundefined{lilypondscoreshift}%\n" + " {}%\n" + " {\\advance\\scoreshift by -\\lilypondscoreshift}%\n" + "\\lybox{" + (ly:number->string wd) "}{" + (ly:number->string ht) "}{%\n")) (define (stop-system) - "}\\vss}\\interscoreline\n") + "}%\n%\n\\interscoreline\n%\n") (define (stop-last-system) - "}\\vss}") + "}%\n") (define (filledbox breapth width depth height) (if (and #f (defined? 'ps-testing)) (embedded-ps (string-append (numbers->string (list breapth width depth height)) " draw_box" )) - (string-append - "\\kern" (number->dim (- breapth)) - "\\vrule width " (number->dim (+ breapth width)) - "depth " (number->dim depth) - "height " (number->dim height) " "))) + (string-append "\\lyvrule{" + (ly:number->string (- breapth)) "}{" + (ly:number->string (+ breapth width)) "}{" + (ly:number->string depth) "}{" + (ly:number->string height) "}"))) (define (roundfilledbox x y width height blotdiam) (embedded-ps (list 'roundfilledbox x y width height blotdiam))) @@ -258,6 +266,9 @@ (define (tuplet ht gapx dx dy thick dir) (embedded-ps (list 'tuplet ht gapx dx dy thick dir))) +(define (polygon points blotdiameter) + (embedded-ps (list 'polygon `(quote ,points) blotdiameter))) + (define (draw-line thick fx fy tx ty) (embedded-ps (list 'draw-line thick fx fy tx ty))) @@ -272,17 +283,11 @@ "") ) - ; no-origin not yet supported by Xdvi +;; no-origin not yet supported by Xdvi (define (no-origin) "") -(define my-eval-in-module eval) - -(if (or (equal? (minor-version) "4.1") - (equal? (minor-version) "4") - (equal? (minor-version) "3.4")) - (set! my-eval-in-module eval-in-module)) - (define-public (tex-output-expression expr port) - (display (my-eval-in-module expr this-module) port ) + (display (eval expr this-module) port ) ) +