LEFT | RIGHT |
1 ;;;; This file is part of LilyPond, the GNU music typesetter. | 1 ;;;; This file is part of LilyPond, the GNU music typesetter. |
2 ;;;; | 2 ;;;; |
3 ;;;; Copyright (C) 2004--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> | 3 ;;;; Copyright (C) 2004--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> |
4 ;;;; | 4 ;;;; |
5 ;;;; LilyPond is free software: you can redistribute it and/or modify | 5 ;;;; LilyPond is free software: you can redistribute it and/or modify |
6 ;;;; it under the terms of the GNU General Public License as published by | 6 ;;;; it under the terms of the GNU General Public License as published by |
7 ;;;; the Free Software Foundation, either version 3 of the License, or | 7 ;;;; the Free Software Foundation, either version 3 of the License, or |
8 ;;;; (at your option) any later version. | 8 ;;;; (at your option) any later version. |
9 ;;;; | 9 ;;;; |
10 ;;;; LilyPond is distributed in the hope that it will be useful, | 10 ;;;; LilyPond is distributed in the hope that it will be useful, |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 (display "%%EndFont\n" port)) | 392 (display "%%EndFont\n" port)) |
393 (load-fonts paper))) | 393 (load-fonts paper))) |
394 (display (setup-variables paper) port) | 394 (display (setup-variables paper) port) |
395 | 395 |
396 ;; adobe note 5002: should initialize variables before loading routines. | 396 ;; adobe note 5002: should initialize variables before loading routines. |
397 (display (procset "music-drawing-routines.ps") port) | 397 (display (procset "music-drawing-routines.ps") port) |
398 (display (procset "lilyponddefs.ps") port) | 398 (display (procset "lilyponddefs.ps") port) |
399 (display "%%EndProlog\n" port) | 399 (display "%%EndProlog\n" port) |
400 (display "%%BeginSetup\ninit-lilypond-parameters\n%%EndSetup\n\n" port)) | 400 (display "%%BeginSetup\ninit-lilypond-parameters\n%%EndSetup\n\n" port)) |
401 | 401 |
| 402 (define (ps-quote str) |
| 403 (fold |
| 404 (lambda (replacement-list result) |
| 405 (string-join |
| 406 (string-split |
| 407 result |
| 408 (car replacement-list)) |
| 409 (cadr replacement-list))) |
| 410 str |
| 411 '((#\\ "\\\\") (#\( "\\(") (#\) "\\)")))) |
| 412 |
402 ;;; Create DOCINFO pdfmark containing metadata | 413 ;;; Create DOCINFO pdfmark containing metadata |
403 ;;; header fields with pdf prefix override those without the prefix | 414 ;;; header fields with pdf prefix override those without the prefix |
404 (define (handle-metadata header port) | 415 (define (handle-metadata header port) |
405 (define (metadata-encode val) | 416 (define (metadata-encode val) |
406 ;; First, escape all parentheses and backslashes (TODO) | 417 ;; First, call ly:encode-string-for-pdf to encode the string (latin1 or |
407 ;; Then call ly:encode-string-for-pdf to encode the string if neccessary | 418 ;; utf-16be), then escape all parentheses and backslashes |
408 (ly:encode-string-for-pdf val)) | 419 (ps-quote (ly:encode-string-for-pdf val))) |
409 (define (metadata-lookup-output overridevar fallbackvar field) | 420 (define (metadata-lookup-output overridevar fallbackvar field) |
410 (let* ((overrideval (ly:modules-lookup (list header) overridevar)) | 421 (let* ((overrideval (ly:modules-lookup (list header) overridevar)) |
411 (fallbackval (ly:modules-lookup (list header) fallbackvar)) | 422 (fallbackval (ly:modules-lookup (list header) fallbackvar)) |
412 (val (if overrideval overrideval fallbackval))) | 423 (val (if overrideval overrideval fallbackval))) |
413 (if val | 424 (if val |
414 (format port "/~a (~a)\n" field (metadata-encode (markup->string val))
)))) | 425 (format port "/~a (~a)\n" field (metadata-encode (markup->string val))
)))) |
415 (display "[ " port) | 426 (display "[ " port) |
416 (metadata-lookup-output 'pdfcomposer 'composer "Author") | 427 (metadata-lookup-output 'pdfcomposer 'composer "Author") |
417 (format port "/Creator (LilyPond ~a)\n" (lilypond-version)) | 428 (format port "/Creator (LilyPond ~a)\n" (lilypond-version)) |
418 (metadata-lookup-output 'pdftitle 'title "Title") | 429 (metadata-lookup-output 'pdftitle 'title "Title") |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 | 686 |
676 lilypond -dbackend=eps FILE | 687 lilypond -dbackend=eps FILE |
677 | 688 |
678 If have cut & pasted a lilypond fragment from a webpage, be sure | 689 If have cut & pasted a lilypond fragment from a webpage, be sure |
679 to only remove anything before | 690 to only remove anything before |
680 | 691 |
681 %% **************************************************************** | 692 %% **************************************************************** |
682 %% Start cut-&-pastable-section | 693 %% Start cut-&-pastable-section |
683 %% **************************************************************** | 694 %% **************************************************************** |
684 "))) | 695 "))) |
LEFT | RIGHT |