]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/output-ps.scm
* scm/output-ps.scm (header): Papersize from paper.
[lilypond.git] / scm / output-ps.scm
index a49156c011ebd017138968e54db0bfd33a1f5624..3635daf6b0ab4a012bb46b92ff4a2cdfb2b58cef 100644 (file)
@@ -50,7 +50,6 @@
             tuplet
             polygon
             draw-line
-            between-system-string
             define-origin
             no-origin
             start-page
@@ -59,6 +58,7 @@
 
 (use-modules (guile)
             (ice-9 regex)
+            (srfi srfi-1)
             (srfi srfi-13)
             (lily))
 
    (ly:number->string (* 10 thick))
    " ] 0 draw_dashed_slur"))
 
+;; FIXME -- now that we can have ENCODING == #f, this can be
+;; simplified, esp OVERRIDE-CODING-COMMAND
 (define (font-command font . override-coding-command)
   (let* ((name (ly:font-filename font))
         (magnify (ly:font-magnification font))
         (font-encoding (assoc-get 'output-name coding-alist))
         (coding-command (if (not (null? override-coding-command))
                             (car override-coding-command)
-                            (get-coding-command font-encoding))))
+                            (if font-encoding
+                                (get-coding-command font-encoding)
+                                #f))))
 
     (string-append
      "magfont" (string-encode-integer (hashq  name 1000000))
      "m" (string-encode-integer (inexact->exact (round (* 1000 magnify))))
-     (if (equal? input-encoding font-encoding) ""
+     (if (or (not font-encoding) (equal? input-encoding font-encoding)) ""
         (string-append "e" coding-command)))))
 
 (define (define-fonts paper font-list)
           (coding-alist (ly:font-encoding-alist font))
           (input-encoding (assoc-get 'input-name coding-alist))
           (font-encoding (assoc-get 'output-name coding-alist))
-          (plain (font-command font (get-coding-command font-encoding)))
           (command (font-command font))
+          ;; FIXME -- see (font-command )
+          (plain (if font-encoding
+                     (font-command font . (get-coding-command font-encoding))
+                     command))
           (designsize (ly:font-design-size font))
           (magnification (* (ly:font-magnification font)))
           (ops (ly:paper-lookup paper 'outputscale))
                               (assoc-get 'input-name
                                          (ly:font-encoding-alist x)))
                             font-list))
-        (encodings (uniq-list (sort-list encoding-list string<?))))
-    
+        (encodings (uniq-list (sort-list (filter string? encoding-list)
+                                         string<?))))
+
     (string-append
      (apply string-append (map font-load-encoding encodings))
      (apply string-append
   (string-append (ly:numbers->string (list breapth width depth height))
                 " draw_box"))
 
-(define (header creator time-stamp page-count-)
+(define (header creator time-stamp paper page-count- classic?)
   (set! page-count page-count-)
   (set! page-number 0)
   (string-append
    "%%Creator: " creator " " time-stamp "\n"
    "%%Pages: " (number->string page-count) "\n"
    "%%PageOrder: Ascend\n"
-   ;; FIXME: TODO get from paper
-   ;; "%%DocumentPaperSizes: a6\n"
+   "%%DocumentPaperSizes: " (ly:paper-lookup paper 'papersize) "\n"
    ;;(string-append "GNU LilyPond (" (lilypond-version) "), ")
    ;;     (strftime "%c" (localtime (current-time))))
    ;; FIXME: duplicated in every backend
     (ly:numbers->string
      (list x y width height blotdiam)) " draw_round_box"))
 
-(define (new-start-system origin dim)
+(define (start-system origin dim)
   (string-append
    "\n" (ly:number-pair->string origin) " start-system\n"
    "{\n"
    (ly:numbers->string (list breapth width depth height))
    " draw_box" ))
 
-(define (stop-system)
+(define (stop-system last?)
   "} stop-system\n")
 
-(define stop-last-system stop-system)
-
 (define (symmetric-x-triangle thick w h)
   (string-append
    (ly:numbers->string (list h w thick))
    " draw_symmetric_x_triangle"))
 
 (define (text font s)
-  (string-append (font-command font) " setfont "
-                "(" (ps-encoding s) ") show"))
+  (let*
+      
+      (
+       ;; ugh, we should find a better way to
+       ;; extract the hsbw for /space from the font.
+       
+       (space-length (cdar (ly:text-dimension font "t"))) 
+       (commands '())
+       (add-command (lambda (x) (set! commands (cons x commands)))) )
+
+    (string-fold
+     (lambda (chr word)
+       "Translate space as into moveto, group the rest in words."
+       (if (and (< 0 (string-length word))
+               (equal? #\space  chr))
+          (add-command 
+           (string-append "(" (ps-encoding word) ") show\n")))
+
+       (if (equal? #\space  chr)
+          (add-command  (string-append (number->string space-length) " 0.0 rmoveto ")) )
+       
+       (if (equal? #\space  chr)
+          ""
+          (string-append word (make-string 1 chr))))
+     ""
+     (string-append  s " "))
 
+    (string-append
+     (font-command font) " setfont "
+     (string-join (reverse commands)))
+    ))
+  
 (define (unknown) 
   "\n unknown\n")