--- /dev/null
+\version "2.1.28"
+%{
+ \markup in titles is WIP, only available in direct PostScript output
+ process and view this file doing:
+
+ lilypond-bin -fps title-markup.ly
+ export GS_LIB=$(pwd)/mf/out:/usr/share/texmf/fonts/type1/bluesky/cm
+ gs title-markup.ps
+
+
+FIXME: use conditionals in \makeTitle:
+
+#(define (my-ly-version)
+ (list-head (ly:version) 3))
+
+#(if (not (defined? 'pieceTagLine))
+ (define pieceTagLine (string-append "Jeremie " (numbers->string (my-ly-version)) " was here")))
+
+\header{
+tagline = \pieceTagLine
+texidoc = "
+
+%}
+
+\header {
+ texidoc = "Make titles using markup (WIP)."
+
+
+ % FIXME
+ fonts = #'((font-family . roman)
+ (word-space . 1)
+ (baseline-skip . 2)
+ (font-series . medium)
+ (font-style . roman)
+ (font-shape . upright)
+ (font-size . 0))
+
+ title = "Title String"
+ subtitle = "and the subtitle"
+ poet = "poetstring"
+ composer = "compozeur"
+ instrument = "instrum"
+ piece = "stukkie"
+
+ makeTitle = \markup {
+ \column <
+ { \large \bold \title } " " { \large \bold \subtitle }
+ { " " }
+ % FIXME: 60: linewidth / flushleft/flushright (hfill?))
+ { { \smaller \upright \instrument } \hspace #60 \upright \composer }
+ { { \smaller \caps \piece } \hspace #60 \upright \poet }
+ >
+ }
+}
+
+\score {
+ \context Staff \notes \relative c' {
+ c-\markup { \center < \roman \caps "foe" > }
+ }
+}
->output_scheme (scm_list_2 (ly_symbol2scm ("define-fonts"),
ly_quote_scm (paper_->font_descriptions ())));
-#if 0
- // huh? does not work, stack overflow
outputter_->output_scheme (scm_list_2 (ly_symbol2scm ("make-title"),
- outputter_->file_));
-#else
-#if 0
- // uhuh?? does not work, stack overflow
- outputter_->output_scheme (scm_list_2 (ly_symbol2scm ("set-port"),
- outputter_->file_));
-#endif
- outputter_->output_scheme (scm_list_1 (ly_symbol2scm ("make-title")));
-#endif
-
+ ly_quote_scm (outputter_->file_)));
system_->output_lines ();
outputter_->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
;;;; (c) 1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
+;; TODO:
+;; * testbed for titles with markup
+;; * font size and designsize
+;; * FIXME: breaks when outputting strings with parentheses.
+
(debug-enable 'backtrace)
(lily))
-
-;;; Lily output interface --- cleanup and docme
-
-;; TODO: fucks up if outputting strings with parentheses.
+;;; Lily output interface, PostScript implementation --- cleanup and docme
;; Module entry
(define-public (ps-output-expression expr port)
(display (expression->string expr) port))
+
(define (expression->string expr)
(eval expr this-module))
;; alist containing fontname -> fontcommand assoc (both strings)
(define font-name-alist '())
+;; WIP -- stencils from markup? values of output-scopes
+(define header-stencil #f)
;; Interface functions
(define (beam width slope thick blot)
(font-series . medium)
(font-style . roman)
(font-shape . upright)
- (font-size . 0)))))
-
+ (font-size . 0))))
+ (stencils '())
+ (baseline-skip 2))
+
+ (define (output-scope-entry sym var)
+ (let ((val (variable-ref var))
+ (tex-key (symbol->string sym)))
+
+ (if (memq sym fields)
+ (header-to-file basename sym val))
+
+ (cond
+ ((eq? sym 'font)
+ BARF
+ (format (current-error-port) "PROPS:~S\n" val)
+ (set! props (cons val props))
+ "")
+
+ ;; define strings, for /make-lilypond-title to pick up
+ ((string? val) (ps-string-def "lilypond" sym val))
+
+ ;; generate stencil from markup
+ ((markup? val) (set! stencils
+ (append
+ stencils
+ (list
+ (interpret-markup paper props val))))
+ "")
+ ((number? val) (ps-number-def
+ "lilypond" sym (if (integer? val)
+ (number->string val)
+ (number->string
+ (exact->inexact val)))))
+ (else ""))))
+
(define (output-scope scope)
- (apply
- string-append
- (module-map
- (lambda (sym var)
- (let ((val (variable-ref var))
- (tex-key (symbol->string sym)))
-
- (if (memq sym fields)
- (header-to-file basename sym val))
-
- (cond
- ((eq? sym 'font)
- BARF
- (format (current-error-port) "PROPS:~S\n" val)
- (set! props (cons val props))
- "")
-
- ;; define strings, for /make-lilypond-title to pick up
- ((string? val) (ps-string-def "lilypond" sym val))
-
- ;; generate stencil from markup
- ((markup? val) (set! header-stencils
- (append header-stencils
- (list
- (ly:stencil-get-expr
- (interpret-markup paper props val)))))
-
- "")
- ((number? val) (ps-number-def
- "lilypond" sym (if (integer? val)
- (number->string val)
- (number->string
- (exact->inexact val)))))
- (else ""))))
- scope)))
+ (apply string-append (module-map output-scope-entry scope)))
- (string-append
- (apply string-append (map output-scope scopes)))))
+ (let ((s (string-append (apply string-append (map output-scope scopes)))))
+ (set! header-stencil (stack-lines DOWN 0 baseline-skip stencils))
+
+ ;; trigger font load
+ (ly:stencil-get-expr header-stencil)
+ s)))
(define (offset-add a b)
(cons (+ (car a) (car b))
(+ (cdr a) (cdr b))))
-(define header-stencils '())
-
-(define output-port (current-error-port))
-
-;; just calling this from paper-score gives Stack overflow.
-(define (set-port p)
- (set! output-port p)
- "")
-
-(define (make-title)
- (if (pair? header-stencils)
- (map (lambda (x) (output-stencil output-port x '(10 . -10)))
- header-stencils))
+(define (make-title port)
+ (if header-stencil
+ (let ((x-ext (ly:stencil-get-extent header-stencil Y))
+ (y-ext (ly:stencil-get-extent header-stencil X)))
+ (display (start-system (interval-length x-ext) (interval-length y-ext))
+ port)
+ (output-stencil port (ly:stencil-get-expr header-stencil) '(0 . 0))
+ (display (stop-system) port)))
"")
;; hmm, looks like recursing call is always last statement, does guile