X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fframework-ps.scm;h=7c5669fdb32ecd11b80ded4d137994e30ddfb81c;hb=1ae837b4312cac4ac71a08b2f47677110846c1af;hp=4a4ae30b7a9145bed67632b08efa7197b11511c2;hpb=16cb456cabf477f6d398ff731aa0f10b60913394;p=lilypond.git diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index 4a4ae30b7a..7c5669fdb3 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -8,9 +8,7 @@ ;;; this is still too big a mess. -(use-modules (ice-9 regex) - (ice-9 string-fun) - (ice-9 format) +(use-modules (ice-9 string-fun) (guile) (scm page) (scm paper-system) @@ -19,6 +17,7 @@ (scm clip-region) (lily)) +(define format ergonomic-simple-format) (define framework-ps-module (current-module)) @@ -31,7 +30,12 @@ (string-append "magfont" - (string-regexp-substitute "[ /%]" "_" name) + (ly:string-substitute + " " "_" + (ly:string-substitute + "/" "_" + (ly:string-substitute + "%" "_" name))) "m" (string-encode-integer (inexact->exact (round (* 1000 magnify))))))) (define (tex-font? fontname) @@ -45,10 +49,6 @@ (string-append "/" command " { /" fontname " " (ly:number->string scaling) " output-scale div selectfont } bind def\n")) - (define (standard-tex-font? x) - (or (equal? (substring x 0 2) "ms") - (equal? (substring x 0 2) "cm"))) - (define (font-load-command font) (let* ((specced-font-name (ly:font-name font)) (fontname (if specced-font-name @@ -63,10 +63,6 @@ (ops (ly:output-def-lookup paper 'output-scale)) (scaling (* ops magnification designsize))) - ;; Bluesky pfbs have UPCASE names (sigh.) - ;; FIXME - don't support Bluesky? - (if (standard-tex-font? fontname) - (set! fontname (string-upcase fontname))) (if (equal? fontname "unknown") (display (list font fontname))) (define-font plain fontname scaling))) @@ -165,13 +161,13 @@ (ly:output-def-lookup paper 'output-scale)) (ly:bp 1))) (landscape? (eq? (ly:output-def-lookup paper 'landscape) #t))) - (format "%%DocumentMedia: ~a ~$ ~$ ~a ~a ~a\n" - (ly:output-def-lookup paper 'papersizename) - (if landscape? h w) - (if landscape? w h) - 80 ;; weight - "()" ;; color - "()" ;; type + (ly:format "%%DocumentMedia: ~a ~2f ~2f ~a ~a ~a\n" + (ly:output-def-lookup paper 'papersizename) + (if landscape? h w) + (if landscape? w h) + 80 ;; weight + "()" ;; color + "()" ;; type ))) @@ -252,12 +248,14 @@ (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 (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)) @@ -270,7 +268,10 @@ (if (mac-font? bare-file-name) (handle-mac-font name bare-file-name) (cond - ((string-match "^([eE]mmentaler|[Aa]ybabtu)" file-name) + ((or (string-startswith file-name "Emmentaler") + (string-startswith file-name "emmentaler") + (string-startswith file-name "aybabtu") + (string-startswith file-name "Aybabtu")) (ps-load-file (ly:find-file (format "~a.otf" file-name)))) ((string? bare-file-name) @@ -337,13 +338,13 @@ ((downcase-file-name (string-downcase file-name))) (cond - ((and file-name (string-match "\\.pfa" downcase-file-name)) + ((and file-name (string-endswith downcase-file-name ".pfa")) (embed-document file-name)) - ((and file-name (string-match "\\.pfb" downcase-file-name)) + ((and file-name (string-endswith downcase-file-name ".pfb")) (ly:pfb->pfa file-name)) - ((and file-name (string-match "\\.ttf" downcase-file-name)) + ((and file-name (string-endswith downcase-file-name ".ttf")) (ly:ttf->pfa file-name)) - ((and file-name (string-match "\\.otf" downcase-file-name)) + ((and file-name (string-endswith downcase-file-name ".otf")) (ps-embed-cff (ly:otf->cff file-name) name 0)) (else (ly:warning (_ "do not know how to embed ~S=~S") name file-name) @@ -354,7 +355,7 @@ (eq? PLATFORM 'darwin) bare-file-name (or - (string-match "\\.dfont" bare-file-name) + (string-endswith bare-file-name ".dfont") (= (stat:size (stat bare-file-name)) 0)))) (define (load-font font-name-filename) @@ -417,6 +418,11 @@ pfas)) (display "%%BeginProlog\n" port) + + (format port + "/lilypond-datadir where {pop} {userdict /lilypond-datadir (~a) put } ifelse" + (ly:get-option 'datadir)) + (if load-fonts? (for-each (lambda (f) @@ -431,9 +437,6 @@ (display (procset "music-drawing-routines.ps") port) (display (procset "lilyponddefs.ps") port) - (if (not (ly:get-option 'point-and-click)) - (display "/mark_URI { pop pop pop pop pop } bind def\n" port)) - (display "%%EndProlog\n" port) (display "%%BeginSetup\ninit-lilypond-parameters\n%%EndSetup\n\n" port)) @@ -445,7 +448,7 @@ ;; content-mangling is always bad. ;; MINGW hack: need to have "b"inary for embedding CFFs (open-file filename "wb") - "ps")) + 'ps)) (paper (ly:paper-book-paper book)) (systems (ly:paper-book-systems book)) (page-stencils (map page-stencil (ly:paper-book-pages book))) @@ -537,7 +540,7 @@ ;; 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)) @@ -601,7 +604,7 @@ )) -(define (clip-system-EPSes basename paper-book) +(define-public (clip-system-EPSes basename paper-book) (define do-pdf (member "pdf" (ly:output-formats))) (define (clip-score-systems basename systems) @@ -761,7 +764,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 @@ -769,5 +772,4 @@ to only remove anything before %% **************************************************************** %% Start cut-&-pastable-section %% **************************************************************** - ")))