From fd5f1d06eab36c296f9baa0fab71e43753d9a434 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 2 Mar 2004 10:42:40 +0000 Subject: [PATCH] * scm/output-ps.scm (make-title, output-scopes): Further development. * input/test/title-markup.ly: New file. * ps/lilyponddefs.ps: Disable PostScript titling. * lily/paper-score.cc (process): Qoute PORT argument to make-title. --- ChangeLog | 11 ++++ input/test/title-markup.ly | 60 +++++++++++++++++++ lily/paper-score.cc | 13 +---- ps/lilyponddefs.ps | 5 +- scm/output-ps.scm | 115 +++++++++++++++++++------------------ scm/output-tex.scm | 2 +- 6 files changed, 135 insertions(+), 71 deletions(-) create mode 100644 input/test/title-markup.ly diff --git a/ChangeLog b/ChangeLog index e76d28de15..32368fc300 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-03-02 Jan Nieuwenhuizen + + * scm/output-ps.scm (make-title, output-scopes): Further + development. + + * input/test/title-markup.ly: New file. + + * ps/lilyponddefs.ps: Disable PostScript titling. + + * lily/paper-score.cc (process): Qoute PORT argument to make-title. + 2004-03-01 Han-Wen Nienhuys * lily/arpeggio.cc (width_callback): remove padding. diff --git a/input/test/title-markup.ly b/input/test/title-markup.ly new file mode 100644 index 0000000000..65ae2dad74 --- /dev/null +++ b/input/test/title-markup.ly @@ -0,0 +1,60 @@ +\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" > } + } +} diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 8e24ecd5ec..4c2e2b68e8 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -115,19 +115,8 @@ Paper_score::process (String outname) ->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"))); diff --git a/ps/lilyponddefs.ps b/ps/lilyponddefs.ps index 6c903a5290..c11a7390f5 100644 --- a/ps/lilyponddefs.ps +++ b/ps/lilyponddefs.ps @@ -6,7 +6,7 @@ % /setgray { 1 add } bind def % To let gs load fonts from builddir, do: -% export GS_LIB=$(pwd)/mf/out: +% export GS_LIB=$(pwd)/mf/out:/usr/share/texmf/fonts/type1/bluesky/cm /staff-line-thickness lilypondpaperlinethickness def /staff-height lilypondpaperstaffheight def @@ -220,7 +220,8 @@ staff-height init-paper /line-x left-margin output-scale div def /line-y vsize top-margin sub def -make-lilypond-title +% FIXME: testing \markup titles +% make-lilypond-title % see if we're there... % 10 setlinewidth 0 0 moveto 400 800 lineto stroke diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 84cbe3fe86..9a578246a6 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -5,6 +5,11 @@ ;;;; (c) 1998--2004 Jan Nieuwenhuizen ;;;; Han-Wen Nienhuys +;; TODO: +;; * testbed for titles with markup +;; * font size and designsize +;; * FIXME: breaks when outputting strings with parentheses. + (debug-enable 'backtrace) @@ -17,15 +22,13 @@ (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)) @@ -34,6 +37,8 @@ ;; 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) @@ -364,65 +369,63 @@ (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 diff --git a/scm/output-tex.scm b/scm/output-tex.scm index 6661e4e61b..4698e8ee41 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -352,4 +352,4 @@ (define-public (tex-output-expression expr port) (display (eval expr this-module) port )) -(define (make-title) "") +(define (make-title port) "") -- 2.39.2