From 15551c56a17c10f2e1eae0766ddc87a62da119a8 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 25 Mar 2004 23:24:45 +0000 Subject: [PATCH] *** empty log message *** --- ChangeLog | 9 ++ Documentation/topdocs/NEWS.texi | 16 +-- Documentation/user/changing-defaults.itely | 5 + Documentation/user/introduction.itely | 23 +-- Documentation/user/preface.itely | 12 ++ input/regression/spacing-ragged-last.ly | 18 +++ lily/duration.cc | 18 ++- lily/engraver.cc | 4 - lily/font-metric.cc | 1 - lily/font-select.cc | 6 +- lily/gourlay-breaking.cc | 15 +- lily/grob-scheme.cc | 4 +- lily/horizontal-bracket.cc | 2 - lily/mark-engraver.cc | 4 - lily/moment.cc | 22 ++- lily/music-iterator.cc | 2 +- lily/rest-collision.cc | 3 - lily/slur.cc | 2 +- lily/stem-tremolo.cc | 4 - lily/tie-engraver.cc | 2 - ly/declarations-init.ly | 1 + make/mutopia-rules.make | 2 +- scm/font.scm | 158 +++++++++++---------- 23 files changed, 205 insertions(+), 128 deletions(-) create mode 100644 input/regression/spacing-ragged-last.ly diff --git a/ChangeLog b/ChangeLog index 04e9213e35..361b070937 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2004-03-25 Han-Wen Nienhuys + * lily/duration.cc (LY_DEFINE): dotcount argument is now optional. + + * input/regression/spacing-ragged-last.ly: new file. + + * lily/gourlay-breaking.cc (do_solve): add raggedlast support for + spacing. + + * scm/font.scm: rewrite using GOOPS. + * lily/context-def.cc (filter_engravers): derefence pointer. * lily/lily-guile.cc (type_check_assignment): use diff --git a/Documentation/topdocs/NEWS.texi b/Documentation/topdocs/NEWS.texi index bf4ac15419..9c45fff780 100644 --- a/Documentation/topdocs/NEWS.texi +++ b/Documentation/topdocs/NEWS.texi @@ -134,13 +134,10 @@ It is shorter, cleaner and faster. The special construct @code{mbinclude} has been removed, plain @code{@@include} or @code{\input} can be used now. -@ignore -It now supports -running convert-ly on the lilypond snippets like so: +It now supports running convert-ly on the lilypond snippets, @example lilypond-book --filter='convert-ly --from=2.0.0' my-book.tely @end example -@end ignore @item The @code{LyricsVoice} context has been removed. Lyrics should only be constructed in @code{Lyrics}. @@ -168,7 +165,7 @@ performed in a @code{DrumStaff} context: result, the syntax has been simplified as well: @example - \autochange @var{the music} + \autochange @var{the-music} @end example @item The ergonomic syntax of @code{\markup} now has an equivalent in @@ -250,7 +247,10 @@ Both have the same effect on the global layout of a piece. Similarly, the paper size may be changed as follows @example - #(set-paper-size "a4") + #(set-default-paper-size "a4") + \paper @{ + #(set-paper-size "a4") + @} @end example @@ -308,11 +308,11 @@ expression. For example, @end example @item Features of spanner contexts, like @code{Staff}, can now be changed - using @code{\property}, eg. + using @code{\set}, eg. @example \new Staff @{ - \property Staff.StaffSymbol \set #'line-count = #4 + \override Staff.StaffSymbol #'line-count = #4 c'4 @} @end example diff --git a/Documentation/user/changing-defaults.itely b/Documentation/user/changing-defaults.itely index 0ec0a80c88..1e3a0575c2 100644 --- a/Documentation/user/changing-defaults.itely +++ b/Documentation/user/changing-defaults.itely @@ -1929,6 +1929,11 @@ spacing is. @cindex page layout @cindex vertical spacing +The option @code{raggedlast} is similar to @code{raggedright}, but +only affects the last line of the piece. No restrictions are put on +that line. The result is similar to formatting paragraphs. In a +paragraph, the last line simply takes its natural length. + The page layout process happens outside the LilyPond formatting engine: variables controlling page layout are passed to the output, and are further interpreted by @code{lilypond} wrapper program. It diff --git a/Documentation/user/introduction.itely b/Documentation/user/introduction.itely index ca85187c68..786a44ece0 100644 --- a/Documentation/user/introduction.itely +++ b/Documentation/user/introduction.itely @@ -1,10 +1,22 @@ @c -*-texinfo-*- - @node Introduction @chapter Introduction -[TODO: should have introduction of introduction] +This manual + + +@menu +* Automated engraving:: +* What symbols to engrave?:: +* Music representation:: +* Example applications:: +* About this manual:: +@end menu + + +@node Engraving +@section Engraving The art of music typography is called @emph{(plate) engraving}. The term derives from the traditional process of music printing. Only a @@ -160,13 +172,6 @@ see and love to play from. -@menu -* Automated engraving:: -* What symbols to engrave?:: -* Music representation:: -* Example applications:: -* About this manual:: -@end menu @node Automated engraving @section Automated engraving diff --git a/Documentation/user/preface.itely b/Documentation/user/preface.itely index 6ba59df78b..8748e65b59 100644 --- a/Documentation/user/preface.itely +++ b/Documentation/user/preface.itely @@ -11,6 +11,18 @@ @end menu +@node Preface to version 2.2 +@unnumberedsec Preface to version 2.2 + +During the 2.1 development cycle, the cleanup of the existing features +has continued unabated. Major areas of change are: orchestral +notation, lyrics formatting and font size handling. + +Han-Wen and Jan + +Utrecht/Eindhoven, The Netherlands, March 2003. + + @node Preface to version 2.0 @unnumberedsec Preface to version 2.0 diff --git a/input/regression/spacing-ragged-last.ly b/input/regression/spacing-ragged-last.ly new file mode 100644 index 0000000000..8493e66ae3 --- /dev/null +++ b/input/regression/spacing-ragged-last.ly @@ -0,0 +1,18 @@ +\version "2.1.34" + +\header { + + texidoc = "If @code{raggedlast} is set, the systems are broken + similar to paragraph formatting in text: the last line is + justified. " + + } + + +\score { + \notes \relative c'' \new Staff { \repeat unfold 20 { c1 } } + \paper{ + raggedlast = ##t + } +} + diff --git a/lily/duration.cc b/lily/duration.cc index a85bf11093..39fe26ca39 100644 --- a/lily/duration.cc +++ b/lily/duration.cc @@ -145,11 +145,11 @@ LY_DEFINE (duration_less, "ly:durationset_property ("cause", cause); diff --git a/lily/font-metric.cc b/lily/font-metric.cc index e125775587..fb041fe3da 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -178,7 +178,6 @@ LY_DEFINE (ly_find_glyph_by_name, "ly:find-glyph-by-name", 2 , 0, 0, /* TODO: make optional argument for default if not found. - */ return m.smobbed_copy (); } diff --git a/lily/font-select.cc b/lily/font-select.cc index ae78641b11..26d3cad0d3 100644 --- a/lily/font-select.cc +++ b/lily/font-select.cc @@ -117,10 +117,10 @@ select_font (Paper_def *paper, SCM chain) return paper->find_font (name, rmag); } - else if (gh_pair_p (name)) // (DEFAULT . FONT-VEC) pair + else if (scm_instance_p (name)) { - SCM vec = gh_cdr (name); - SCM base_size = gh_car (name); + SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size")); + SCM vec = scm_slot_ref (name, ly_symbol2scm ("size-vector")); SCM font_size = ly_assoc_chain (ly_symbol2scm ("font-size"), chain); Real req = 0.0; diff --git a/lily/gourlay-breaking.cc b/lily/gourlay-breaking.cc index 2b935037dd..93192d1a28 100644 --- a/lily/gourlay-breaking.cc +++ b/lily/gourlay-breaking.cc @@ -79,6 +79,9 @@ Gourlay_breaking::do_solve () const Break_node first_node ; optimal_paths.push (first_node); + bool ragged_right = to_boolean (pscore_->paper_->get_scmvar ("raggedright")); + bool ragged_last = to_boolean (pscore_->paper_->get_scmvar ("raggedlast")); + Real worst_force = 0.0; for (int break_idx = 1; break_idx< breaks.size (); break_idx++) { @@ -92,13 +95,11 @@ Gourlay_breaking::do_solve () const Real minimal_demerits = infinity_f; - bool ragged = to_boolean (pscore_->paper_->get_scmvar ("raggedright")); - for (int start_idx = break_idx; start_idx--;) { Link_array line = all.slice (breaks[start_idx], breaks[break_idx]+1); - line[0] = dynamic_cast (line[0]) ->find_prebroken_piece (RIGHT); + line[0] = dynamic_cast (line[0])->find_prebroken_piece (RIGHT); line.top () = dynamic_cast (line.top ())->find_prebroken_piece (LEFT); Column_x_positions cp; @@ -107,9 +108,17 @@ Gourlay_breaking::do_solve () const Interval line_dims = pscore_->paper_->line_dimensions_int (optimal_paths[start_idx].line_); Simple_spacer * sp = generate_spacing_problem (line, line_dims); + bool last_line = break_idx == breaks.size ()-1; + bool ragged = ragged_right + || (last_line && ragged_last); + sp->solve (&cp, ragged); + delete sp; + if (ragged && last_line) + cp.force_ = 0.0; + if (fabs (cp.force_) > worst_force) worst_force = fabs (cp.force_); diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index 587a692c38..77cc5d914e 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -147,8 +147,8 @@ LY_DEFINE (get_broken_into, "ly:spanner-broken-into", SCM_ASSERT_TYPE (me, spanner, SCM_ARG1, __FUNCTION__, "spanner"); SCM s = SCM_EOL; - for (int i = me->broken_intos_.size (); i; i--) - s = gh_cons (me->broken_intos_[i-1]->self_scm (), s); + for (int i = me->broken_intos_.size (); i--;) + s = gh_cons (me->broken_intos_[i]->self_scm (), s); return s; } diff --git a/lily/horizontal-bracket.cc b/lily/horizontal-bracket.cc index fdbdd05879..4961721496 100644 --- a/lily/horizontal-bracket.cc +++ b/lily/horizontal-bracket.cc @@ -27,9 +27,7 @@ struct Horizontal_bracket This doesn't look very elegant: should support winged edges. Support texts on the brackets? - */ - MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1); SCM diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc index 3dc5cda209..ade82a0c23 100644 --- a/lily/mark-engraver.cc +++ b/lily/mark-engraver.cc @@ -96,11 +96,7 @@ Mark_engraver::try_music (Music* r) /* - TODO: make the increment function in Scheme. - - - TODO: junk the number type for rehearsalMark */ void Mark_engraver::process_music () diff --git a/lily/moment.cc b/lily/moment.cc index 57fc8b6535..a180bedd6c 100644 --- a/lily/moment.cc +++ b/lily/moment.cc @@ -41,8 +41,9 @@ Moment::print_smob (SCM s, SCM port, scm_print_state *) /* TODO: add optional factor argument. */ -LY_DEFINE (make_moment,"ly:make-moment", 2,0,0, (SCM n, SCM d), - "Create the rational number with main timing @var{n}/@var{d}. \n" +LY_DEFINE (make_moment,"ly:make-moment", 2,2,0, (SCM n, SCM d, SCM gn, SCM gd), + "Create the rational number with main timing @var{n}/@var{d}, " + "and optional grace timin @var{gn}/@var{gd}.\n" "\n" "\n" "Moment is a point in musical time. It is consists of a pair of\n" @@ -54,7 +55,22 @@ LY_DEFINE (make_moment,"ly:make-moment", 2,0,0, (SCM n, SCM d), SCM_ASSERT_TYPE (SCM_INUMP (n), n, SCM_ARG1, __FUNCTION__, "integer"); SCM_ASSERT_TYPE (SCM_INUMP (d), d, SCM_ARG2, __FUNCTION__, "integer"); - return Moment (Rational (gh_scm2int (n), gh_scm2int (d))).smobbed_copy (); + int grace_num = 0; + if (gn != SCM_UNDEFINED) + { + SCM_ASSERT_TYPE (SCM_INUMP (gn), gn, SCM_ARG3, __FUNCTION__, "integer"); + grace_num = gh_scm2int (gn); + } + + int grace_den = 1; + if (gd != SCM_UNDEFINED) + { + SCM_ASSERT_TYPE (SCM_INUMP (gd), gd, SCM_ARG4, __FUNCTION__, "integer"); + grace_den = gh_scm2int (gd); + } + + return Moment (Rational (gh_scm2int (n), gh_scm2int (d)), + Rational (grace_num, grace_den)).smobbed_copy (); } LY_DEFINE (add_moment,"ly:add-moment", 2,0,0, (SCM a, SCM b), diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index 43e28e3ebd..14bbebebd9 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -150,7 +150,7 @@ Music_iterator::get_iterator (Music *m) const } /* - TODO: rename to prevent confusion between Translator::try_music and + TODO: rename to prevent confusion between Context::try_music and Iterator::try_music */ diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 9bdfad3cc9..c815db634e 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -75,11 +75,8 @@ head_characteristic (Grob * col) } /* - TODO: fixme, fucks up if called twice on the same set of rests. - TODO: look at horizontal-shift to determine ordering between rests for more than two voices. - */ SCM diff --git a/lily/slur.cc b/lily/slur.cc index d5ffc85aad..5a34e272f4 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -1,5 +1,5 @@ /* - slur.cc -- implement Slur + slur.cc -- implement Slur source file of the GNU LilyPond music typesetter diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index 4eae91b91f..abee9361b6 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -141,10 +141,6 @@ Stem_tremolo::print (SCM grob) // ugh, rather calc from Stem_tremolo_req int beam_count = (beam) ? (Stem::beam_multiplicity (stem).length () + 1): 0; - /* - TODO. - */ - Real beamthickness = 0.0; SCM sbt = (beam) ? beam->get_property ("thickness") : SCM_EOL ; diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index b176a34092..a1df498c98 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -27,8 +27,6 @@ TODO: Remove the dependency on musical info. We should tie on the basis of position and duration-log of the heads (not of the events). - - TODO: support sparseTies. */ class Tie_engraver : public Engraver { diff --git a/ly/declarations-init.ly b/ly/declarations-init.ly index c2b185f66e..00ae0f46f6 100644 --- a/ly/declarations-init.ly +++ b/ly/declarations-init.ly @@ -52,6 +52,7 @@ melismaEnd = #(make-span-event 'ManualMelismaEvent STOP) cm = #(* 10 mm) raggedright = ##f + raggedlast = ##f packed = ##f #(define $is-paper #t) diff --git a/make/mutopia-rules.make b/make/mutopia-rules.make index af73902b97..b9452646f8 100644 --- a/make/mutopia-rules.make +++ b/make/mutopia-rules.make @@ -20,7 +20,7 @@ $(outdir)/%.ly: %.abc $(PYTHON) $(ABC2LY) --strict -o $@ $< $(outdir)/%.dvi: $(outdir)/%.ly - $(PYTHON) $(LY2DVI) --output=$@ --dependencies $< + $(PYTHON) $(LY2DVI) --output=$@ --dependencies $< # don't junk intermediate .dvi files. They're easier to view than # .ps or .png diff --git a/scm/font.scm b/scm/font.scm index 15c48da40e..ec561cc5ab 100644 --- a/scm/font.scm +++ b/scm/font.scm @@ -7,40 +7,74 @@ ;; ;; should dump tree to .texi as internal documentation ;; -;; * should extract design sizes from fonts. +;; * should extract design sizes from fonts: fonts should +;; be read off the disk, on demand, something like: +;; +;; cmr -> ((font-load "cmr6") (font-load "cmr8") .. ) +;; + +(define-class + () + ) -(define font-tree-record - (make-record-type - "font-tree-node" - '(qualifier default children))) +(define-class () + (default-size #:init-keyword #:default-size) + (size-vector #:init-keyword #:size-vector)) -(define-public font-tree-node? - (record-predicate font-tree-record)) -(define-public font-tree-default - (record-accessor font-tree-record 'default)) -(define-public font-tree-qualifier - (record-accessor font-tree-record 'qualifier)) -(define-public font-tree-children - (record-accessor font-tree-record 'children)) +(define-class () + (qualifier #:init-keyword #:qualifier #:accessor font-qualifier) + (default #:init-keyword #:default #:accessor font-default) + (children #:init-keyword #:children #:accessor font-children)) +(define (make-font-tree-leaf size size-font-vector) + (make #:default-size size #:size-vector size-font-vector)) (define (make-font-tree-node qualifier default) - ((record-constructor font-tree-record) - qualifier - default - (make-hash-table 11))) ;ugh. hardcoded. + (make + #:qualifier qualifier + #:default default + #:children (make-hash-table 11))) + +(define-method (display (leaf ) port) + (map (lambda (x) (display x port)) + (list + "Font-size-family: \n" + (slot-ref leaf 'default-size) + (slot-ref leaf 'size-vector) ))) + +(define-method (display (node ) port) + + (map + (lambda (x) + (display x port)) + + (list + "Font_node { \nqual: " + (font-qualifier node) + "(def: " + (font-default node) + ") {\n")) + (for-each + (lambda (x) + (display "\n") + (display (car x) port) + (display "=" port) + (display (cdr x) port)) + (hash-table->alist (font-children node))) + (display "} } \n")) + + (define default-qualifier-order '(font-encoding font-family font-shape font-series)) - -(define-public (add-font node fprops size-family) +(define-method (add-font (node ) fprops size-family) (define (assoc-delete key alist) (assoc-remove! (list-copy alist) key)) (define (make-node fprops size-family) (if (null? fprops) - size-family + (make-font-tree-leaf (car size-family) (cdr size-family)) (let* ((qual (next-qualifier default-qualifier-order fprops))) (make-font-tree-node qual @@ -58,72 +92,50 @@ (next-qualifier (cdr order) props)) ))) - (if (font-tree-node? node) - (let* - ((q (font-tree-qualifier node)) - (d (font-tree-default node)) - (v (assoc-get q fprops d)) - (new-fprops (assoc-delete q fprops)) - (child (hashq-ref (font-tree-children node) - v #f))) + (let* + ((q (font-qualifier node)) + (d (font-default node)) + (v (assoc-get q fprops d)) + (new-fprops (assoc-delete q fprops)) + (child (hashq-ref (slot-ref node 'children) + v #f))) - (if (not child) - (begin - (set! child (make-node new-fprops size-family)) - (hashq-set! (font-tree-children node) v child))) + (if (not child) + (begin + (set! child (make-node new-fprops size-family)) + (hashq-set! (slot-ref node 'children) v child))) + (if (pair? new-fprops) + (add-font child new-fprops size-family)))) - (add-font child new-fprops size-family)) - (if (not (equal? size-family node)) - (throw 'invalid-font props size-family))) - ) -(define-public (display-font-node node . rest) - (let* - ((port (if (pair? rest) (car rest) (current-output-port))) - ) - (cond - ((font-tree-node? node) - (map - (lambda (x) - (display x port)) - - (list - "Font_node { \nqual: " - (font-tree-qualifier node) - "(def: " - (font-tree-default node) - ") {\n")) - (for-each - (lambda (x) - (display "\n") - (display (car x) port) - (display "=" port) - (display-font-node (cdr x) port)) - (hash-table->alist (font-tree-children node))) - (display "} } \n")) +(define-method (add-font (node ) fprops size-family) + (throw "must add to node, not leaf")) - (else - (display node port)))) - ) -(define-public (lookup-font node alist-chain) - (cond - ((font-tree-node? node) - (let* - ((qual (font-tree-qualifier node)) - (def (font-tree-default node)) +(define-method (g-lookup-font (node ) alist-chain) + (let* + ((qual (font-qualifier node)) + (def (font-default node)) (val (chain-assoc-get qual alist-chain def)) (desired-font (lookup-font - (hashq-ref (font-tree-children node) + (hashq-ref (font-children node) val) alist-chain)) + + (default (hashq-ref (font-children node) def)) (font (if desired-font desired-font - (lookup-font (hashq-ref (font-tree-children node) + (g-lookup-font (hashq-ref (font-children node) def) alist-chain))) ) font)) - (else node))) + +(define-method (g-lookup-font (node ) alist-chain) + node) + +(define (lookup-font node alist-chain) + (g-lookup-font node alist-chain)) + (define-public (make-font-tree factor) (let* @@ -229,5 +241,7 @@ )) n)) +; (display (make-font-tree 1.0)) + (define-public (magstep x) (exp (* (/ x 6) (log 2)))) -- 2.39.2