(ice-9 format)
(guile)
(srfi srfi-13)
+ (srfi srfi-1)
(lily))
-;; FIXME: rename
-;; what is bla supposed to do? It breaks the default output terribly:
-
-;; \def\lilypondpaperbla$\backslash${$\backslash$}{bla$\backslash${$\backslash$}}%
-;; \lyitem{089.5557}{-15.3109}{\hbox{\magfontUGQLomTVo{}bla$\backslash${$\backslash$}}}%
-;; --jcn
(define-public (sanitize-tex-string s)
(if (ly:get-option 'safe)
(regexp-substitute/global
#f "\\\\"
- (regexp-substitute/global #f "([{}])" "bla{}" 'pre "\\" 1 'post )
+ (regexp-substitute/global #f "([{}])" s 'pre "\\" 1 'post )
'pre "$\\backslash$" 'post)
s))
(string-append
"magfont"
(string-encode-integer
- (hashq (ly:font-filename font) 1000000))
+ (hashq (ly:font-file-name font) 1000000))
"m"
(string-encode-integer
(inexact->exact (round (* 1000 (ly:font-magnification font)))))))
(font-encoding (assoc-get 'output-name coding-alist)))
(string-append
"\\font\\lilypond" (tex-font-command font) "="
- (ly:font-filename font)
+ (ly:font-file-name font)
" scaled "
(ly:number->string (inexact->exact
(round (* 1000
"\n"
"\\def\\" (tex-font-command font) "{%\n"
;; UGH. Should be handled via alist.
- (if (equal? "Extended-TeX-Font-Encoding---Latin" font-encoding)
+ (if (or (equal? "Extended-TeX-Font-Encoding---Latin" font-encoding)
+ (not font-encoding))
" \\lilypondfontencoding{T1}"
" ")
"\\lilypond" (tex-font-command font)
"lilypondpaper" 'linewidth
(ly:number->string (* scale (ly:output-def-lookup paper 'linewidth))))
"\\def\\lilyponddocumentclassoptions{"
- texpaper
+ (sanitize-tex-string texpaper)
(if landscape? ",landscape" "")
"}%\n"
(tex-string-def
(define-public (output-preview-framework
outputter book scopes fields basename )
(let* ((paper (ly:paper-book-paper book))
- (lines (ly:paper-book-systems book)))
+ (lines (ly:paper-book-systems book))
+ (first-notes-index (list-index
+ (lambda (s) (not (ly:paper-system-title? s)))
+ lines)))
+
(for-each
(lambda (x)
(ly:outputter-dump-string outputter x))
(list
+
;;FIXME
(header paper (length lines) #f)
"\\def\\lilypondclassic{1}%\n"
(define-fonts paper)
(header-end)))
- (dump-line outputter (car lines) #t)
+ (for-each
+ (lambda (l)
+ (dump-line outputter l (not (ly:paper-system-title? l))))
+ (take lines (1+ first-notes-index)))
(ly:outputter-dump-string outputter "\\lilypondend\n")))
(define-public (convert-to-pdf book name)
(define-public (convert-to-ps book name)
(let* ((paper (ly:paper-book-paper book))
(preview? (string-contains name ".preview"))
+
(papersizename (ly:output-def-lookup paper 'papersizename))
(landscape? (eq? #t (ly:output-def-lookup paper 'landscape)))
(base (basename name ".tex"))
(cmd (string-append "dvips "
(if preview?
" -E "
- (string-append " -t " papersizename))
+ (string-append
+ " -t "
+
+ ;; careful: papersizename is user-set.
+ (sanitize-command-option papersizename)))
+
(if landscape?
" -t landscape "
" ")
" -u+ec-mftrace.map -u+lilypond.map -Ppdf "
- base
-
- (if (ly:get-option 'verbose)
- " "
- " 2>&1 1>& /dev/null "))))
-
- (if (ly:get-option 'verbose)
- (begin
- (newline (current-error-port))
- (format (current-error-port) (_ "Invoking ~S") cmd)
- (newline (current-error-port)))
+ base)))
+
+ (let ((ps-name (string-append base ".ps")))
+ (if (access? ps-name W_OK)
+ (delete-file ps-name)))
+ (if (not (ly:get-option 'verbose))
(begin
(format (current-error-port) (_ "Converting to `~a.ps'...") base)
(newline (current-error-port))))
'pre "" 'post)))
(base (basename name ".tex"))
(cmd (string-append
- "latex \\\\nonstopmode \\\\input " name
- (if (ly:get-option 'verbose)
- " "
- " 2>&1 1>& /dev/null "))))
+ "latex \\\\nonstopmode \\\\input " name)))
(setenv "extra_mem_top" (number->string (max curr-extra-mem 1024000)))
- (if (ly:get-option 'verbose)
- (begin
- (newline (current-error-port))
- (format (current-error-port) (_ "Invoking ~S") cmd)
- (newline (current-error-port)))
+ (let ((dvi-name (string-append base ".dvi")))
+ (if (access? dvi-name W_OK)
+ (delete-file dvi-name)))
+ (if (not (ly:get-option 'verbose))
(begin
(format (current-error-port) (_ "Converting to `~a.dvi'...") base)
(newline (current-error-port))))