]> git.donarmstrong.com Git - lilypond.git/commitdiff
Merge branch 'master' into topic/master-translation
authorJohn Mandereau <john.mandereau@gmail.com>
Tue, 27 Mar 2007 15:01:34 +0000 (17:01 +0200)
committerJohn Mandereau <john.mandereau@gmail.com>
Tue, 27 Mar 2007 15:01:34 +0000 (17:01 +0200)
* master: (21 commits)
  Fix #281.
  Fix #51.
  Fix rest-dot-position.ly
  Fix collision-dots-move.ly
  formatting nit.
  also handle rests for dot positioning
  bugfix: don't return flag for invisible stems.
  Cleanup and simplify  dot column formatting logic.
  add prototypes.
  trim outdated comment
  Add Skyline::print_points(), Offset::swapped()
  make Dot_configuration into class, in new files dot-configuration.{cc,hh}
  use ly:progress for backend-svg
  always compile in Grob::instrumented_set_property
  whitespace cleanup.
  Edit docs translation instructions
  bump version
  use envp argument for main()
  strip LD_LIBRARY_PATH from inkscape call.
  Fix backend-svg.ly for ubuntu 6.06
  ...

32 files changed:
GNUmakefile.in
VERSION
flower/include/offset.hh
flower/offset.cc
input/regression/backend-svg.ly
input/regression/collision-dots.ly
input/regression/dot-up-voice-collision.ly [new file with mode: 0644]
input/regression/script-center-seconds.ly [new file with mode: 0644]
lily/dot-column.cc
lily/dot-configuration.cc [new file with mode: 0644]
lily/dot-formatting-problem.cc [new file with mode: 0644]
lily/general-scheme.cc
lily/grob-property.cc
lily/include/dot-configuration.hh [new file with mode: 0644]
lily/include/dot-formatting-problem.hh [new file with mode: 0644]
lily/include/lily-proto.hh
lily/include/main.hh
lily/include/note-column.hh
lily/include/note-head.hh
lily/include/script-interface.hh
lily/include/skyline.hh
lily/main.cc
lily/note-collision.cc
lily/note-column.cc
lily/script-interface.cc
lily/skyline.cc
lily/stem.cc
mf/GNUmakefile
scm/backend-library.scm
scm/define-grobs.scm
scm/output-lib.scm
scm/safe-lily.scm

index c9879725c8b6504c1237dea72e1fb82a98f7e7e1..f05ed3fe4d3ee51d0d48c15046aa8cd4973218bb 100644 (file)
@@ -178,10 +178,13 @@ $(tree-share-prefix)/lilypond-force link-tree: GNUmakefile $(outdir)/VERSION
 $(tree-share-prefix)/mf-link-tree link-mf-tree: $(tree-share-prefix)/lilypond-force
        -rm -f $(tree-share-prefix)/fonts/otf/* &&  \
        rm -f $(tree-share-prefix)/fonts/svg/* &&  \
+       rm -f $(tree-share-prefix)/fonts/fonts.conf &&  \
        rm -f $(tree-share-prefix)/fonts/tfm/* &&  \
        rm -f $(tree-share-prefix)/fonts/type1/* &&  \
                cd $(tree-share-prefix)/fonts/otf && \
                ln -s ../../../../../../mf/$(outconfbase)/*.otf .
+       -cd $(tree-share-prefix)/fonts/ && \
+               ln -s ../../../../../mf/$(outconfbase)/fonts.conf .
        -cd $(tree-share-prefix)/fonts/svg && \
                ln -s ../../../../../../mf/$(outconfbase)/*.svg .
        -cd $(tree-share-prefix)/fonts/tfm && \
diff --git a/VERSION b/VERSION
index 14fa44f263aa6d79fa5857509c40e1c86af34ac8..4db62148a37675663bda8020758d0687543dbded 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1,6 +1,6 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=2
 MINOR_VERSION=11
-PATCH_LEVEL=20
+PATCH_LEVEL=21
 MY_PATCH_LEVEL=
 
index a3093c98ef2548f2157b328c44d510415352ee27..80053a51b6546f71a0172d86580fcb475dd78e4c 100644 (file)
@@ -97,6 +97,7 @@ public:
     return *this;
   }
   Offset direction () const;
+  Offset swapped () const;
   
   Real arg () const;
   Real angle_degrees () const;
index 8fc956c65e6ac097ac166547ad83bf9e7cafea2b..294f69e6f8e5a3c2626497615c14038429df8ece 100644 (file)
@@ -105,3 +105,9 @@ Offset::direction () const
   d /= length (); 
   return d;
 }
+
+Offset
+Offset::swapped () const
+{
+  return Offset (coordinate_a_[Y_AXIS], coordinate_a_[X_AXIS]);
+}
index f9d9ffe3a5afcb1380deff647cc13bd31ad4874d..823016e85bcce00c2607d69591ffbd5ecc8f195e 100644 (file)
 #(ly:set-option 'backend 'eps)
 
 %% TODO: what to do if inkscape fails?
-#(display "Invoking inkscape...\n")
+#(ly:progress "Invoking inkscape...\n")
+
+%% LD_LIBRARY_PATH is necesssary, otherwise, it doesn't build in GUB.
+%% LD_LIBRARY_PATH is part of the start-environment but should be switched off
+%% for external inkscape.
+#(ly:system (format #f "LD_LIBRARY_PATH= inkscape -T -E ~a-inkscape.eps ~a-1.svg" outname outname)
+  (cons
+   (format #f "FONTCONFIG_FILE=~a/fonts/fonts.conf" (ly:effective-prefix))
+   (ly:start-environment)))
 
-%% LD_LIBRARY_PATH is necesssary, otherwise, it doesn't build in GUB.  
-#(system (format #f "LD_LIBRARY_PATH= inkscape -T -E ~a-1.eps ~a-1.svg" outname outname))
 #(set! output-count 0)
 #(set-default-paper-size "a5")
 
@@ -28,9 +34,9 @@
   \score {
     \lyrics {
       \markup {
-       \epsfile #X #30.0 #(format #f "~a-1.eps" outname)
+       \epsfile #X #30.0 #(format #f "~a-inkscape.eps" outname)
       }
-      x x x
+      bla bla bla
     }
   }
 }
index 645000c8031a979670a26a1e87a382edab2d7a0a..b526e369de9e7a4d62d0bc18823dd8a9a42e563c 100644 (file)
@@ -1,6 +1,3 @@
-
-
-
 \header { texidoc = "Collision resolution tries to put notes with dots
   on the right side."
 }
diff --git a/input/regression/dot-up-voice-collision.ly b/input/regression/dot-up-voice-collision.ly
new file mode 100644 (file)
index 0000000..2009232
--- /dev/null
@@ -0,0 +1,18 @@
+\header {
+
+  texidoc = "in collisions, the stems of outer voice are added to the
+  dot support of the inner voices."
+
+}
+
+\version "2.11.21"
+
+\layout { ragged-right = ##t }
+
+\new Staff {
+  \key e \major \time 3/4
+  \relative c'' {
+    << { dis4.  } \\
+       { fis,4 } \\ { b4 } >>
+  }
+}
diff --git a/input/regression/script-center-seconds.ly b/input/regression/script-center-seconds.ly
new file mode 100644 (file)
index 0000000..765d47a
--- /dev/null
@@ -0,0 +1,13 @@
+\header {
+
+  texidoc = "Scripts on chords with seconds remain centered on the extremal note head"
+  }
+
+
+\version "2.10.21"
+\layout { ragged-right = ##t }
+
+\relative c''{
+  <g a>-.
+  <g a>_.
+}
index 3c1eff6c60dfc3815675eb35926aacfe61d0f94d..36c95137970240f526faff57515c68e8f7753f07 100644 (file)
@@ -11,6 +11,8 @@
 #include <cstdio>
 #include <cmath>
 #include <map>
+#include <set>
+
 using namespace std;
 
 #include "dots.hh"
@@ -23,229 +25,118 @@ using namespace std;
 #include "stem.hh"
 #include "grob.hh"
 #include "pointer-group-interface.hh"
+#include "dot-configuration.hh"
+#include "note-head.hh"
+#include "rest.hh"
+#include "dot-formatting-problem.hh"
 
-/*
-  TODO: let Dot_column communicate with stem via Note_column.
-*/
-
-MAKE_SCHEME_CALLBACK (Dot_column, side_position, 1);
+MAKE_SCHEME_CALLBACK (Dot_column, calc_positioning_done, 1);
 SCM
-Dot_column::side_position (SCM smob)
-{
-  Grob *me = unsmob_grob (smob);
-  extract_grob_set (me, "dots", dots);
-  
-  for (vsize i = 0; i  < dots.size (); i++)
-    {
-      Grob *head = dots[i]->get_parent (Y_AXIS);
-      Grob *stem = head ? unsmob_grob (head->get_object ("stem")) : 0;
-      if (stem
-         && !Stem::get_beam (stem)
-         && Stem::duration_log (stem) > 2
-         && !Stem::is_invisible (stem))
-       {
-         /*
-           trigger stem end & direction calculation.
-           
-           This will add the stem to the support if a flag collision happens.
-         */
-         stem->get_property ("stem-end-position");
-       }
-    }
-
-  return Side_position_interface::x_aligned_side (smob, SCM_EOL);
-}
-
-struct Dot_position
+Dot_column::calc_positioning_done (SCM smob)
 {
-  int pos_;
-  Direction dir_;
-  Grob *dot_;
-  bool extremal_head_;
-
-  Dot_position ()
-  {
-    dot_ = 0;
-    pos_ = 0;
-    dir_ = CENTER;
-    extremal_head_ = false;
-  }
-};
+  Grob *me = unsmob_grob (smob);  
 
-typedef map<int, Dot_position> Dot_configuration;
+  me->set_property ("positioning-done", SCM_BOOL_T);
 
-/*
-  Value CFG according.
-*/
-int
-dot_config_badness (Dot_configuration const &cfg)
-{
-  int t = 0;
-  for (Dot_configuration::const_iterator i (cfg.begin ());
-       i != cfg.end (); i++)
-    {
-      int p = i->first;
-      int demerit = sqr (p - i->second.pos_) * 2;
+  vector<Grob*> dots
+    = extract_grob_array (me, "dots");
 
-      int dot_move_dir = sign (p - i->second.pos_);
-      if (i->second.extremal_head_)
-       {
-         if (i->second.dir_
-             && dot_move_dir != i->second.dir_)
-           demerit += 3;
-         else if (dot_move_dir != UP)
-           demerit += 2;
-       }
-      else if (dot_move_dir != UP)
-       demerit += 1;
+  vector<Grob*> main_heads;
+  Real ss = 0;
 
-      t += demerit;
-    }
+  Grob *commonx = me;
+  { /*
+      Trigger note collision resolution first, since that may kill off
+      dots when merging.
+    */
+    for (vsize i = 0; i < dots.size (); i++)
+      {
+       Grob *n = dots[i]->get_parent (Y_AXIS);
+       commonx = n->common_refpoint (commonx, X_AXIS);
 
-  return t;
-}
+       if (Grob *stem = unsmob_grob (n->get_object("stem")))
+         {
+           commonx = stem->common_refpoint (commonx, X_AXIS);
 
-void
-print_dot_configuration (Dot_configuration const &cfg)
-{
-  printf ("dotconf { ");
-  for (Dot_configuration::const_iterator i (cfg.begin ());
-       i != cfg.end (); i++)
-    printf ("%d, ", i->first);
-  printf ("} \n");
-}
+           if (Stem::first_head (stem) == n)
+             main_heads.push_back (n);
+         }
+      }
+  }
 
-/*
-  Shift K and following (preceding) entries up (down) as necessary to
-  prevent staffline collisions if D is up (down).
+  vector<Box> boxes;
+  set<Grob*> stems;
 
-  If K is in CFG, then do nothing.
-*/
+  extract_grob_set(me, "side-support-elements", support);
 
-Dot_configuration
-shift_one (Dot_configuration const &cfg,
-          int k, Direction d)
-{
-  Dot_configuration new_cfg;
-  int offset = 0;
-
-  if (d > 0)
+  Interval base_x;
+  for (vsize i = 0; i < main_heads.size (); i++)
+    base_x.unite (main_heads[i]->extent (commonx, X_AXIS));
+  for (vsize i = 0; i < support.size (); i++)
     {
-      for (Dot_configuration::const_iterator i (cfg.begin ());
-          i != cfg.end (); i++)
+      Grob *s = support[i];
+      if (!ss)
+       ss = Staff_symbol_referencer::staff_space (s);
+
+      /* can't inspect Y extent of rest.
+        
+        Rest collisions should wait after line breaking.
+      */
+      Interval y;
+      if (Rest::has_interface (s))
        {
-         int p = i->first;
-         if (p == k)
-           {
-             if (Staff_symbol_referencer::on_line (i->second.dot_, p))
-               p += d;
-             else
-               p += 2* d;
-
-             offset = 2*d;
-
-             new_cfg[p] = i->second;
-           }
-         else
-           {
-             if (new_cfg.find (p) == new_cfg.end ())
-               offset = 0;
-             new_cfg[p + offset] = i->second;
-           }
+         base_x.unite (s->extent (commonx, X_AXIS));
+         continue;
        }
-    }
-  else
-    {
-      Dot_configuration::const_iterator i (cfg.end ());
-      do
+      else if (Stem::has_interface (s))
        {
-         i--;
-
-         int p = i->first;
-         if (p == k)
-           {
-             if (Staff_symbol_referencer::on_line (i->second.dot_, p))
-               p += d;
-             else
-               p += 2* d;
-
-             offset = 2*d;
-
-             new_cfg[p] = i->second;
-           }
-         else
-           {
-             if (new_cfg.find (p) == new_cfg.end ())
-               offset = 0;
-
-             new_cfg[p + offset] = i->second;
-           }
+         Real y1 = Stem::head_positions (s)[-get_grob_direction (s)];
+         Real y2 = y1 + get_grob_direction (s) * 7;
+
+         y.add_point (y1);
+         y.add_point (y2);
        }
-      while (i != cfg.begin ());
-    }
+      else
+       y = s->extent (s, Y_AXIS);
 
-  return new_cfg;
-}
+      y *= 2 / ss;
+      y += Staff_symbol_referencer::get_position (s);
+         
+      Box b (s->extent (commonx, X_AXIS), y);
+      boxes.push_back (b);
 
-/*
-  Remove the collision in CFG either by shifting up or down, whichever
-  is best.
-*/
-void
-remove_collision (Dot_configuration &cfg, int p)
-{
-  bool collide = cfg.find (p) != cfg.end ();
+      if (Grob *stem = unsmob_grob (s->get_object ("stem")))
+       stems.insert (stem);
+    }
 
-  if (collide)
+  for (set<Grob*>::const_iterator i(stems.begin());
+       i != stems.end (); i++)
     {
-      Dot_configuration cfg_up = shift_one (cfg, p, UP);
-      Dot_configuration cfg_down = shift_one (cfg, p, DOWN);
-
-      int b_up = dot_config_badness (cfg_up);
-      int b_down = dot_config_badness (cfg_down);
-
-      cfg = (b_up < b_down) ? cfg_up : cfg_down;
+      Grob *stem = (*i);
+      Stencil flag = Stem::flag (stem);
+      if (!flag.is_empty ())
+       {
+         Interval y = flag.extent (Y_AXIS)
+           * (2 / ss)
+           + Stem::stem_end_position (stem);
+                 
+         Interval x = stem->relative_coordinate (commonx, X_AXIS)
+           + flag.extent (X_AXIS);
+
+         boxes.push_back (Box (x,y));
+       }
     }
-}
-
-MAKE_SCHEME_CALLBACK (Dot_column, calc_positioning_done, 1);
-SCM
-Dot_column::calc_positioning_done (SCM smob)
-{
-  Grob *me = unsmob_grob (smob);  
-
-  me->set_property ("positioning-done", SCM_BOOL_T);
-
-  vector<Grob*> dots
-    = extract_grob_array (me, "dots");
-
-  { /*
-      Trigger note collision resolution first, since that may kill off
-      dots when merging.
-    */
-    Grob *c = 0;
-    for (vsize i = dots.size (); i--;)
-      {
-       Grob *n = dots[i]->get_parent (Y_AXIS);
-       if (c)
-         c = n->common_refpoint (c, X_AXIS);
-       else
-         c = n;
-      }
-    for (vsize i = dots.size (); i--;)
-      {
-       Grob *n = dots[i]->get_parent (Y_AXIS);
-       n->relative_coordinate (c, X_AXIS);
-      }
-  }
-
+             
   vector_sort (dots, position_less);
   for (vsize i = dots.size (); i--;)
     if (!dots[i]->is_live ())
       dots.erase (dots.begin () + i);
 
-  Dot_configuration cfg;
-  for (vsize i = 0;i < dots.size (); i++)
+  Dot_formatting_problem problem (boxes, base_x);
+
+  Dot_configuration cfg (problem);
+  for (vsize i = 0; i < dots.size (); i++)
     {
       Dot_position dp;
       dp.dot_ = dots[i];
@@ -256,6 +147,8 @@ Dot_column::calc_positioning_done (SCM smob)
          Grob *stem = unsmob_grob (note->get_object ("stem"));
          if (stem)
            dp.extremal_head_ = Stem::first_head (stem) == note;
+         
+         dp.x_extent_ = note->extent (commonx, X_AXIS);
        }
 
       int p = Staff_symbol_referencer::get_rounded_position (dp.dot_);
@@ -264,16 +157,17 @@ Dot_column::calc_positioning_done (SCM smob)
         offset callback but adding a dot overwrites Y-offset. */
       p += (int) robust_scm2double (dp.dot_->get_property ("staff-position"), 0.0);
       dp.pos_ = p;
-
       if (dp.extremal_head_)
        dp.dir_ = to_dir (dp.dot_->get_property ("direction"));
 
-      remove_collision (cfg, p);
+      cfg.remove_collision (p);
       cfg[p] = dp;
       if (Staff_symbol_referencer::on_line (dp.dot_, p))
-       remove_collision (cfg, p);
+       cfg.remove_collision (p);
     }
 
+  problem.register_configuration (cfg);
+
   for (Dot_configuration::const_iterator i (cfg.begin ());
        i != cfg.end (); i++)
     {
@@ -282,6 +176,10 @@ Dot_column::calc_positioning_done (SCM smob)
        */
       Staff_symbol_referencer::set_position (i->second.dot_, i->first);
     }
+
+  
+  me->translate_axis (cfg.x_offset () - me->relative_coordinate (commonx, X_AXIS),
+                     X_AXIS);
   return SCM_BOOL_T;
 }
 
@@ -295,6 +193,7 @@ Dot_column::add_head (Grob *me, Grob *rh)
 
       Pointer_group_interface::add_grob (me, ly_symbol2scm ("dots"), d);
       d->set_property ("Y-offset", Grob::x_parent_positioning_proc);
+      d->set_property ("X-offset", Grob::x_parent_positioning_proc);
       Axis_group_interface::add_element (me, d);
     }
 }
@@ -302,7 +201,7 @@ Dot_column::add_head (Grob *me, Grob *rh)
 ADD_INTERFACE (Dot_column,
               
               "Groups dot objects so they form a column, and position dots so they do not "
-              "clash with staff lines ",
+              "clash with staff lines. ",
 
               /* properties */
               "dots "
diff --git a/lily/dot-configuration.cc b/lily/dot-configuration.cc
new file mode 100644 (file)
index 0000000..c4cf852
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+  dot-implement.cc -- declare Dot_configuration
+
+  Source file of the GNU LilyPond music typesetter.  Distributed under
+  terms of the GNU General Public License.  LilyPond comes with NO
+  WARRANTY.
+
+  (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
+
+#include "dot-configuration.hh"
+#include "dot-formatting-problem.hh"
+#include "staff-symbol-referencer.hh"
+
+
+int
+Dot_configuration::badness () const
+{
+  int t = 0;
+  for (Dot_configuration::const_iterator i (begin ());
+       i != end (); i++)
+    {
+      int p = i->first;
+      int demerit = sqr (p - i->second.pos_) * 2;
+
+      int dot_move_dir = sign (p - i->second.pos_);
+      if (i->second.extremal_head_)
+       {
+         if (i->second.dir_
+             && dot_move_dir != i->second.dir_)
+           demerit += 3;
+         else if (dot_move_dir != UP)
+           demerit += 2;
+       }
+      else if (dot_move_dir != UP)
+       demerit += 1;
+
+      t += demerit;
+    }
+
+  return t;
+}
+
+void
+Dot_configuration::print () const
+{
+  printf ("dotconf { ");
+  for (Dot_configuration::const_iterator i (begin ());
+       i != end (); i++)
+    printf ("%d, ", i->first);
+  printf ("} \n");
+}
+
+/*
+  Shift K and following (preceding) entries up (down) as necessary to
+  prevent staffline collisions if D is up (down).
+
+  If K is in CFG, then do nothing.
+*/
+
+Dot_configuration
+Dot_configuration::shifted (int k, Direction d) const
+{
+  Dot_configuration new_cfg (*problem_);
+  int offset = 0;
+
+  if (d > 0)
+    {
+      for (Dot_configuration::const_iterator i (begin ());
+          i != end (); i++)
+       {
+         int p = i->first;
+         if (p == k)
+           {
+             if (Staff_symbol_referencer::on_line (i->second.dot_, p))
+               p += d;
+             else
+               p += 2* d;
+
+             offset = 2*d;
+
+             new_cfg[p] = i->second;
+           }
+         else
+           {
+             if (new_cfg.find (p) == new_cfg.end ())
+               offset = 0;
+             new_cfg[p + offset] = i->second;
+           }
+       }
+    }
+  else
+    {
+      Dot_configuration::const_iterator i (end ());
+      do
+       {
+         i--;
+
+         int p = i->first;
+         if (p == k)
+           {
+             if (Staff_symbol_referencer::on_line (i->second.dot_, p))
+               p += d;
+             else
+               p += 2* d;
+
+             offset = 2*d;
+
+             new_cfg[p] = i->second;
+           }
+         else
+           {
+             if (new_cfg.find (p) == new_cfg.end ())
+               offset = 0;
+
+             new_cfg[p + offset] = i->second;
+           }
+       }
+      while (i != begin ());
+    }
+
+  return new_cfg;
+}
+
+/*
+  Remove the collision in CFG either by shifting up or down, whichever
+  is best.
+*/
+void
+Dot_configuration::remove_collision (int p)
+{
+  bool collide = find (p) != end ();
+
+  if (collide)
+    {
+      Dot_configuration cfg_up = shifted (p, UP);
+      Dot_configuration cfg_down = shifted (p, DOWN);
+
+      int b_up = cfg_up.badness ();
+      int b_down = cfg_down.badness ();
+
+      *this = (b_up < b_down) ? cfg_up : cfg_down;
+    }
+}
+
+Dot_configuration::Dot_configuration (Dot_formatting_problem const &problem)
+{
+  problem_ = &problem;
+}
+
+Real
+Dot_configuration::x_offset () const
+{
+  Real off = 0.0;
+  for (Dot_configuration::const_iterator i (begin ());
+       i != end (); i++)
+    off = max (off, problem_->head_skyline_.height ((*i).first));
+
+  return off;
+}
diff --git a/lily/dot-formatting-problem.cc b/lily/dot-formatting-problem.cc
new file mode 100644 (file)
index 0000000..81dc908
--- /dev/null
@@ -0,0 +1,35 @@
+
+#include "dot-formatting-problem.hh"
+#include "dot-configuration.hh"
+#include "skyline.hh"
+
+Dot_formatting_problem::~Dot_formatting_problem()
+{
+  delete best_;
+}
+
+void
+Dot_formatting_problem::register_configuration (Dot_configuration const &src)
+{
+  int b = src.badness ();
+  if (b < score_)
+    {
+      delete best_;
+      best_ = new Dot_configuration (src);
+    }
+}
+
+Dot_configuration *
+Dot_formatting_problem::best () const
+{
+  return best_;
+}
+
+
+
+Dot_formatting_problem::Dot_formatting_problem (vector<Box> const &boxes, Interval base_x)
+  : head_skyline_ (boxes, 0.0, Y_AXIS, RIGHT)
+{
+  best_ = 0;
+  head_skyline_.set_minimum_height (base_x[RIGHT]);
+}
index cc46b631a301e473c596738b1fb10811a4cd3da2..f00d1938ab56746bc948f2cdc6ddb2f1172f55e5 100644 (file)
@@ -27,6 +27,24 @@ using namespace std;
 #include "file-name.hh"
 #include "string-convert.hh"
 
+LY_DEFINE (ly_start_environment, "ly:start-environment",
+          0, 0, 0, (),
+          "Return the environment, a list of strings, that was in effect at program start")
+{
+  SCM l = SCM_EOL;
+  SCM *tail = &l;
+
+  for (vsize i = 0; i < start_environment_global.size (); i++)
+    {
+      *tail = scm_cons (ly_string2scm (start_environment_global[i]),
+                       SCM_EOL);
+      tail = SCM_CDRLOC(*tail);
+    }
+
+  return l;
+}
+
+
 LY_DEFINE (ly_find_file, "ly:find-file",
           1, 0, 0, (SCM name),
           "Return the absolute file name of @var{name}, "
index 4eee8955e609747d618063ee873d4e3212aadb4f..d7f29aed3db1e29b7d9ade31f27ed6178dad5f64 100644 (file)
@@ -70,6 +70,7 @@ LY_DEFINE (ly_set_property_cache_callback, "ly:set-property-cache-callback",
   cache_callback = cb;
   return SCM_UNSPECIFIED;
 }
+#endif
 
 void
 Grob::instrumented_set_property (SCM sym, SCM v,
@@ -77,6 +78,7 @@ Grob::instrumented_set_property (SCM sym, SCM v,
                                 int line,
                                 char const *fun)
 {
+#ifndef NDEBUG
   if (ly_is_procedure (modification_callback))
     scm_apply_0 (modification_callback,
                 scm_list_n (self_scm (),
@@ -84,9 +86,10 @@ Grob::instrumented_set_property (SCM sym, SCM v,
                             scm_from_int (line),
                             scm_from_locale_string (fun),
                             sym, v, SCM_UNDEFINED));
+#endif
+  
   internal_set_property (sym, v);
 }
-#endif
 
 SCM
 Grob::get_property_alist_chain (SCM def) const
diff --git a/lily/include/dot-configuration.hh b/lily/include/dot-configuration.hh
new file mode 100644 (file)
index 0000000..a7ab09f
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+  dot-configuration.hh -- declare Dot_configuration
+
+  Source file of the GNU LilyPond music typesetter.  Distributed under
+  terms of the GNU General Public License.  LilyPond comes with NO
+  WARRANTY.
+
+  (c) 2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
+
+#ifndef DOT_CONFIGURATION_HH
+#define DOT_CONFIGURATION_HH
+
+#include "lily-proto.hh"
+#include "direction.hh"
+#include "box.hh"
+
+#include <map>
+
+struct Dot_position
+{
+  int pos_;
+  Direction dir_;
+  Grob *dot_;
+  Box dot_extents_;
+  bool extremal_head_;
+  Interval x_extent_;
+  
+  Dot_position ()
+  {
+    dot_ = 0;
+    pos_ = 0;
+    dir_ = CENTER;
+    extremal_head_ = false;
+  }
+};
+
+struct Dot_configuration : public map<int, Dot_position>
+{
+  Dot_formatting_problem const *problem_;
+  
+  Dot_configuration (Dot_formatting_problem const &);
+  Real x_offset () const;
+  int badness () const;
+  void print () const;
+  Dot_configuration shifted (int k, Direction d) const;
+  void remove_collision (int p);
+};
+
+#endif
diff --git a/lily/include/dot-formatting-problem.hh b/lily/include/dot-formatting-problem.hh
new file mode 100644 (file)
index 0000000..da24854
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef DOT_FORMATTING_PROBLEM_HH
+#define DOT_FORMATTING_PROBLEM_HH
+
+
+#include "skyline.hh"
+#include "std-vector.hh"
+
+#include <map>
+
+struct Dot_formatting_problem
+{
+  Skyline head_skyline_;
+  Dot_configuration *best_;
+  int score_;
+
+  void register_configuration (Dot_configuration const &);
+  Dot_configuration *best () const;
+  Dot_formatting_problem (vector<Box> const &boxes, Interval base_x);
+  ~Dot_formatting_problem();
+};
+
+#endif
index fc600c1bd62ffa82f3c9b0bd25405528ff39d274..768f24002cf4436bbb067b618b9f02558f2f1e7a 100644 (file)
@@ -45,6 +45,9 @@ class Context;
 class Context_def;
 class Context_specced_music;
 class Dispatcher;
+class Dot_column;
+class Dot_configuration;
+class Dot_formatting_problem;
 class Engraver;
 class Engraver;
 class Engraver_group;
@@ -149,6 +152,7 @@ class Simple_spacer;
 class Simple_spacer_wrapper;
 class Simultaneous_music;
 class Simultaneous_music_iterator;
+class Skyline;
 class Skyline_entry;
 class Slur_configuration;
 class Slur_score_state;
index 3db38a564f7d71cfcba52d4c489f807a12e36cd2..fb1d94b5934ca8f42df965c2aadd2add6ecb5e95 100644 (file)
@@ -27,6 +27,7 @@ extern string init_name_global;
 
 /* options */
 extern vector<string> dump_header_fieldnames_global;
+extern vector<string> start_environment_global;
 extern string output_backend_global;
 extern string output_name_global;
 extern bool be_safe_global;
index 60c2668890eef9f07aa3ea50a68484295f298042..429b83af3ef29968ac0b6650c96eccf5a35e1e55 100644 (file)
@@ -34,6 +34,7 @@ public:
   static void set_dotcol (Grob *me, Grob *);
   static void add_head (Grob *me, Grob *);
   static bool has_rests (Grob *me);
+  static Grob *dot_column (Grob *me);
   DECLARE_GROB_INTERFACE();
 
   static Item *get_stem (Grob *);
index 0891b7da2b343037412b8f642ddb02a8c152deab..2edeb1b95135e3c93034993ef2ca79564330dd80 100644 (file)
 #include "stencil.hh"
 #include "grob-interface.hh"
 
-/** ball at the end of the stem. Also takes care of ledger lines.
-
-NoteHead is a kind of RhythmicHead, see there.
-
-Read-only:
-*/
 
 class Note_head
 {
@@ -25,6 +19,7 @@ public:
   DECLARE_SCHEME_CALLBACK (stem_x_shift, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_stem_attachment, (SCM));
   DECLARE_GROB_INTERFACE();
+
   static Real stem_attachment_coordinate (Grob *, Axis a);
   static int get_balltype (Grob *);
 
index 12ba90a8fe5edbce261e4f172250c9a73824833a..157ce77bf7ddb7273b05c88bcf6f3ff43406fcc8 100644 (file)
@@ -24,6 +24,7 @@ public:
   DECLARE_GROB_INTERFACE();
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM));
 };
 
index 31747b1d431cdc7c03411e026d076f81aa1ec3e2..5dadbacaf736f6503cf7e444c4bc448324556ad1 100644 (file)
@@ -9,8 +9,7 @@
 #ifndef SKYLINE_HH
 #define SKYLINE_HH
 
-#include <list>
-
+#include "lily-proto.hh"
 #include "axis.hh"
 #include "box.hh"
 #include "interval.hh"
@@ -18,6 +17,8 @@
 #include "std-vector.hh"
 #include "smobs.hh"
 
+#include <list>
+
 struct Building
 {
   Real end_;
@@ -47,16 +48,19 @@ private:
   list<Building> internal_build_skyline (list<Box>*, Real, Axis, Direction);
 
   DECLARE_SIMPLE_SMOBS(Skyline);
+
 public:
   Skyline ();
   Skyline (Skyline const &src);
   Skyline (Direction sky);
   Skyline (vector<Box> const &bldgs, Real horizon_padding, Axis a, Direction sky);
   Skyline (Box const &b, Real horizon_padding, Axis a, Direction sky);
+  
   vector<Offset> to_points (Axis) const;
   void merge (Skyline const &);
   void insert (Box const &, Real horizon_padding, Axis);
   void print () const;
+  void print_points () const;
   void raise (Real);
   void shift (Real);
   Real distance (Skyline const &) const;
index 6caafd73c90a503443444c71a1148dad4f122a4c..9ff982bcf854ad70e80205d455f4a2756818b3f7 100644 (file)
@@ -564,9 +564,14 @@ setup_guile_env ()
               "104857600", overwrite);
 }
 
+vector<string> start_environment_global;
 int
-main (int argc, char **argv)
+main (int argc, char **argv, char **envp)
 {
+  for (char **p = envp; *p; p++)
+    start_environment_global.push_back(*p);
+  
   if (getenv ("LILYPOND_VERBOSE"))
     be_verbose_global = true;
 
index 23e3f98e018dff05e6c8d662f7765114a7c34348..6feb71c8633f0e00f26e4f59c5bc32dbf44f4a20 100644 (file)
@@ -306,7 +306,12 @@ check_meshing_chords (Grob *me,
        far to the right.
       */
       if (Dot_column::has_interface (parent))
-       Side_position_interface::add_support (parent, nu);
+       {
+         Grob *stem = unsmob_grob (nu->get_object ("stem"));
+         extract_grob_set (stem, "note-heads", heads);
+         for (vsize i = 0; i < heads.size (); i++)
+           Side_position_interface::add_support (parent, heads[i]);
+       }
     }
 
   Direction d = UP;
@@ -502,6 +507,23 @@ Note_collision_interface::automatic_shift (Grob *me,
     }
   while ((flip (&d)) != UP);
 
+
+  /*
+    see input/regression/dot-up-voice-collision.ly
+   */
+  for (vsize i = 0; i < clash_groups[UP].size (); i++)
+    {
+      Grob *g = clash_groups[UP][i];
+      Grob *dc = Note_column::dot_column (g);
+      
+      if (dc)
+       for (vsize j = i + 1;  j < clash_groups[UP].size (); j++)
+         {
+           Grob *stem = Note_column::get_stem (clash_groups[UP][j]);
+           Side_position_interface::add_support (dc, stem);
+         }
+    }
+  
   /*
     Check if chords are meshing
   */
index 380182f85623cd74fca631b1d04a4715bc02fcf1..3f57d3e63c888b09fb564849aa3809b4307366b3 100644 (file)
@@ -181,6 +181,20 @@ Note_column::accidentals (Grob *me)
   return acc;
 }
 
+Grob *
+Note_column::dot_column (Grob *me)
+{
+  extract_grob_set (me, "note-heads", heads);
+  for (vsize i = 0; i < heads.size (); i++)
+    {
+      Grob *dots = unsmob_grob (heads[i]->get_object ("dot"));
+      if (dots)
+       return dots->get_parent (X_AXIS);
+    }
+  
+  return 0;
+}
+
 Grob *
 Note_column::arpeggio (Grob *me)
 {
index 8e142179b4f2fbc211cc961ac534eb800a497a27..6db959113e846e182fb0d724956b8dc62a0ffa25 100644 (file)
@@ -42,6 +42,20 @@ Script_interface::get_stencil (Grob *me, Direction d)
   return Stencil ();
 }
 
+MAKE_SCHEME_CALLBACK (Script_interface, calc_positioning_done, 1);
+SCM
+Script_interface::calc_positioning_done (SCM smob)
+{
+  Grob *me = unsmob_grob (smob);
+  if (Grob *par = me->get_parent (X_AXIS))
+    {
+      Grob *stem = Note_column::get_stem (par);
+      if (stem && Stem::first_head (stem))
+       me->set_parent (Stem::first_head (stem), X_AXIS);
+    }
+  return SCM_BOOL_T;
+}
+
 MAKE_SCHEME_CALLBACK (Script_interface, calc_direction, 1);
 SCM
 Script_interface::calc_direction (SCM smob)
@@ -55,13 +69,7 @@ Script_interface::calc_direction (SCM smob)
       d = DOWN;
     }
 
-  if (Grob *par = me->get_parent (X_AXIS))
-    {
-      Grob *stem = Note_column::get_stem (par);
-      if (stem && Stem::first_head (stem))
-       me->set_parent (Stem::first_head (stem), X_AXIS);
-    }
-
+  (void) me->get_property ("positioning-done");
   return scm_from_int (d);
 }
 
@@ -108,6 +116,7 @@ ADD_INTERFACE (Script_interface,
               "An object that is put above or below a note",
               "add-stem-support "
               "avoid-slur "
+              "positioning-done "
               "script-priority "
               "script-stencil "
               "slur "
index e55ba3a6637024de8e0a9fb36b28e53298d2098f..c935660c6ed33b400cdf2b002fc0a79f886474ab 100644 (file)
@@ -59,6 +59,16 @@ Skyline::print () const
   print_buildings (buildings_);
 }
 
+void
+Skyline::print_points () const
+{
+  vector<Offset> ps (to_points (X_AXIS));
+
+  for (vsize i = 0; i < ps.size (); i++)
+    printf ("(%f,%f)%s" , ps[i][X_AXIS], ps[i][Y_AXIS],
+           (i%2)==1 ? "\n" : " ");
+}
+
 Building::Building (Real start, Real start_height, Real end_height, Real end)
 {
   if (isinf (start) || isinf (end))
@@ -497,7 +507,7 @@ Skyline::set_minimum_height (Real h)
 
 
 vector<Offset>
-Skyline::to_points (Axis a) const
+Skyline::to_points (Axis horizon_axis) const
 {
   vector<Offset> out;
 
@@ -510,9 +520,9 @@ Skyline::to_points (Axis a) const
       start = i->end_;
     }
 
-  if (a == Y_AXIS)
+  if (horizon_axis == Y_AXIS)
     for (vsize i = 0; i < out.size (); i++)
-      out[i] = Offset (out[i][Y_AXIS], out[i][X_AXIS]);
+      out[i] = out[i].swapped ();
 
   return out;
 }
index 97f1cd24bfe1572c6d6f47331150c3ae7492f74a..9ef07652e33bff3df8fc314e793fbed3a4e51c11 100644 (file)
@@ -275,8 +275,6 @@ Stem::calc_stem_end_position (SCM smob)
       return me->get_property ("stem-end-position");
     }
   
-  Real ss = Staff_symbol_referencer::staff_space (me);
-  int durlog = duration_log (me);
   vector<Real> a;
 
   /* WARNING: IN HALF SPACES */
@@ -291,41 +289,6 @@ Stem::calc_stem_end_position (SCM smob)
   if (!no_extend_b && dir * stem_end < 0)
     stem_end = 0.0;
 
-  
-  /* Make a little room if we have a upflag and there is a dot.
-     previous approach was to lengthen the stem. This is not
-     good typesetting practice.  */
-  if (!get_beam (me) && dir == UP
-      && durlog > 2)
-    {
-      Grob *closest_to_flag = extremal_heads (me)[dir];
-      Grob *dots = closest_to_flag
-       ? Rhythmic_head::get_dots (closest_to_flag) : 0;
-
-      if (dots)
-       {
-         Real dp = Staff_symbol_referencer::get_position (dots);
-         Interval flag_yext = flag (me).extent (Y_AXIS) * (2 / ss) + stem_end;
-
-         /* Very gory: add myself to the X-support of the parent,
-            which should be a dot-column. */
-         
-         if (flag_yext.distance (dp) < 0.5)
-           {
-             Grob *par = dots->get_parent (X_AXIS);
-
-             if (Dot_column::has_interface (par))
-               {
-                 Side_position_interface::add_support (par, me);
-
-                 /* TODO: apply some better logic here. The flag is
-                    curved inwards, so this will typically be too
-                    much. */
-               }
-           }
-       }
-    }
-
   return scm_from_double (stem_end);
 }
 
@@ -606,6 +569,9 @@ Stem::flag (Grob *me)
       || unsmob_grob (me->get_object ("beam")))
     return Stencil ();
 
+  if (!is_normal_stem (me))
+    return Stencil ();
+  
   /*
     TODO: maybe property stroke-style should take different values,
     e.g. "" (i.e. no stroke), "single" and "double" (currently, it's
index 1492d1790b11ed6b2cf09be839b0d050c5db2e50..170bbb13eb14a081b751333dbe88ba28af75acdd 100644 (file)
@@ -121,7 +121,7 @@ export MFINPUTS:=.:$(MFINPUTS)
 
 
 
-default: $(ALL_GEN_FILES) $(outdir)/emmentaler-20.otf tree-regen
+default: $(ALL_GEN_FILES) $(outdir)/emmentaler-20.otf tree-regen $(outdir)/fonts.conf
 
 .PHONY: tree-regen
 
@@ -138,11 +138,17 @@ local-clean:
        rm -f mfplain.mem mfplain.log
        rm -f *.tfm *.log
 
+
+## fixme: why is this necessary?
 $(outdir)/%.enc.in: %.enc
        cp $< $@
 
 
+$(outdir)/fonts.conf:
+       echo '<fontconfig><dir>'$(shell cd $(outdir); pwd)'</dir></fontconfig>' > $@
+
 $(NCSB_OTFS): $(NCSB_SOURCE_FILES)  $(buildscript-dir)/pfx2ttf.fontforge
        $(foreach i, $(basename $(NCSB_SOURCE_FILES)), \
                $(FONTFORGE) -script $(buildscript-dir)/pfx2ttf.fontforge \
                        $(i).pfb $(i).afm $(outdir)/ && ) true
+
index eaefaf786752821a525cdfa406a353cbac0e18c9..c09e7572d5d3d0a77f687ca37c71e2c6e6c0bd3a 100644 (file)
@@ -8,7 +8,7 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
 ;; backend helpers.
 
-(define-public (ly:system command)
+(define-public (ly:system command . rest)
   (let* ((status 0)
         (dev-null "/dev/null")
         (silenced (if (or (ly:get-option 'verbose)
                       (format #f "~a > ~a 2>&1 " command dev-null))))
     (if (ly:get-option 'verbose)
        (ly:message (_ "Invoking `~a'...") command))
-    
-    (set! status (system silenced))
+
+    (set! status
+         (if (pair? rest)
+             (system-with-env silenced (car rest))
+             (system silenced)))
+       
     (if (> status 0)
        (begin
          (ly:message (_ "`~a' failed (~a)") command status)
          ;; hmmm.  what's the best failure option? 
          (throw 'ly-file-failed)))))
 
+(define-public (system-with-env cmd env)
+
+  "Execute CMD in fork, with ENV (a list of strings) as the environment"
+  (let*
+      ;; laziness: should use execle?
+      
+      ((pid (primitive-fork)))
+    (if (= 0 pid)
+       ;; child
+       (begin
+         (environ env)
+         (system cmd))
+       
+       ;; parent
+       (cdr (waitpid pid)))))
+
 (define-public (sanitize-command-option str)
   "Kill dubious shell quoting"
   
index d44d3412cb187499f9bc3f5cc0a924d539ef25da..82d377ccdce1b125f6b2fe54fcc7071b0c415313 100644 (file)
        (direction . ,RIGHT)
        (positioning-done . ,ly:dot-column::calc-positioning-done) 
        (X-extent . ,ly:axis-group-interface::width)
-       (X-offset . ,ly:dot-column::side-position)
        (meta . ((class . Item)
                 (interfaces . (dot-column-interface
                                axis-group-interface))))))
 
        (stencil . ,ly:text-interface::print)
        (direction . ,ly:script-interface::calc-direction)
+       (positioning-done . ,ly:script-interface::calc-positioning-done)
 
        (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
        (self-alignment-X . 0)
        (script-priority . 100)
        (stencil . ,ly:text-interface::print)
        (direction . ,ly:script-interface::calc-direction)
+       (positioning-done . ,ly:script-interface::calc-positioning-done)
+
        (text . ,fingering::calc-text) 
        (font-encoding . fetaNumber)
        (font-size . -5)                ; don't overlap when next to heads.
 
        ;; padding set in script definitions.
        (staff-padding . 0.25)
-       (X-offset . ,ly:self-alignment-interface::centered-on-x-parent)
+       (X-offset . ,script-interface::calc-x-offset)
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
        (side-axis . ,Y)
 
        (stencil . ,ly:script-interface::print)
        (direction . ,ly:script-interface::calc-direction)
+       (positioning-done . ,ly:script-interface::calc-positioning-done)
        (font-encoding . fetaMusic)
        (cross-staff . ,ly:script-interface::calc-cross-staff)
        (meta . ((class . Item)
 
        (stencil . ,ly:text-interface::print)
        (direction . ,ly:script-interface::calc-direction)
+       (positioning-done . ,ly:script-interface::calc-positioning-done)
 
        (outside-staff-priority . 450)
        (avoid-slur . around)
index 3cfefc8f3e58f53aac4f323105d7f769fb32d3ef..eea76143769952258f68b3dd449f889a1d20b7f1 100644 (file)
@@ -676,3 +676,10 @@ centered, X==1 is at the right, X == -1 is at the left."
     (grob-interpret-markup grob
                           (make-fret-diagram-verbose-markup
                            (string-frets->description string-frets string-count)))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; scripts
+
+(define-public (script-interface::calc-x-offset grob)
+  (ly:grob-property grob 'positioning-done)
+  (ly:self-alignment-interface::centered-on-x-parent grob))
index 2e3f2afe654fb0bb4d3ba8101483b6b7ce0da995..12657af88a2974aac5d5c18f7ba4f8c673578c7b 100644 (file)
    ly:cluster::print
    ly:cluster-beacon::height
    ly:custos::print
-   ly:dot-column::side-position
    ly:dots::print
    ly:hairpin::print
    ly:hara-kiri-group-spanner::force-hara-kiri-callback