X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fframework-ps.scm;h=c7214da3c597d25c5dcf49210a1f90efe829ab1c;hb=31c5fd7a58a5db058a4aea65eb2957d12f7dab76;hp=28579ebc96f93c0175d793fa39d8dd2547741cfb;hpb=f605c1bfb0803efce1fad4472820360b7d40e0bd;p=lilypond.git diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index 28579ebc96..c7214da3c5 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -2,7 +2,7 @@ ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; -;;;; (c) 2004--2006 Han-Wen Nienhuys +;;;; (c) 2004--2007 Han-Wen Nienhuys (define-module (scm framework-ps)) @@ -17,10 +17,7 @@ (scm clip-region) (lily)) -(define (format dest . rest) - (if (string? dest) - (apply simple-format (cons #f (cons dest rest))) - (apply simple-format (cons dest rest)))) +(define format ergonomic-simple-format) (define framework-ps-module (current-module)) @@ -249,14 +246,21 @@ (define (write-preamble paper load-fonts? port) - - (define (load-font-via-GS font-name-filename) - (define (ps-load-file name) - (format - (if (string? name) - "(~a) (r) file .loadfont\n" - "% cannot find font file: ~a\n") - name)) + (define (internal-font? file-name) + (or (string-startswith file-name "Emmentaler") + (string-startswith file-name "emmentaler") + (string-startswith file-name "aybabtu") + (string-startswith file-name "Aybabtu"))) + (define (load-font-via-GS font-name-filename) + (define (ps-load-file file-name) + (if (string? file-name) + (if (string-contains file-name (ly:get-option 'datadir)) + (begin + (set! file-name (ly:string-substitute (ly:get-option 'datadir) "" file-name)) + (format "lilypond-datadir (~a) concatstrings (r) file .loadfont" file-name)) + + (format "(~a) (r) file .loadfont\n" file-name)) + (format "% cannot find font file: ~a\n" file-name))) (let* ((font (car font-name-filename)) (name (cadr font-name-filename)) @@ -269,10 +273,7 @@ (if (mac-font? bare-file-name) (handle-mac-font name bare-file-name) (cond - ((or (string-startswith file-name "Emmentaler") - (string-startswith file-name "emmentaler") - (string-startswith file-name "aybabtu") - (string-startswith file-name "Aybabtu")) + ((internal-font? file-name) (ps-load-file (ly:find-file (format "~a.otf" file-name)))) ((string? bare-file-name) @@ -385,6 +386,8 @@ (define (load-fonts paper) (let* ((fonts (ly:paper-fonts paper)) + + ;; todo - doc format of list. (all-font-names (map (lambda (font) @@ -411,14 +414,30 @@ (sort (apply append all-font-names) (lambda (x y) (stringexact - (round (/ (* x scale) (ly:bp 1)))))) mmbox))) - - (list (car box) - (cadr box) - (max (1+ (car box)) (caddr box)) - (max (1+ (cadr box)) (cadddr box)) + (strip-non-number (lambda (x) + (if (or (nan? x) (inf? x)) 0.0 x))) + (directed-round (lambda (x rounder) + (inexact->exact + (rounder (/ (* (strip-non-number x) scale) + (ly:bp 1))))))) + (list (directed-round (car box) floor) + (directed-round (cadr box) floor) + (directed-round (max (1+ (car box)) (caddr box)) ceiling) + (directed-round (max (1+ (cadr box)) (cadddr box)) ceiling) ))) (let* ((outputter (ly:make-paper-outputter @@ -539,10 +558,10 @@ ;; content-mangling is always bad. ;; MINGW hack: need to have "b"inary for embedding CFFs (open-file (format "~a.eps" filename) "wb") - "ps")) + 'ps)) (port (ly:outputter-port outputter)) - (rounded-bbox (to-bp-box bbox)) + (rounded-bbox (to-rounded-bp-box bbox)) (port (ly:outputter-port outputter)) (header (eps-header paper rounded-bbox load-fonts))) @@ -581,7 +600,7 @@ ((xext (car ext-system-pair)) (paper-system (cdr ext-system-pair)) (yext (paper-system-extent paper-system Y)) - (bbox (list (car xext) (car yext) + (bbox (list (car xext) (car yext) (cdr xext) (cdr yext))) (filename (if (< 0 count) (format "~a-~a" basename count) @@ -763,7 +782,7 @@ (ly:error (_ "\nThe PostScript backend does not support the system-by-system output. For that, use the EPS backend instead, - lilypond -b eps + lilypond -dbackend=eps FILE If have cut & pasted a lilypond fragment from a webpage, be sure to only remove anything before @@ -771,5 +790,4 @@ to only remove anything before %% **************************************************************** %% Start cut-&-pastable-section %% **************************************************************** - ")))