X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Foutput-tex.scm;h=b0fc77e8d47e8330149ad95f5c3a78ba89195ea5;hb=c9284cfe3b1fa3512f19c4e053077339c20d5662;hp=6a0cebe77ec9f5372fe2b74c9b9febb8f3234f70;hpb=03147447d5826e0f909150bd7720d88a06661be7;p=lilypond.git diff --git a/scm/output-tex.scm b/scm/output-tex.scm index 6a0cebe77e..b0fc77e8d4 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -3,41 +3,49 @@ ;;;; source file of the GNU LilyPond music typesetter ;;;; ;;;; (c) 1998--2004 Jan Nieuwenhuizen -;;;; Han-Wen Nienhuys +;;;; Han-Wen Nienhuys ;; (debug-enable 'backtrace) -;; the public interface is tight. +;; The public interface is tight. ;; It has to be, because user-code is evalled with this module. +;; ***It should also be clean, well defined, documented and reviewed*** + +;; To be reasonably safe, you probably do not want to use the TeX +;; backend anyway, but rather the PostScript backend. You may want +;; to run gs in a uml sandbox too. + + (define-module (scm output-tex) #:re-export (quote) + + ;; JUNK this -- see lily.scm: ly:all-output-backend-commands #:export (unknown - blank - dot - beam - bracket - dashed-slur - char - dashed-line - zigzag-line - symmetric-x-triangle - ez-ball - comment - repeat-slash - placebox - bezier-sandwich - horizontal-line - filledbox - round-filled-box - text - tuplet - polygon - draw-line - define-origin - no-origin - )) + blank + dot + white-dot + beam + bracket + dashed-slur + named-glyph + dashed-line + zigzag-line + ez-ball + comment + repeat-slash + placebox + bezier-sandwich + horizontal-line + filledbox + round-filled-box + text + white-text + polygon + draw-line + no-origin + grob-cause)) (use-modules (ice-9 regex) (ice-9 string-fun) @@ -47,11 +55,16 @@ (scm framework-tex) (lily)) + + ;;;;;;;; ;;;;;;;; DOCUMENT ME! ;;;;;;;; +(define (char font i) + (string-append "\\" (tex-font-command font) + "\\char" (ly:inexact->string i 10) " ")) (define (unknown) "%\n\\unknown\n") @@ -64,18 +77,38 @@ (define (dot x y radius) (embedded-ps (list 'dot x y radius))) + +(define (embedded-ps string) + (embedded-ps (list 'embedded-ps string))) + +(define (white-dot x y radius) + (embedded-ps (list 'white-dot x y radius))) + (define (beam width slope thick blot) (embedded-ps (list 'beam width slope thick blot))) (define (bracket arch_angle arch_width arch_height height arch_thick thick) (embedded-ps (list 'bracket arch_angle arch_width arch_height height arch_thick thick))) -(define (dashed-slur thick dash l) - (embedded-ps (list 'dashed-slur thick dash `(quote ,l)))) - -(define (char font i) - (string-append "\\" (tex-font-command font) - "\\char" (ly:inexact->string i 10) " ")) +(define (dashed-slur thick dash lst) + (embedded-ps (list 'dashed-slur thick dash `(quote ,lst)))) + +(define (named-glyph font name) + (let* ((info (ly:otf-font-glyph-info font name)) + (subfont (assoc-get 'subfont info)) + (subidx (assoc-get 'subfont-index info))) + + ;;(stderr "INFO: ~S\n" info) + ;;(stderr "FONT: ~S\n" font) + (if (and subfont subidx) + (string-append "\\" (tex-font-command-raw + subfont + (ly:font-magnification font)) + "\\char" (number->string subidx)) + + (begin + (ly:warn "Can't find ~a in ~a" name font) + "")))) (define (dashed-line thick on off dx dy) (embedded-ps (list 'dashed-line thick on off dx dy))) @@ -83,38 +116,18 @@ (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 (ez-ball c l b) - (embedded-ps (list 'ez-ball c l b))) - - +(define (ez-ball c lst b) + (embedded-ps (list 'ez-ball c lst b))) (define (embedded-ps expr) (let ((ps-string (with-output-to-string (lambda () (ps-output-expression expr (current-output-port)))))) (string-append "\\embeddedps{" ps-string "}"))) - -(define (comment s) - (string-append "% " s "\n")) - -(define (end-output) - (begin - ;; uncomment for some stats about lily memory - ;; (display (gc-stats)) - (string-append - "\\lilypondend\n" - ;; Put GC stats here. - ))) (define (repeat-slash w a t) (embedded-ps (list 'repeat-slash w a t))) - - (define (number->dim x) (string-append ;;ugh ly:* in backend needs compatibility func for standalone output @@ -124,8 +137,8 @@ (string-append "\\lyitem{" (ly:number->string x) "}{" (ly:number->string y) "}{" s "}%\n")) -(define (bezier-sandwich l thick) - (embedded-ps (list 'bezier-sandwich `(quote ,l) thick))) +(define (bezier-sandwich lst thick) + (embedded-ps (list 'bezier-sandwich `(quote ,lst) thick))) ;; WTF is this in every backend? (define (horizontal-line x1 x2 th) @@ -146,16 +159,16 @@ (embedded-ps (list 'round-filled-box x y width height blotdiam))) (define (text font s) - (let* - ((mapping #f) ;; (assoc-get 'char-mapping (ly:font-encoding-alist font)))) - + ;; (assoc-get 'char-mapping (ly:font-encoding-alist font)))) + (let* ((mapping #f) - ;; TODO: we'd better do this for PS only - ;; LaTeX gets in the way, and we need to remap - ;; nonprintable chars. - - (input-enc-name #f) ;; (assoc-get 'input-name (ly:font-encoding-alist font) )) - ) + ;; TODO: we'd better do this for PS only + ;; LaTeX gets in the way, and we need to remap + ;; nonprintable chars. + + ;; (assoc-get 'input-name (ly:font-encoding-alist font))) + + (input-enc-name #f)) (string-append "\\hbox{\\" (tex-font-command font) (if (string? input-enc-name) @@ -167,9 +180,8 @@ s)) "}"))) - -(define (tuplet ht gapx dx dy thick dir) - (embedded-ps (list 'tuplet ht gapx dx dy thick dir))) +(define (white-text scale s) + (embedded-ps (list 'white-text scale s))) (define (polygon points blotdiameter) (embedded-ps (list 'polygon `(quote ,points) blotdiameter))) @@ -177,13 +189,19 @@ (define (draw-line thick fx fy tx ty) (embedded-ps (list 'draw-line thick fx fy tx ty))) -(define (define-origin file line col) - (if (procedure? point-and-click) - (string-append "\\special{src:" ;;; \\string ? - (point-and-click line col file) - "}" ) - "")) - ;; no-origin not yet supported by Xdvi (define (no-origin) "") +(define (grob-cause grob) + (if (procedure? point-and-click) + (let* ((cause (ly:grob-property grob 'cause)) + (music-origin (if (ly:music? cause) + (ly:music-property cause 'origin))) + (location (if (ly:input-location? music-origin) + (ly:input-location music-origin)))) + (if (pair? location) + ;;; \\string ? + (string-append "\\special{src:" + (apply point-and-click location) "}") + "")) + "")) \ No newline at end of file