Re: Merging different fonts

2004-03-16 Thread Doug Linhardt
Douglas A Linhardt wrote:

Han-Wen,

On 3/15/2004 12:20 PM, Han-Wen Nienhuys wrote:
 

The other properties reflect some guitar and piano practices.  I don't
see use of a merge-different-style, so please leave it out for now. We
can always put it back in later.
   

No problem.  Thanks for the feedback.

 

I haven't integrated your previous patch due to the questions I
had. Could you (re)implement the functionality as you would do it now,
and send me the patch, so I can apply it to the CVS repo?  Thanks!
   

I should be able to do it tonight.  I'll get it to you as soon as it's done.

Doug

After removing the merge-differently-headed, the documentation didn't 
need to be changed, and I didn't need to a properties.  It turns out all 
I needed is:

--- note-collision.cc   2004-03-15 20:47:15.0 -0600
+++ ../../lilypond-2.1.31/lily/note-collision.cc2004-03-15 
20:52:46.0 -0600
@@ -71,6 +71,11 @@
  // FIXME: what's this?
  bool merge_possible = (ups[0] >= dps[0]) && (ups.top () >= dps.top ());
   

+  /* Do not merge notes typeset in different fonts */
+  if ( ! gh_equal_p (nu->get_property ("style"),
+   nd->get_property ("style") ) )
+merge_possible = false;
+
  int upball_type = Note_head::get_balltype (nu);
  int dnball_type = Note_head::get_balltype (nd);


___
Lilypond-devel mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-devel


Merging different fonts

2004-03-11 Thread Doug Linhardt
When running lilypond (I'm using 2.1.27), if you have 2 voices with 
different note head styles (fonts), the program will merge colliding 
notes, losing one of the fonts.  The problem is shown in this example:

\score { \notes { << { d'4 c'4 }
   \\ \override NoteHead #'style = #'diamond
   { c'4 c'4 } >> r2 } }
\paper {
   indent = 0.0\mm
   raggedright = ##t
}
I created a patch.  I also added a property (merge-differently-fonted) 
to allow the original behavior.  The patch includes the source files as 
well as the user manual.  I also created a file for the regression 
tests.  Below are the 1. the patch, and 2. the regression test.  I've 
been following the mailing list for a few weeks now, and I think this is 
the format you want (diff -u, no attachments, etc.).  If you want 
something else, let me know.

Doug Linhardt

1. The patch

--- ../lilypond-2.1.27/./lily/note-head.cc  2004-03-07 
17:03:28.0 -0600
+++ ./lily/note-head.cc 2004-03-07 17:03:28.0 -0600
@@ -121,16 +121,13 @@
Stencil
internal_print (Grob *me, bool with_ledgers)
{
-  SCM style  = me->get_property ("style");
-  if (!gh_symbol_p (style))
+  String font_name = Note_head::get_font_name(me);
+  if (font_name == "")
{
  return Stencil ();
}

-  SCM log = gh_int2scm (Note_head::get_balltype (me));
-  SCM proc = me->get_property ("glyph-name-procedure");
-  SCM scm_font_char = scm_call_2 (proc, log, style);
-  String font_char = "noteheads-" + ly_scm2string (scm_font_char);
+  String font_char = "noteheads-" + font_name;
  Font_metric * fm = Font_interface::get_default_font (me);
  Stencil out = fm->find_by_name (font_char);
@@ -272,6 +269,23 @@
  return m.smobbed_copy ();
}
+String
+Note_head::get_font_name(Grob* me)
+{
+  String ret_val = "";
+
+  SCM style  = me->get_property ("style");
+  if (gh_symbol_p (style))
+{
+  SCM log = gh_int2scm (Note_head::get_balltype (me));
+  SCM proc = me->get_property ("glyph-name-procedure");
+  SCM scm_font_char = scm_call_2 (proc, log, style);
+  ret_val = ly_scm2string (scm_font_char);
+}
+
+ return ret_val;
+}
+
Real
Note_head::stem_attachment_coordinate (Grob *me, Axis a)
@@ -281,16 +295,13 @@
  
  if (brewer == Note_head::print_proc)
{
-  SCM style  = me->get_property ("style");
-  if (!gh_symbol_p (style))
-   {
- return 0.0;
-   }
-
-  SCM log = gh_int2scm (Note_head::get_balltype (me));
-  SCM proc = me->get_property ("glyph-name-procedure");
-  SCM scm_font_char = scm_call_2 (proc, log, style);
-  String font_char = "noteheads-" + ly_scm2string (scm_font_char);
+  String font_name = get_font_name(me);
+  if (font_name == "")
+{
+  return 0.0;
+}
+
+  String font_char = "noteheads-" + font_name;

  int k = fm->name_to_index (font_char) ;

--- ../lilypond-2.1.27/./lily/note-collision.cc 2004-03-07 
17:03:28.0 -0600
+++ ./lily/note-collision.cc2004-03-07 17:03:28.0 -0600
@@ -71,6 +71,8 @@

  int upball_type = Note_head::get_balltype (nu);
  int dnball_type = Note_head::get_balltype (nd);
+  String up_font = Note_head::get_font_name (nu);
+  String dn_font = Note_head::get_font_name (nd);
  
  /* Do not merge whole notes (or longer, like breve, longa, maxima).  */
  if (merge_possible && (upball_type <= 0 || dnball_type <= 0))
@@ -88,6 +90,13 @@
  && !to_boolean (me->get_property ("merge-differently-headed")))
merge_possible = false;

+  /* Can only merge different fonts if merge-differently-fonted is
+ set. */
+  if (merge_possible
+  && up_font != dn_font
+  && !to_boolean (me->get_property ("merge-differently-fonted")))
+merge_possible = false;
+
  /* Should never merge quarter and half notes, as this would make
 them indistinguishable.  */
  if (merge_possible
@@ -474,4 +483,4 @@
  ,
  
-  "merge-differently-dotted merge-differently-headed 
positioning-done");
+  "merge-differently-dotted merge-differently-headed 
merge-differently-fonted positioning-done");
--- ../lilypond-2.1.27/./lily/include/note-head.hh  2004-03-07 
17:03:28.0 -0600
+++ ./lily/include/note-head.hh 2004-03-07 17:03:28.0 -0600
@@ -29,6 +29,7 @@
  static bool has_interface (Grob*);
  static Real stem_attachment_coordinate (Grob *, Axis a);
  static int get_balltype (Grob*) ;
+  static String get_font_name (Grob*) ;
};
#endif // NOTEHEAD_HH

--- ../lilypond-2.1.27/./scm/define-grob-properties.scm 2004-03-07 
17:03:28.0 -0600
+++ ./scm/define-grob-properties.scm2004-03-07 17:03:28.0 -0600
@@ -338,6 +338,10 @@
notation for some types of polyphonic