2004-03-25 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * 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
@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}.
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
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
@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
@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
@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
-@menu
-* Automated engraving::
-* What symbols to engrave?::
-* Music representation::
-* Example applications::
-* About this manual::
-@end menu
@node Automated engraving
@section Automated engraving
@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
--- /dev/null
+\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
+ }
+}
+
}
LY_DEFINE (make_duration, "ly:make-duration",
- 2, 2, 0, (SCM length, SCM dotcount, SCM num, SCM den),
+ 1, 3, 0, (SCM length, SCM dotcount, SCM num, SCM den),
"@var{length} is the negative logarithm (base 2) of the duration:\n"
"1 is a half note, 2 is a quarter note, 3 is an eighth\n"
"note, etc. The number of dots after the note is given by\n"
- "@var{dotcount}.\n"
+ "the optional argument @var{dotcount}.\n"
"\n"
"The duration factor is optionally given by @var{num}\n"
"and @var{den}.\n\n"
"(whole, half, quarter, etc.) and a number of augmentation\n"
"dots. \n")
{
- SCM_ASSERT_TYPE (gh_number_p (length), length, SCM_ARG1, __FUNCTION__, "integer");
- SCM_ASSERT_TYPE (gh_number_p (dotcount), dotcount, SCM_ARG2, __FUNCTION__, "integer");
+ SCM_ASSERT_TYPE (scm_integer_p (length) == SCM_BOOL_T,
+ length, SCM_ARG1, __FUNCTION__, "integer");
+
+ int dots = 0;
+ if (dotcount != SCM_UNDEFINED)
+ {
+ SCM_ASSERT_TYPE (scm_integer_p (dotcount) == SCM_BOOL_T,
+ dotcount, SCM_ARG2, __FUNCTION__, "integer");
+ dots = gh_scm2int (dotcount);
+ }
bool compress = false;
if (num != SCM_UNDEFINED)
else
den = gh_int2scm (1);
- Duration p (gh_scm2int (length), gh_scm2int (dotcount));
+ Duration p (gh_scm2int (length), dots);
if (compress)
p = p.compressed (Rational (gh_scm2int (num), gh_scm2int (den)));
void
Engraver::announce_grob (Grob* e, SCM cause)
{
- /*
- TODO: junk grob-info, and make a cause grob-property to store
- `causes' generically.
- */
if (unsmob_music (cause) || unsmob_grob (cause))
e->set_property ("cause", cause);
/*
TODO: make optional argument for default if not found.
-
*/
return m.smobbed_copy ();
}
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;
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++)
{
Real minimal_demerits = infinity_f;
- bool ragged = to_boolean (pscore_->paper_->get_scmvar ("raggedright"));
-
for (int start_idx = break_idx; start_idx--;)
{
Link_array<Grob> line = all.slice (breaks[start_idx], breaks[break_idx]+1);
- line[0] = dynamic_cast<Item*> (line[0]) ->find_prebroken_piece (RIGHT);
+ line[0] = dynamic_cast<Item*> (line[0])->find_prebroken_piece (RIGHT);
line.top () = dynamic_cast<Item*> (line.top ())->find_prebroken_piece (LEFT);
Column_x_positions cp;
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_);
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;
}
This doesn't look very elegant: should support winged edges.
Support texts on the brackets?
-
*/
-
MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1);
SCM
/*
-
TODO: make the increment function in Scheme.
-
-
- TODO: junk the number type for rehearsalMark
*/
void
Mark_engraver::process_music ()
/*
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"
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),
}
/*
- TODO: rename to prevent confusion between Translator::try_music and
+ TODO: rename to prevent confusion between Context::try_music and
Iterator::try_music
*/
}
/*
- 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
/*
- slur.cc -- implement Slur
+ slur.cc -- implement Slur
source file of the GNU LilyPond music typesetter
// 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 ;
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
{
cm = #(* 10 mm)
raggedright = ##f
+ raggedlast = ##f
packed = ##f
#(define $is-paper #t)
$(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
;;
;; 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 <Font-tree-element>
+ ()
+ )
-(define font-tree-record
- (make-record-type
- "font-tree-node"
- '(qualifier default children)))
+(define-class <Font-tree-leaf> (<Font-tree-element>)
+ (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 <Font-tree-node> (<Font-tree-element>)
+ (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 <Font-tree-leaf> #: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 <Font-tree-node>
+ #:qualifier qualifier
+ #:default default
+ #:children (make-hash-table 11)))
+
+(define-method (display (leaf <Font-tree-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 <Font-tree-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 <Font-tree-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
(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 <Font-tree-leaf>) 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 <Font-tree-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 <Font-tree-leaf>) alist-chain)
+ node)
+
+(define (lookup-font node alist-chain)
+ (g-lookup-font node alist-chain))
+
(define-public (make-font-tree factor)
(let*
))
n))
+; (display (make-font-tree 1.0))
+
(define-public (magstep x)
(exp (* (/ x 6) (log 2))))