]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/virtual-font-metric.cc
($(outdir)/%.pdf): add DVIPS_FLAGS. This will
[lilypond.git] / lily / virtual-font-metric.cc
index 276a2450965879dfd2eac5e50174e59d82c22c0b..744da20afdc7dabe594ab3a5c0680fe81bfd4c9a 100644 (file)
@@ -3,14 +3,14 @@
 
 source file of the GNU LilyPond music typesetter
 
-(c) 2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+(c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
  */
 
+#include "warn.hh"
 #include "virtual-font-metric.hh"
 #include "all-font-metrics.hh"
-#include "main.hh"
-#include "molecule.hh"
+#include "stencil.hh"
 #include "paper-def.hh"
 
 
@@ -50,11 +50,11 @@ Virtual_font_metric::count () const
   return k;
 }
 
-Molecule
+Stencil
 Virtual_font_metric::find_by_name (String glyph) const
 {
-  Molecule m;  
-  for (SCM s = font_list_; m.empty_b () && gh_pair_p (s); s = gh_cdr (s))
+  Stencil m;  
+  for (SCM s = font_list_; m.is_empty () && gh_pair_p (s); s = gh_cdr (s))
     {
       m = unsmob_metrics (gh_car (s))->find_by_name (glyph);
     }
@@ -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();
+}
+
+Stencil
+Virtual_font_metric::get_ascii_char_stencil (int )  const
+{
+  programming_error ("Virtual font metric cannot be indexed by ASCII.");
+  return Stencil();
+}
+
+
+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
+{
+  Stencil m;
+  int total = 0; 
+  for (SCM s = font_list_; m.is_empty () && 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
+Stencil
+Virtual_font_metric::get_indexed_char_stencil (int code)  const
 {
-  Molecule  m ;  
-  int last_k = 0;
+  Stencil  m ;  
+  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_stencil (code - total); // ugh.
          break; 
        }
-      last_k = k;
+      total += fm->count ();
     }
 
   return m;