]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/output-lib.scm (note-head-style->attachment-coordinates):
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 30 Dec 2003 15:40:24 +0000 (15:40 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 30 Dec 2003 15:40:24 +0000 (15:40 +0000)
change calling convention of stem-attachment function.

* buildscripts/mf-to-table.py: read and dump WX/WY fields

* mf/feta-autometric.mf: dump WX/WY fields too

* mf/parmesan-heads.mf: idem.

* mf/feta-bolletjes.mf (slash_slope): set WX/WY fields for
attachment coordinates.

* lily/note-head.cc (stem_attachment_coordinate): read stem
attachment from the notehead glyphs WX/WY fields.

* lily/include/font-metric.hh (struct Font_metric): add methods
get_indexed_wxwy (), make a distinction between looking up by
index and ASCII

* mf/feta-bolletjes.mf: rewrite note head MF code.
(test_outlines): make heads more rotund for smaller sizes.

22 files changed:
ChangeLog
Documentation/topdocs/NEWS.texi
Documentation/topdocs/README.texi
buildscripts/mf-to-table.py
lily/afm.cc
lily/font-metric.cc
lily/include/afm.hh
lily/include/font-metric.hh
lily/include/scaled-font-metric.hh
lily/include/tfm.hh
lily/include/virtual-font-metric.hh
lily/note-head.cc
lily/scaled-font-metric.cc
lily/stem.cc
lily/system-start-delimiter.cc
lily/tfm.cc
lily/virtual-font-metric.cc
mf/feta-autometric.mf
mf/feta-bolletjes.mf
mf/parmesan-heads.mf
scm/define-grob-properties.scm
scm/output-lib.scm

index bf26638ba98822b065d333cc9f5772f6802528a4..e93695117bf5d41a1cb07827551381f2bacd3bc5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2003-12-30  Han-Wen Nienhuys   <hanwen@cs.uu.nl>
 
+       * scm/output-lib.scm (note-head-style->attachment-coordinates):
+       change calling convention of stem-attachment function. 
+
+       * buildscripts/mf-to-table.py: read and dump WX/WY fields
+
+       * mf/feta-autometric.mf: dump WX/WY fields too
+       
+       * mf/parmesan-heads.mf: idem.
+
+       * mf/feta-bolletjes.mf (slash_slope): set WX/WY fields for
+       attachment coordinates.
+
+       * lily/note-head.cc (stem_attachment_coordinate): read stem
+       attachment from the notehead glyphs WX/WY fields.
+
+       * lily/include/font-metric.hh (struct Font_metric): add methods
+       get_indexed_wxwy (), make a distinction between looking up by
+       index and ASCII  
+
        * mf/feta-bolletjes.mf: rewrite note head MF code.
        (test_outlines): make heads more rotund for smaller sizes. 
 
index 496e209603cbffc50ff2034685705f5743c368a9..f4d34e8f2c26b5866cea571886bfec3347749cc5 100644 (file)
@@ -8,6 +8,12 @@
 @chapter New features in 2.1 since 2.0
 
 @itemize
+@item
+The weight of the stafflines is now heavier at smaller staff sizes.
+To match this, the font has been revamped completely for looking: the
+font is now much heavier for smaller sizes, and the note heads are
+more rounded in smaller sizes.
+
 @item Processing scores is now done while parsing the file. New
 Scheme functions give more flexibility: for example, it is now possible
 interpret a score, collecting synchronized musical events in a list, and
index 10588b6c81773e7377419e8933f75a19bf9210ca..f920937325f3a4040d31bfc492d711b7524e1b71 100644 (file)
@@ -8,8 +8,8 @@
 @chapter Toplevel README
 
 
-LilyPond  is a music  typesetter.  It  produces beautiful  sheet music
-using  a description  file as  input.   LilyPond  is  part of  the  GNU
+LilyPond is a music typesetter.  It produces beautiful sheet music
+using a description file as input.  LilyPond is part of the GNU
 Project.
 
 @section Versioning
@@ -21,7 +21,7 @@ For development versions 'y' is odd.
 @section Downloading
 
 The primary download site for sourcecode is
-@uref{ftp://ftp.lilypond.org/pub/LilyPond/}.
+@uref{http://lilypond.org/download/}.
 
 If you have a slow connection, then you are advised to use
 @uref{http://sourceforge.net/projects/xdelta/,xdelta} for patching
@@ -33,7 +33,7 @@ For compiling and running LilyPond see the installation instructions.
 These instructions can be found when you unpack lilypond, as
 @file{lilypond-x.y.z/INSTALL.txt}. They are also available on the web
 at
-@uref{http://lilypond.org/Documentation/topdocs/out-www/INSTALL.html}.
+@uref{http://lilypond.org/doc/v2.1/Documentation/topdocs/out-www/INSTALL.html}.
 
 NOTE: If you downloaded a binary (@file{.rpm}) or use the Cygwin
 @file{setup.exe} program, then you don't have to compile LilyPond.
@@ -42,7 +42,7 @@ NOTE: If you downloaded a binary (@file{.rpm}) or use the Cygwin
 @section Documentation
 
 The documentation is available online at
-@uref{http://www.lilypond.org/doc/v1.9/Documentation/out-www/}.
+@uref{http://www.lilypond.org/doc/}.
 
 You can also build it locally: follow the instructions under `Building
 documentation' in the installation instructions.
index cf3d4b08c2873ea45bfd33e656840ce51f9f7a89..c3051019a0fd32675410be1f1d8b2fdbce390fbc 100644 (file)
@@ -72,13 +72,15 @@ def parse_logfile (fn):
                elif tags[0] == 'char':
                        m = {
                                'description':  tags[1],
-                               'name': group + '-' + tags[7],
-                               'tex': tags[8],
+                               'name': group + '-' + tags[9],
+                               'tex': tags[10],
                                'code': string.atoi (tags[2]),
                                'breapth':string.atof (tags[3]),
                                'width': string.atof (tags[4]),
                                'depth':string.atof (tags[5]),
-                               'height':string.atof (tags[6])
+                               'height':string.atof (tags[6]),
+                               'wx': string.atof (tags[7]),
+                               'wy':string.atof (tags[8]),
                                }
                        charmetrics.append (m)
                elif tags[0] == 'font':
@@ -110,15 +112,15 @@ def write_afm_char_metric(file, charmetric):
 
        f = 1000;
        tup = (charmetric['code'],
-              (charmetric['width'] + charmetric['breapth'])*f,
                charmetric['name'],
                -charmetric['breapth'] *f,
                -charmetric['depth']*f,
                charmetric['width']*f,
-               charmetric['height']*f)
+               charmetric['height']*f,
+              charmetric['wx'] * f,
+              charmetric['wy'] * f)
        
-       
-       file.write ('C %d ; WX %d ; N  %s ;  B %d %d %d %d ;\n'% tup)
+       file.write ('C %d ; N %s ; B %d %d %d %d ; W %d %d ;\n'% tup)
 
 def write_afm_header (file):
        file.write ("StartFontMetrics 2.0\n")
index 5510c8fe75e0956af51decd139f554a9f91937ee..1ba31b7b8b4b5f1c8c0088d90c7f76ace0c30454 100644 (file)
@@ -7,13 +7,11 @@
   
  */
 
-#ifndef _GNU_SOURCE // we want memmem
-#define _GNU_SOURCE
-#endif
 #include <string.h>
+
+#include "warn.hh"             // error()
 #include "libc-extension.hh"
 #include "afm.hh"
-#include "warn.hh"
 #include "molecule.hh"
 #include "dimensions.hh"
 
@@ -51,7 +49,7 @@ Adobe_font_metric::make_afm (AFM_Font_info *fi, unsigned int checksum)
 
 
 AFM_CharMetricInfo const *
-Adobe_font_metric::find_ascii_metric (int a , bool warn) const
+Adobe_font_metric::find_ascii_metric (int a) const
 {
   if (ascii_to_metric_idx_[a] >=0)
     {
@@ -61,29 +59,31 @@ Adobe_font_metric::find_ascii_metric (int a , bool warn) const
          return font_inf_->cmi + code;
        }
     }
-  else if (warn)
-    {
-      warning (_f ("can't find character number: %d", a));
-    }
 
   return 0;
 }
 
+
+
 AFM_CharMetricInfo const *
-Adobe_font_metric::find_char_metric (String nm, bool warn) const
+Adobe_font_metric::find_char_metric (String nm) const
+{
+  int idx = name_to_index (nm);
+  if (idx >= 0)
+    return font_inf_->cmi+ idx;
+  else
+    return 0;
+}
+
+int
+Adobe_font_metric::name_to_index (String nm)const 
 {
   std::map<String,int>::const_iterator ai = name_to_metric_dict_.find (nm);
   
   if (ai == name_to_metric_dict_.end ())
-    {
-      if (warn)
-       {
-         warning (_f ("can't find character called: `%s'", nm.to_str0 ()));
-       }
-      return 0;
-    }
+    return -1;
   else
-    return font_inf_->cmi + (*ai).second;
+    return (*ai).second; 
 }
 
 int
@@ -93,10 +93,10 @@ Adobe_font_metric::count () const
 }
 
 Box
-Adobe_font_metric::get_char (int code) const
+Adobe_font_metric::get_ascii_char (int code) const
 {
   AFM_CharMetricInfo const
-    * c =  find_ascii_metric (code,false);
+    * c =  find_ascii_metric (code);
   Box b (Interval (0,0),Interval (0,0));
   if (c)
     b = afm_bbox_to_box (c->charBBox);                 
@@ -104,6 +104,16 @@ Adobe_font_metric::get_char (int code) const
   return b;
 }
 
+
+Box
+Adobe_font_metric::get_indexed_char (int code) const
+{
+  if (code>= 0)
+    return afm_bbox_to_box (font_inf_->cmi[code].charBBox);
+  else
+    return   Box (Interval (0,0),Interval (0,0));
+}
+
 SCM
 read_afm_file (String nm)
 {
@@ -113,12 +123,6 @@ read_afm_file (String nm)
 
   unsigned int cs = 0;
 
-#if 0
-  fread (s, sizeof (s), sizeof (*s), f);
-  if (char const* p = (char const *)
-      memmem (s, sizeof (s), check_key, strlen (check_key)))
-    sscanf (p + strlen (check_key), "%ud", &cs);
-#else
   s[0] = 0;
   /* Assume check_key in first 10 lines */
   for (int i = 0; i < 10; i++)
@@ -130,7 +134,6 @@ read_afm_file (String nm)
          break;
        }
     }
-#endif
   
   rewind (f);
     
@@ -159,7 +162,15 @@ afm_bbox_to_box (AFM_BBox bb)
              Interval (bb.lly, bb.ury)* (1/1000.0) PT);
 
 }
-  
+
+Offset
+Adobe_font_metric::get_indexed_wxwy (int k)const
+{
+  AFM_CharMetricInfo const *mi = font_inf_->cmi+ k;
+  return 1/1000.0 PT * Offset (mi->wx, mi->wy); 
+}
+
+
 
 Adobe_font_metric::~Adobe_font_metric ()
 {
@@ -172,7 +183,7 @@ Adobe_font_metric::~Adobe_font_metric ()
 Molecule
 Adobe_font_metric::find_by_name (String s) const
 {
-  AFM_CharMetricInfo const *cm = find_char_metric (s, false);
+  AFM_CharMetricInfo const *cm = find_char_metric (s);
 
   if (!cm)
     {
index 52933a503c960c42142ce24d9dbe7fa27ffb1840..37fc1c80e29cb51609838d81d068ca1ab51550f8 100644 (file)
@@ -11,6 +11,7 @@
 #include <math.h>
 #include <ctype.h>
 
+#include "virtual-methods.hh"
 #include "warn.hh"
 #include "molecule.hh"
 #include "ly-smobs.icc"
@@ -56,11 +57,11 @@ Font_metric::text_dimension (String text) const
          break;
        
        default: 
-         Box b = get_char ((unsigned char)text[i]);
+         Box b = get_ascii_char ((unsigned char)text[i]);
          
          // Ugh, use the width of 'x' for unknown characters
          if (b[X_AXIS].length () == 0) 
-           b = get_char ((unsigned char)'x');
+           b = get_ascii_char ((unsigned char)'x');
          
          w += b[X_AXIS].length ();
          ydims.unite (b[Y_AXIS]);
@@ -97,11 +98,29 @@ Font_metric::count () const
 }
 
 Box 
-Font_metric::get_char (int)const
+Font_metric::get_ascii_char (int) const
 {
   return Box (Interval (0,0),Interval (0,0));
 }
 
+Box 
+Font_metric::get_indexed_char (int k) const
+{
+  return get_ascii_char(k);
+}
+
+
+int
+Font_metric::name_to_index (String) const
+{
+  return -1;
+}
+
+Offset
+Font_metric::get_indexed_wxwy (int )const
+{
+  return Offset (0,0);
+}
 
 void
 Font_metric::derived_mark ()const
@@ -109,8 +128,6 @@ Font_metric::derived_mark ()const
   
 }
 
-  
-
 SCM
 Font_metric::mark_smob (SCM s)
 {
@@ -124,7 +141,9 @@ int
 Font_metric::print_smob (SCM s, SCM port, scm_print_state *)
 {
   Font_metric *m = unsmob_metrics (s);
-  scm_puts ("#<Font_metric ", port);
+  scm_puts ("#<", port);
+  scm_puts (classname (m), port);
+  scm_puts (" ", port);
   scm_write (m->description_, port);
   scm_puts (">", port);
   return 1;
@@ -171,7 +190,7 @@ LY_DEFINE(ly_get_glyph, "ly:get-glyph", 2 , 0, 0,
   SCM_ASSERT_TYPE(fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
   SCM_ASSERT_TYPE(gh_number_p (index), index, SCM_ARG2, __FUNCTION__, "number");
 
-  return fm->get_char_molecule (gh_scm2int (index)).smobbed_copy ();
+  return fm->get_ascii_char_molecule (gh_scm2int (index)).smobbed_copy ();
 }
 
 LY_DEFINE(ly_text_dimension,"ly:text-dimension", 2 , 0, 0,
@@ -191,11 +210,21 @@ LY_DEFINE(ly_text_dimension,"ly:text-dimension", 2 , 0, 0,
 }
 
 Molecule
-Font_metric::get_char_molecule (int code)  const
+Font_metric::get_ascii_char_molecule (int code)  const
+{
+  SCM at = scm_list_n (ly_symbol2scm ("char"), gh_int2scm (code),
+                      SCM_UNDEFINED);
+  at = fontify_atom (this, at);
+  Box b = get_ascii_char (code);
+  return Molecule (b, at);
+}
+
+Molecule
+Font_metric::get_indexed_char_molecule (int code)  const
 {
   SCM at = scm_list_n (ly_symbol2scm ("char"), gh_int2scm (code),
                       SCM_UNDEFINED);
   at = fontify_atom (this, at);
-  Box b = get_char (code);
+  Box b = get_indexed_char (code);
   return Molecule (b, at);
 }
index c3bb9a8cec6bf19b2727603df929f714cb579af8..9bb7118a3167bf0595cd61b40af928ca81ded079 100644 (file)
@@ -23,10 +23,14 @@ struct Adobe_font_metric : Font_metric
 {
   AFM_Font_info * font_inf_;
 
+  virtual int name_to_index (String) const;
   virtual int count () const;
-  virtual Box get_char (int) const;
-  AFM_CharMetricInfo const *find_char_metric (String name, bool warn=true) const;
-  AFM_CharMetricInfo const *find_ascii_metric (int, bool warn=true) const;  
+  virtual Box get_ascii_char (int) const;
+  virtual Box get_indexed_char (int) const;
+  virtual Offset get_indexed_wxwy (int) const;
+  
+  AFM_CharMetricInfo const *find_char_metric (String name) const;
+  AFM_CharMetricInfo const *find_ascii_metric (int) const;  
 
   String to_string () const;
   ~Adobe_font_metric ();
index ca008e524c09692985785831b2386ffe5bda845e..1e1c5fa9f082e922914732d14ce976c8e809396a 100644 (file)
@@ -23,10 +23,16 @@ public:
   String path_;
   
   virtual int count () const;
-  virtual Box get_char (int ascii) const;
-  virtual Molecule get_char_molecule (int ascii) const;
+  virtual Offset get_indexed_wxwy (int) const;
+  virtual Box get_indexed_char (int index) const;
+  virtual Box get_ascii_char (int ascii) const;
   virtual Box text_dimension (String)  const;
+  virtual int name_to_index (String) const;
+
   virtual Molecule find_by_name (String) const;
+  virtual Molecule get_indexed_char_molecule (int k) const;
+  virtual Molecule get_ascii_char_molecule (int k) const;  
+  
   DECLARE_SMOBS (Font_metric,);
 private:
   Font_metric (Font_metric const&); // no copy.
@@ -39,4 +45,3 @@ protected:
 DECLARE_UNSMOB(Font_metric, metrics);
 
 #endif /* FONT_METRIC_HH */
-
index 2383c7bb099f406ea1f1ff1a8cc6a37d053ef7cb..9cbee8cb92ed82df57646c6540474c153e4310d3 100644 (file)
@@ -21,8 +21,11 @@ struct Scaled_font_metric : public Font_metric
   virtual Molecule find_by_name (String) const;
   static SCM make_scaled_font_metric (Font_metric*, Real);
   virtual int count () const;
+  virtual Offset get_indexed_wxwy (int) const;
+  virtual int name_to_index (String) const;
 protected:
-  virtual   Box get_char (int)const;
+  virtual Box get_indexed_char (int)const;
+  virtual Box get_ascii_char (int)const;
   Font_metric *orig_;
   Real magnification_;
   
index 47f79bcad998f6cb23cbc5c7d8d1c1e8698963c0..aaf955a8dd03b66771f458a1b1e9e8d60c0ed49c 100644 (file)
@@ -151,7 +151,7 @@ public:
   static  SCM make_tfm (String filename);
 
   virtual int count () const;
-  virtual Box get_char (int) const;
+  virtual Box get_ascii_char (int) const;
   Tex_font_char_metric const *find_ascii (int ascii, bool warn=true) const;
 
   String to_string () const;
index 2f6c2e690aa8b35988c4e2fac75f04ea903db16e..995a96f96a8a8b9d91c1d1356284c8b9c1a0d740 100644 (file)
@@ -20,9 +20,12 @@ public:
   Virtual_font_metric (SCM namelist, Real, Paper_def*);
 
   virtual int count () const;
-  virtual Box get_char (int ascii) const;
-  virtual Molecule get_char_molecule (int ascii) const;
-  
+  virtual Box get_indexed_char (int ascii) const;
+  virtual Box get_ascii_char (int ascii) const;
+  virtual Molecule get_indexed_char_molecule (int ascii) const;
+  virtual Molecule get_ascii_char_molecule (int ascii) const;
+  virtual Offset get_indexed_wxwy (int) const;
+  virtual int name_to_index (String)const;
   virtual Molecule find_by_name (String) const;
 
 protected:
index ede0bdb483e85b6529cb4af4d277aef0bab83add..012e7051a4430013b5a9d81ff117146f26f1c61c 100644 (file)
@@ -262,15 +262,38 @@ Note_head::brew_ez_molecule (SCM smob)
 Real
 Note_head::stem_attachment_coordinate (Grob *me, Axis a)
 {
-  SCM v = me->get_grob_property ("stem-attachment-function");
+  SCM brewer = me->get_grob_property ("molecule-callback");
+  Font_metric * fm  = Font_interface::get_default_font (me);
+  
+  if (brewer == Note_head::brew_molecule_proc)
+    {
+      SCM style  = me->get_grob_property ("style");
+      if (!gh_symbol_p (style))
+       {
+         return 0.0;
+       }
+      
+      SCM log = gh_int2scm (Note_head::get_balltype (me));
+      SCM proc = me->get_grob_property ("glyph-name-procedure");
+      SCM scm_font_char = scm_call_2 (proc, log, style);
+      String font_char = "noteheads-" + ly_scm2string (scm_font_char);
+
+      int k = fm->name_to_index (font_char);
+      Box b = fm->get_indexed_char (k);
+      Offset wxwy = fm->get_indexed_wxwy (k);
+      Interval v = b[a];
+      if (!v.empty_b ())
+       return 2 * (wxwy[a] - v.center()) / v.length ();
+    }
 
+  /*
+    Fallback
+   */
+  SCM v = me->get_grob_property ("stem-attachment-function");
   if (!gh_procedure_p (v))
     return 0.0;
-
-  SCM st = me->get_grob_property ("style");
-  SCM log = gh_int2scm (get_balltype (me));
-  SCM result = gh_apply (v, scm_list_n (st, log, SCM_UNDEFINED));
-
+  
+  SCM result = scm_call_2 (v, me->self_scm(), gh_int2scm (axis));
   if (!gh_pair_p (result))
     return 0.0;
 
@@ -278,7 +301,6 @@ Note_head::stem_attachment_coordinate (Grob *me, Axis a)
   
   return gh_number_p (result) ?  gh_scm2double (result) : 0.0;
 }
-
 int
 Note_head::get_balltype (Grob*me) 
 {
index 8583887b5855aa225ad2ae78ada741f371b15531..b34e8a7cf8bce1b6f022cffbb0f5ef47cc245cef 100644 (file)
@@ -43,9 +43,17 @@ Scaled_font_metric::find_by_name (String s) const
 }
 
 Box 
-Scaled_font_metric::get_char (int i) const
+Scaled_font_metric::get_indexed_char (int i) const
 {
-  Box b = orig_->get_char (i);
+  Box b = orig_->get_indexed_char (i);
+  b.scale (magnification_);
+  return b;  
+}
+
+Box 
+Scaled_font_metric::get_ascii_char (int i) const
+{
+  Box b = orig_->get_ascii_char (i);
   b.scale (magnification_);
   return b;  
 }
@@ -64,3 +72,16 @@ Scaled_font_metric::count () const
 {
   return orig_->count ();
 }
+
+Offset
+Scaled_font_metric::get_indexed_wxwy (int k) const
+{
+  Offset o = orig_->get_indexed_wxwy (k);
+  return o * magnification_;
+}
+
+int
+Scaled_font_metric::name_to_index (String s)const
+{
+  return orig_->name_to_index (s);
+}
index e14fc302bef1dbbfc282e5bdabfdcf764530a668..6b69ae40923f29494b72633d91ca8d600a5cee83 100644 (file)
@@ -737,7 +737,7 @@ Stem::brew_molecule (SCM smob)
        must not take ledgers into account.
        */
       Interval head_height = Note_head::head_extent (hed,Y_AXIS);
-      Real y_attach = Note_head::stem_attachment_coordinate ( hed, Y_AXIS);
+      Real y_attach = Note_head::stem_attachment_coordinate (hed, Y_AXIS);
 
       y_attach = head_height.linear_combination (y_attach);
       stem_y[Direction (-d)] += d * y_attach/dy;
@@ -786,7 +786,6 @@ Stem::off_callback (SCM element_smob, SCM)
   if (Grob * f = first_head (me))
     {
       Interval head_wid = Note_head::head_extent(f, X_AXIS);
-
       
       Real attach =0.0;
 
@@ -811,7 +810,6 @@ Stem::off_callback (SCM element_smob, SCM)
          Real rule_thick
            = gh_scm2double (me->get_grob_property ("thickness"))
            * me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
-
          
          r += - d * rule_thick * 0.5;
        }
@@ -819,6 +817,7 @@ Stem::off_callback (SCM element_smob, SCM)
   return gh_double2scm (r);
 }
 
+
 Grob*
 Stem::get_beam (Grob*me)
 {
index 4254c4b6729a960e2fe5e045ddcb93f11e5da0a0..1c68e112d4524fb116781a427a7322914217d317 100644 (file)
@@ -164,7 +164,7 @@ System_start_delimiter::staff_brace (Grob*me, Real y)
   do
     {
       int cmp = (lo + hi) / 2;
-      b = fm->get_char (cmp);
+      b = fm->get_indexed_char (cmp);
       if (b[Y_AXIS].empty_b () || b[Y_AXIS].length () > y)
        hi = cmp;
       else
@@ -172,7 +172,7 @@ System_start_delimiter::staff_brace (Grob*me, Real y)
     }
   while (hi - lo > 1);
       
-  Molecule m (fm->get_char_molecule (lo));
+  Molecule m (fm->get_indexed_char_molecule (lo)); // ugh.  ascii?
   b=m.extent_box();
   b[X_AXIS] = Interval (0,0);
 
index df8d2d0dbcb623d90ad3704c723ffcdb58be2d25..1086ad1551f5bc3b2514d175b9ecc61baa472799 100644 (file)
@@ -101,13 +101,12 @@ Tex_font_metric::count () const
 }
 
 Box
-Tex_font_metric::get_char (int a) const
+Tex_font_metric::get_ascii_char (int a) const
 {
   Box b = find_ascii (a)->dimensions () ;
   return b;
 }
 
-
 String
 Tex_font_metric::to_string () const
 {
index 7b66c5bfc126b130474aa50d1c9a2e292b6eaf07..1bf489302c0486aa0a602a5cd8afa7d5872ca0fa 100644 (file)
@@ -7,9 +7,9 @@ source file of the GNU LilyPond music typesetter
 
  */
 
+#include "warn.hh"
 #include "virtual-font-metric.hh"
 #include "all-font-metrics.hh"
-#include "main.hh"
 #include "molecule.hh"
 #include "paper-def.hh"
 
@@ -65,40 +65,91 @@ Virtual_font_metric::find_by_name (String glyph) const
   
 
 Box
-Virtual_font_metric::get_char (int code)  const
+Virtual_font_metric::get_ascii_char (int)  const
 {
-  int last_k = 0;
+  programming_error ("Virtual font metric cannot be indexed by ASCII.");
+  return Box();
+}
+
+Molecule
+Virtual_font_metric::get_ascii_char_molecule (int )  const
+{
+  programming_error ("Virtual font metric cannot be indexed by ASCII.");
+  return Molecule();
+}
+
+
+Offset
+Virtual_font_metric::get_indexed_wxwy (int code)  const
+{
+  int total = 0;
   for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
     {
       Font_metric* fm = unsmob_metrics (gh_car (s));
-      int k = last_k + fm->count ();
-      if (last_k <= code && code < k)
+      if (code < total + fm->count ())
        {
-         return fm->get_char (code - last_k);
+         return fm->get_indexed_wxwy (code - total);
        }
-      last_k = k;
+      total += fm->count ();
     }
 
   
-  return Box();
+  return Offset (0,0);
 }
+
+Box
+Virtual_font_metric::get_indexed_char (int code)  const
+{
+  int total = 0;
+  for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
+    {
+      Font_metric* fm = unsmob_metrics (gh_car (s));
+      if (code < total + fm->count ())
+       {
+         return fm->get_indexed_char (code - total);
+       }
+      total += fm->count ();
+    }
+
   
+  return Box();
+}
+
+
+int 
+Virtual_font_metric::name_to_index (String glyph) const
+{
+  Molecule m;
+  int total = 0; 
+  for (SCM s = font_list_; m.empty_b () && gh_pair_p (s); s = gh_cdr (s))
+    {
+      Font_metric *m =unsmob_metrics (gh_car (s));
+      int k = m->name_to_index (glyph);
+      if (k >= 0)
+       return total + k;
+
+      total += m->count ();
+    }
+
+  return -1;
+}
+
   
 Molecule
-Virtual_font_metric::get_char_molecule (int code)  const
+Virtual_font_metric::get_indexed_char_molecule (int code)  const
 {
   Molecule  m ;  
-  int last_k = 0;
+  int total = 0;
+  
   for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
     {
       Font_metric* fm = unsmob_metrics (gh_car (s));
-      int k = last_k + fm->count ();
-      if (last_k <= code && code < k)
+      if (code < total + fm->count())
        {
-         m = fm->get_char_molecule (code - last_k);
+         m = fm->get_indexed_char_molecule (code - total); // ugh.
          break; 
        }
-      last_k = k;
+      total += fm->count ();
     }
 
   return m;
index f8dc9bd94408d783c83484da7bbe22531cc23c6c..e30d6cc9c53b8c18eabe4b40cef03823368dad22 100644 (file)
@@ -43,7 +43,7 @@ def fet_endgroup(expr name) =
 enddef;
 
 def autometric_output_char=
-       message "@{char@:"&charnamestr&"@:"&decimal charcode&"@:"&decimal charbp&"@:"&decimal charwd&"@:"&decimal chardp&"@:"&decimal charht&"@:"&idstr&"@:"&texstr&"@}";
+       message "@{char@:"&charnamestr&"@:"&decimal charcode&"@:"&decimal charbp&"@:"&decimal charwd&"@:"&decimal chardp&"@:"&decimal charht&"@:"&decimal charwx&"@:"&decimal charwy&"@:"&idstr&"@:"&texstr&"@}";
 enddef;
 
 def hround_pixels(expr sharped) = hround(sharped * hppp) enddef;
@@ -73,6 +73,9 @@ def set_char_box(expr b_sharp, w_sharp, d_sharp,h_sharp) =
        b := hround(b_sharp *hppp);
        h := hround(h_sharp *vppp);
        d := hround(d_sharp *vppp);
+
+       charwx := charwd;
+       charwy := 0;
 enddef;
 
 def no_dimen_beginchar(expr c) =
@@ -103,6 +106,8 @@ def fet_beginchar(expr name, id_lit, texstr_lit) =
        save texstr, idstr, charnamestr;
        save charbp;
        save w,b,h,d;
+       save charwx, charwy;
+
        string texstr, idstr, charnamestr;
        texstr := texstr_lit;
        charnamestr := name;
index 0a9dc06aa0039377471f39e86e102d088b4ba544..0fde3f0f448e6878c0e1efb3442138a54acfb7fb 100644 (file)
@@ -31,6 +31,7 @@ noteheight#:=staff_space#+ (1 + overdone_heads) *stafflinethickness#;
 
 def draw_outside_ellipse (expr ellipsidity, tilt, superness,
                        slant) =
+       save attachment_y;
        save p;
        path p;
 
@@ -54,6 +55,10 @@ def draw_outside_ellipse (expr ellipsidity, tilt, superness,
        
        set_char_box (0, width#, noteheight#/2, noteheight#/2);
 
+       % attachment Y
+       charwy := ypart (right_point) * scaling#;
+       charwx := xpart (right_point) * scaling#;
+
        p := p scaled scaling shifted (width/2, 0) ;
        if test_outlines = 1:
                pickup pencircle scaled 1 ; draw p;
@@ -304,6 +309,9 @@ def draw_slash(expr hwid_hash) =
                        staff_space#/2 + stafflinethickness#/2,
                        staff_space#/2 + stafflinethickness#/2);
 
+       charwx := charwd;
+       charwy := charht;
+
        clearxy;
        pickup pencircle scaled blot_diameter;
 
@@ -358,29 +366,48 @@ fet_endchar;
 
 % thick is the distance between the two parallel lines in the cross (distance between centres of lines)
 def draw_cross(expr thick) =
-       pent := 1.2stafflinethickness;
-       pickup pencircle scaled pent;
-       % alfa is the slant of the lines (i.e. 1 means 45 degrees)
-       alfa := (2h-pent)/(w-pent);
-       % llen is the length of the little outer lines
-       % llen = thick / sin(2atan(alfa))
-       llen := thick/(ypart(dir(2angle(1,alfa))));
-       xa := llen/sqrt(1+alfa**2);
-       ya := xa*alfa;
-       xl := w/2-xa-pent/2;
-       yl := h-ya-pent/2;
+       save pent, slant, ne_dir;
+       pair ne_dir;
        save crz; path crz;
-       crz = (xa,0) -- (xa+xl,yl) -- (xl,yl+ya) -- (0,ya);
+
+       pent# := 1.2stafflinethickness#;
+       define_pixels (pent);
+       pickup pencircle scaled pent;
+
+       top y3 = h;
+       ne_dir := (1, (2 h -pent)/(w - pent));
+       rt x4 = w/2;
+       y5 = 0;
+       z4 - z5 = whatever * ne_dir;
+       x6 = 0;
+       z6 - z3 = whatever * ne_dir;
+       z3 - z4 = whatever * (ne_dir yscaled -1);
+
+       z1 = (0, charht - 1.5 pent#);
+       y2 = 0;
+       z2 = z1 + whatever * (ne_dir yscaled -1);
+       z7 = z2 + whatever * ne_dir;
+       x7 = charwd/2 - .5 pent#;
+       top y6 = h - pent;
+
+       
+       labels (1,2,3,4,5,6);
+
+       crz = (z6 -- z3 -- z4 -- z5) ;
        draw crz shifted(w/2,0);
        draw crz xscaled -1 shifted(w/2,0);
        draw crz yscaled -1 shifted(w/2,0);
        draw crz scaled -1 shifted(w/2,0);
+
+       charwx := charwd;
+       charwy := y7;
 enddef;
 
 fet_beginchar("Whole Crossed notehead", "0cross", "wholecrossedhead")
        wid# := black_notehead_width#+4stafflinethickness#;
        hei# := noteheight#+stafflinethickness#;
        set_char_box(0, wid#,hei#/2,hei#/2);
+       
        draw_cross(3.75stafflinethickness);
 fet_endchar;
 
@@ -411,6 +438,9 @@ fet_beginchar("X-Circled notehead", "2xcircle", "xcircledhead")
        ypos := cyr/sqrt2;
        draw (-xpos+w/2,-ypos) -- (xpos+w/2,ypos);
        draw (-xpos+w/2,ypos) -- (xpos+w/2,-ypos);
+
+       charwx := 3/4 charwd ; 
+       charwy := 1/4 charwd ; 
 fet_endchar;
 
 
index ca00403fcecbfcad7f96c849f50d171e319a7451..31cfab73124b72354d0801fb82d3c6ca67325d5a 100644 (file)
@@ -144,7 +144,8 @@ def draw_neo_mensural_black_head (expr wid) =
        save head_width;
        head_width# = wid;
        set_char_box (0, head_width#, noteheight#/2, noteheight#/2);
-
+       charwx := head_width# / 2;
+       charwy := noteheight# / 2;
 
        y3 = y1 =0;
        x2 = x4 = (x1 + x3) /2;
@@ -242,7 +243,10 @@ def draw_diamond_head (expr head_h, pen_w, pen_h, angle, open) =
       define_pixels(head_width, head_height);
 
       set_char_box (0, head_width#,
-                   head_height#/2, head_height#/2);
+       head_height#/2, head_height#/2);
+      
+      charwx := head_width# / 2;
+      charwy := head_height# / 2 - stafflinethickness#;
 
       pickup pencircle
             xscaled (min(blot_diameter, pen_w * head_width))
index 7f75bfb9d93e476b526782d94916116203991a7d..878968ef8b1860be2109db63be665037ea1dd3b8 100644 (file)
@@ -421,10 +421,12 @@ itself.  Return value is ignored.")
 
 (grob-property-description 'staffline-clearance ly:dimension? "don't get closer than this to stafflines.")
 (grob-property-description 'stem ly:grob? "pointer to Stem object.")
+
 (grob-property-description 'stem-attachment-function procedure? "Where
-does the stem attach to the notehead? Function takes a symbol argument
-being the style. It returns a (X . Y) pair, specifying location in
-terms of note head bounding box.")
+does the stem attach to the notehead? Function takes grob and axis as
+arguments. It returns a (X . Y) pair, specifying location in terms of
+note head bounding box.")
+
 (grob-property-description 'stem-end-position number? "Where does the stem end (the end is opposite to the support-head.")
 
 (grob-property-description 'stem-shorten list? "shorten stems in forced directions given flag multiplicity:
index e07436673866ba40d418f2cb2cce2be09385e257..8d28d5090d92abba3aa08d9850d3bc617413d3c2 100644 (file)
                       (symbol->string style))))))
 
 
-(define (note-head-style->attachment-coordinates style duration)
+;; TODO junk completely?
+(define (note-head-style->attachment-coordinates grob axis)
   "Return pair (X . Y), containing multipliers for the note head
 bounding box, where to attach the stem. e.g.: X==0 means horizontally
 centered, X==1 is at the right, X == -1 is at the left."
 
+   '(1.0 . 0.0))
 
-  (case style
-    ((default)
-     (if (< duration -1)
-        '(0.0 . 0.6) ;; neo-mensural
-        '(1.0 . 0.5) ;; default
-        ))
-    ((cross) '(1.0 . 0.75))
-    ((mensural) '(0.0 . 0.6))
-    ((neo_mensural) '(0.0 . 0.6))
-    ((diamond) '(1.0 . 0.8))
-    ((transparent) '(1.0 . 1.0))
-    ((slash) '(1.0 . 1.0))
-    ((harmonic) '(1.0 0.0))
-
-    ;;
-    ;;UGH this needs to be changed: triangle is not point-symmetric, has different attachments
-    ;;  for up/down stem
-    ((triangle) '(0.75 . 0.15))
-    ((baroque)
-     (if (< duration 0)
-        '(0.0 . 0.6) ;; neo-mensural
-        '(1.0 . 0.5) ;; default
-        ))
-    (else
-
-     ;; this also works for easy notation.
-     '(1.0 . 0.0)
-     )))
 
 (define-public (string-encode-integer i)
   (cond