From d721d8a8f8b628b5254796f46bedb2f3b9067b50 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 21 Jan 2006 00:14:10 +0000 Subject: [PATCH] * scm/framework-ps.scm (write-preamble): use it to pick exactly the right font from a Mac dfont. * lily/ttf.cc (LY_DEFINE): ly:ttf-ps-name: new routine to extract PS name from TTF font. * input/regression/tie-manual.ly: document new feature. * Documentation/topdocs/NEWS.tely (Top): add tie NEWS. * VERSION (MY_PATCH_LEVEL): bump to .28 * Documentation/user/basic-notation.itely (Ties): add tie examples refs. * lily/tie-formatting-problem.cc (score_ties_configuration): symmetry penalties for outer ties. --- ChangeLog | 26 ++++++++++++- Documentation/topdocs/NEWS.tely | 8 +++- Documentation/user/basic-notation.itely | 6 +++ VERSION | 2 +- input/regression/tie-manual.ly | 7 +++- lily/include/tie-formatting-problem.hh | 4 +- lily/tie-formatting-problem.cc | 51 ++++++++++++++++--------- lily/tie-helper.cc | 3 ++ lily/tie.cc | 4 +- lily/ttf.cc | 19 +++++++++ scm/define-grob-properties.scm | 4 +- scm/define-grobs.scm | 8 ++-- scm/framework-ps.scm | 6 +-- 13 files changed, 115 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 742d8a559e..a7d758b776 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,30 @@ +2006-01-21 Han-Wen Nienhuys + + * scm/framework-ps.scm (write-preamble): use it to pick exactly + the right font from a Mac dfont. + + * lily/ttf.cc (LY_DEFINE): ly:ttf-ps-name: new routine to extract + PS name from TTF font. + + * input/regression/tie-manual.ly: document new feature. + + * Documentation/topdocs/NEWS.tely (Top): add tie NEWS. + + * VERSION (MY_PATCH_LEVEL): bump to .28 + + * Documentation/user/basic-notation.itely (Ties): add tie examples + refs. + + * lily/tie-formatting-problem.cc (score_ties_configuration): + symmetry penalties for outer ties. + 2006-01-20 Han-Wen Nienhuys - * lily/tie-formatting-problem.cc (generate_configuration): + * lily/tie-formatting-problem.cc (generate_configuration) + (set_manual_tie_configuration): skip non-pair manual + tie-configuration, so you can set individual ties as + + #'tie-configuration = #'((7 . 1) #t (-3 . 1)) * input/regression/tie-chord.ly: use generateTiePattern to simplify file. diff --git a/Documentation/topdocs/NEWS.tely b/Documentation/topdocs/NEWS.tely index a72abdfeaf..fdac765857 100644 --- a/Documentation/topdocs/NEWS.tely +++ b/Documentation/topdocs/NEWS.tely @@ -47,6 +47,12 @@ the @uref{../,LilyPond Documentation} @itemize @bullet +@item The tie formatting for chords has been further polished. More +cases are handled gracefully, and all scoring parameters may now be +changed through the @code{details} property of the @code{Tie} grob. + +This refinement was sponsored by Steve Doonan. + @item Positions of staff lines may now be set individually, for example @@ -412,7 +418,7 @@ specify tie formatting ~ \override TieColumn #'tie-configuration = - #'((0 . -1) (2 . -1) (5.5 . 1) (7 . 1)) + #'((0 . -1) '() (5.5 . 1) (7 . 1)) ~ @end lilypond diff --git a/Documentation/user/basic-notation.itely b/Documentation/user/basic-notation.itely index 473c2b0e5f..7c342db00e 100644 --- a/Documentation/user/basic-notation.itely +++ b/Documentation/user/basic-notation.itely @@ -1528,6 +1528,12 @@ In this manual: @ref{Automatic note splitting}. Program reference: @internalsref{Tie}. +Examples: +@inputfileref{input/@/regression,tie-arpeggio.ly} +@inputfileref{input/@/regression,tie-manual.ly} + + + @refbugs diff --git a/VERSION b/VERSION index 14c743e705..4453cfda2d 100644 --- a/VERSION +++ b/VERSION @@ -1,6 +1,6 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=2 MINOR_VERSION=7 -PATCH_LEVEL=27 +PATCH_LEVEL=28 MY_PATCH_LEVEL= diff --git a/input/regression/tie-manual.ly b/input/regression/tie-manual.ly index c8d8d9dc89..6311da6660 100644 --- a/input/regression/tie-manual.ly +++ b/input/regression/tie-manual.ly @@ -2,7 +2,12 @@ texidoc = "Tie formatting may be adjusted manually, by setting the @code{tie-configuration} property. The override should be placed at -the second note of the chord." +the second note of the chord. + +You can leave a Tie alone by introducing a non-pair value +(eg. @code{#t}) in the @code{tie-configuration} list. + +" } diff --git a/lily/include/tie-formatting-problem.hh b/lily/include/tie-formatting-problem.hh index f311ef682c..01b44cbef4 100644 --- a/lily/include/tie-formatting-problem.hh +++ b/lily/include/tie-formatting-problem.hh @@ -41,7 +41,9 @@ struct Tie_details Real horizontal_distance_penalty_factor_; Real vertical_distance_penalty_factor_; Real intra_space_threshold_; - + Real outer_tie_length_symmetry_penalty_factor_; + Real outer_tie_vertical_distance_symmetry_penalty_factor_; + Grob *staff_symbol_referencer_; Tie_details (); diff --git a/lily/tie-formatting-problem.cc b/lily/tie-formatting-problem.cc index f9d92bf616..c0c31a31ac 100644 --- a/lily/tie-formatting-problem.cc +++ b/lily/tie-formatting-problem.cc @@ -323,7 +323,13 @@ Tie_formatting_problem::generate_configuration (int pos, Direction dir) const if (!conf->delta_y_) { /* - TODO: make sliding criterion? + TODO: + + - should make sliding criterion, should flatten ties if + + - they're just the wrong (ie. touching line at top & bottom) + size. + */ if (h < details_.intra_space_threshold_ * 0.5 * details_.staff_space_) { @@ -550,7 +556,6 @@ Tie_formatting_problem::score_ties_configuration (Ties_configuration const &ties score += score_configuration (ties[i]); } - Real last_edge = 0.0; Real last_center = 0.0; for (int i = 0; i < ties.size (); i++) @@ -583,6 +588,19 @@ Tie_formatting_problem::score_ties_configuration (Ties_configuration const &ties last_center = center; } + + score += + details_.outer_tie_length_symmetry_penalty_factor_ + * fabs (ties[0].attachment_x_.length () - ties.top().attachment_x_.length ()); + + score += + details_.outer_tie_vertical_distance_symmetry_penalty_factor_ + * (fabs (specifications_[0].position_ + - (ties[0].position_ * 0.5 * details_.staff_space_ + ties[0].delta_y_)) + - + fabs (specifications_.top ().position_ + - (ties.top().position_ * 0.5 * details_.staff_space_ + ties.top().delta_y_))); + return score; } @@ -789,22 +807,21 @@ Tie_formatting_problem::set_manual_tie_configuration (SCM manual_configs) scm_is_pair (s) && k < specifications_.size(); s = scm_cdr (s)) { SCM entry = scm_car (s); - if (!scm_is_pair (entry)) - continue; - - Tie_specification &spec = specifications_[k]; - - if (scm_is_number (scm_cdr (entry))) + if (scm_is_pair (entry)) { - spec.has_manual_dir_ = true; - spec.manual_dir_ = Direction (scm_to_int (scm_cdr (entry))); - } - if (scm_is_number (scm_car (entry))) - { - spec.has_manual_position_ = true; - spec.manual_position_ = scm_to_double (scm_car (entry)); - } - + Tie_specification &spec = specifications_[k]; + + if (scm_is_number (scm_cdr (entry))) + { + spec.has_manual_dir_ = true; + spec.manual_dir_ = Direction (scm_to_int (scm_cdr (entry))); + } + if (scm_is_number (scm_car (entry))) + { + spec.has_manual_position_ = true; + spec.manual_position_ = scm_to_double (scm_car (entry)); + } + } k ++; } } diff --git a/lily/tie-helper.cc b/lily/tie-helper.cc index 2e3f4b826c..66afbc4229 100644 --- a/lily/tie-helper.cc +++ b/lily/tie-helper.cc @@ -52,6 +52,9 @@ Tie_details::from_grob (Grob *me) horizontal_distance_penalty_factor_ = get_real_detail ("horizontal-distance-penalty-factor", 5); vertical_distance_penalty_factor_ = get_real_detail ("vertical-distance-penalty-factor", 5); intra_space_threshold_ = get_real_detail ("intra-space-threshold", 1.0); + outer_tie_length_symmetry_penalty_factor_ = get_real_detail ("outer-tie-length-symmetry-penalty-factor", 3.0); + outer_tie_vertical_distance_symmetry_penalty_factor_ = get_real_detail ("outer-tie-vertical-distance-symmetry-penalty-factor", 3.0); + } Tie_details::Tie_details () diff --git a/lily/tie.cc b/lily/tie.cc index e67ed6b3e1..9cf7468d6c 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -242,7 +242,7 @@ Tie::print (SCM smob) ADD_INTERFACE (Tie, "tie-interface", - "A tie connecting two noteheads. \n\n" + "A horizontal curve connecting two noteheads. \n\n" , @@ -254,7 +254,7 @@ ADD_INTERFACE (Tie, "details " "direction " "thickness " - "x-gap "); + ); diff --git a/lily/ttf.cc b/lily/ttf.cc index 1c6f788179..14d58411f7 100644 --- a/lily/ttf.cc +++ b/lily/ttf.cc @@ -161,6 +161,25 @@ create_type42_font (void *out, String name) print_trailer (out, face); } +LY_DEFINE (ly_ttf_ps_name, "ly:ttf-ps-name", + 1, 0, 0, (SCM ttf_file_name), + "Extract the PostScript name from a TrueType font.") +{ + SCM_ASSERT_TYPE (scm_is_string (ttf_file_name), ttf_file_name, + SCM_ARG1, __FUNCTION__, "string"); + String file_name = ly_scm2string (ttf_file_name); + if (be_verbose_global) + progress_indication ("[" + file_name); + + FT_Face face = open_ft_face (file_name); + char const *ps_name_str0 = FT_Get_Postscript_Name (face); + + if (be_verbose_global) + progress_indication ("]"); + + return scm_makfrom0str (ps_name_str0 ? ps_name_str0 : ""); +} + LY_DEFINE (ly_ttf_to_pfa, "ly:ttf->pfa", 1, 0, 0, (SCM ttf_file_name), "Convert the contents of a TTF file to Type42 PFA, returning it as " diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 21afb9af58..53ad479a5a 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -423,7 +423,8 @@ use LEFT.") (threshold ,number-pair? "(@var{min} . @var{max}), where @var{min} and @var{max} are dimensions in staff space.") (tie-configuration ,list? "List of (@var{position} . @var{dir}) -pairs, indicating the desired tie configuration.") +pairs, indicating the desired tie configuration. A non-pair entry in +the list will cause said tie to be formatted automatically. ") (transparent ,boolean? "This makes the grob invisible.") (uniform-stretching ,boolean? "If set, items stretch proportional to their durations. This looks better in complex polyphonic patterns") @@ -432,7 +433,6 @@ to their durations. This looks better in complex polyphonic patterns") happen?") (word-space ,ly:dimension? "space to insert between words in texts.") (width ,ly:dimension? "The width of a grob measured in staff space.") - (x-gap ,ly:dimension? "The horizontal gap between note head and tie.") (zigzag-length ,ly:dimension? "The length of the lines of a zigzag, relative to @code{zigzag-width}. A value of 1 gives 60-degree zigzags.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 4eba1d8e23..2284709184 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -809,9 +809,7 @@ . ( (X-extent . #f) (Y-extent . #f) - (positioning-done . ,Laissez_vibrer_tie_column::calc_positioning_done) - (meta . ((class . Item) (interfaces . (laissez-vibrer-tie-column-interface)) )) @@ -1715,7 +1713,9 @@ (avoid-slur . inside) (direction . ,Tie::calc_direction) (stencil . ,Tie::print) - (details . ((ratio . 0.333) + (details . ( + ;; for a full list, see tie-helper.cc + (ratio . 0.333) (center-staff-line-clearance . 0.6) (tip-staff-line-clearance . 0.45) (note-head-gap . 0.2) @@ -1725,6 +1725,8 @@ (tie-tie-collision-distance . 0.45) (tie-tie-collision-penalty . 25.0) (intra-space-threshold . 1.25) + (outer-tie-vertical-distance-symmetry-penalty-factor . 10) + (outer-tie-length-symmetry-penalty-factor . 10) (between-length-limit . 1.0))) (thickness . 1.0) (meta . ((class . Spanner) diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index 54f0f1c7a2..d2092c8d67 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -281,9 +281,7 @@ (status 0) (embed #f)) - (mkdir dir-name #o700) - (set! status (ly:system (format "cd ~a && fondu -force '~a'" dir-name filename))) @@ -292,10 +290,10 @@ (for-each (lambda (f) (if (and (not embed) - (string-match (string-append name "\\.") f)) + (equal? name (ly:ttf-ps-name f))) (set! embed (font-file-as-ps-string name (dir-join dir-name f)))) - + (if (or (equal? "." f) (equal? ".." f)) #t -- 2.39.2