]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/output-pdftex.scm
* python/lilylib.py (make_ps_images): don't do showpage for
[lilypond.git] / scm / output-pdftex.scm
index ad3e3469b51aa859c0ab7cc3daae63f22139dda9..9dfb6040aec9642104fec2e7a5499ad18e6b2aa2 100644 (file)
 (define (unknown) 
   "%\n\\unknown\n")
 
-
 (define (select-font name-mag-pair)
-  (let*
-      (
-       (c (assoc name-mag-pair font-name-alist))
-       )
+  (let* ((c (assoc name-mag-pair font-name-alist)))
 
     (if (eq? c #f)
        (begin
          (display (object-type (car name-mag-pair)))
          (display (object-type (caaar font-name-alist)))
 
-         (ly:warn (string-append
-                   "Programming error: No such font known "
-                   (car name-mag-pair) " "
-                   (ly:number->string (cdr name-mag-pair))
-                   ))
+         (ly:warn "Programming error: No such font known ~S ~S"
+                  (car name-mag-pair) 
+                  (ly:number->string (cdr name-mag-pair)))
          "") ; issue no command
-       (string-append "\\" (cddr c)))
-    
-    
-    ))
+       (string-append "\\" (cddr c)))))
 
 (define (beam width slope thick blot)
   (embedded-pdf (list 'beam  width slope thick blot)))
 (define (bracket arch_angle arch_width arch_height height arch_thick thick)
   (embedded-pdf (list 'bracket  arch_angle arch_width arch_height height arch_thick thick)))
 
-(define (dashed-slur thick dash l)
-  (embedded-pdf (list 'dashed-slur   thick dash l)))
+(define (dashed-slur thick dash lst)
+  (embedded-pdf (list 'dashed-slur thick dash lst)))
 
 (define (char i)
-  (string-append "\\char" (inexact->string i 10) " "))
+  (string-append "\\char" (ly:inexact->string i 10) " "))
 
 (define (dashed-line thick on off dx dy)
   (embedded-pdf (list 'dashed-line  thick on off dx dy)))
    "\\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)
-  (embedded-pdf (list 'ez-ball  c  l b)))
+(define (ez-ball c lst b)
+  (embedded-pdf (list 'ez-ball  c  lst b)))
 
 (define (header-to-file fn key val)
   (set! key (symbol->string key))
   (if (not (equal? "-" fn))
-      (set! fn (string-append fn "." key))
-      )
+      (set! fn (string-append fn "." key)))
   (display
    (format "writing header field `~a' to `~a'..."
           key
-          (if (equal? "-" fn) "<stdout>" fn)
-          )
+          (if (equal? "-" fn) "<stdout>" fn))
    (current-error-port))
   (if (equal? fn "-")
       (display val)
-      (display val (open-file fn "w"))
-      )
+      (display val (open-file fn "w")))
   (display "\n" (current-error-port))
-  ""
-  )
+  "")
 
 (define (embedded-pdf expr)
-  (let
-      ((os (open-output-string)))
+  (let ((os (open-output-string)))
     (pdf-output-expression expr os)
     (string-append "\\embeddedpdf{" (get-output-string os) "}")))
 
-
-(define (comment s)
-  (simple-format #f "% ~a\n" s))
-
-(define (end-output) 
-  (begin
-                                       ; uncomment for some stats about lily memory      
-                                       ;               (display (gc-stats))
-    (string-append "%\n\\lilypondend\n"
-                                       ; Put GC stats here.
-                  )))
-
 (define (experimental-on)
   "")
 
 (define (repeat-slash w a t)
   (embedded-pdf (list 'repeat-slash w a t)))
-(define (fontify name-mag-pair exp)
-  (string-append (select-font name-mag-pair)
-                exp))
-
 
 (define (tex-encoded-fontswitch name-mag)
   (let* ((iname-mag (car name-mag))
     (cons iname-mag
          (cons ename-mag
                (string-append  "magfont"
-                         (string-encode-integer
-                          (hashq (car ename-mag) 1000000))
-                         "m"
-                         (string-encode-integer
-                          (inexact->exact (* 1000 (cdr ename-mag)))))))))
+                               (string-encode-integer
+                                (hashq (car ename-mag) 1000000))
+                               "m"
+                               (string-encode-integer
+                                (inexact->exact (* 1000 (cdr ename-mag)))))))))
 (define (define-fonts internal-external-name-mag-pairs)
   (set! font-name-alist (map tex-encoded-fontswitch
                             internal-external-name-mag-pairs))
                (font-load-command (car x) (cdr x)))
              (map cdr font-name-alist))))
 
-
 (define (font-switch i)
   (string-append
    "\\" (font i) "\n"))
    (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)))
-                   ))
+                   (else (error "unknown unit" (ly:unit)))))
    "}%\n"
    "\\ifx\\lilypondstart\\undefined\n"
    "  \\input lilyponddefs\n"
 
 (define (invoke-char s i)
   (string-append 
-   "\n\\" s "{" (inexact->string i 10) "}" ))
+   "\n\\" s "{" (ly: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 (output-tex-string s)
-  (if security-paranoia
-      (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
+  (if (ly:get-option 'safe)
+      (regexp-substitute/global
+       #f "\\\\"
+       (regexp-substitute/global #f "\\([{}]\\)" s 'pre "\\1" 'post)
+       'pre "$\\backslash$" 'post)
       s))
 
 (define (lily-def key val)
   (let ((tex-key
         (regexp-substitute/global 
-             #f "_" (output-tex-string key) 'pre "X" 'post))
+         #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")
                 (ly:number->string x) "}{"
                 s "}%\n"))
 
-(define (bezier-sandwich l thick)
-  (embedded-pdf (list 'bezier-sandwich  `(quote ,l) thick)))
+(define (bezier-sandwich lst thick)
+  (embedded-pdf (list 'bezier-sandwich `(quote ,lst) thick)))
 
 (define (start-system wd ht)
   (string-append "\\leavevmode\n"
       (string-append "\\special{src:\\string:"
                     (point-and-click line col file)
                     "}" )
-      "")
-  )
+      ""))
 
-                                       ; no-origin not supported in PDFTeX
+;; no-origin not supported in PDFTeX
 (define (no-origin) "")
 
-
-
-
 (define-public (pdftex-output-expression expr port)
-  (display (eval expr this-module) port) )
+  (display (eval expr this-module) port))