]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lookup.cc
patch::: 1.3.78.jcn1
[lilypond.git] / lily / lookup.cc
index 8be036fa7805a66e99fe1f24b4a1fea3f09c343f..a6c24eddd35692b5f4f5b328090fd4d2806d00af 100644 (file)
@@ -14,7 +14,7 @@
 #include <ctype.h>
 
 #include "lookup.hh"
-#include "debug.hh"
+#include "warn.hh"
 #include "dimensions.hh"
 #include "bezier.hh"
 #include "paper-def.hh"
@@ -27,7 +27,8 @@
 #include "scope.hh"
 #include "molecule.hh"
 
-#include "lily-guile.hh"
+
+#include "ly-smobs.icc"
 
 
 Lookup::Lookup ()
@@ -38,10 +39,33 @@ Lookup::Lookup ()
 Lookup::Lookup (Lookup const& s)
 {
   font_name_ = s.font_name_;
-  afm_l_ = 0;  
+  afm_l_ = 0;
 }
 
+SCM
+Lookup::mark_smob (SCM s)
+{
+  return s;  
+}
 
+int
+Lookup::print_smob (SCM s, SCM p, scm_print_state*)
+{
+  scm_puts ("#<Lookup >#", p);
+  return 1;
+}
+
+
+IMPLEMENT_UNSMOB(Lookup, lookup);
+IMPLEMENT_SIMPLE_SMOBS(Lookup);
+IMPLEMENT_DEFAULT_EQUAL_P(Lookup);
+
+SCM
+Lookup::make_lookup ()
+{
+  Lookup * l = new Lookup;
+  return l->smobbed_self();
+}
 
 
 Molecule
@@ -71,6 +95,7 @@ Lookup::afm_find (String s, bool warn) const
                    gh_int2scm (cm->code),
                    SCM_UNDEFINED));
 
+
   at= fontify_atom (afm_l_,at);
   return Molecule ( afm_bbox_to_box (cm->charBBox), at);
 }
@@ -127,9 +152,7 @@ Lookup::dashed_slur (Bezier b, Real thick, Real dash)
 Molecule
 Lookup::blank (Box b) 
 {
-  Molecule m;
-  m.dim_ = b;
-  return m;
+  return Molecule (b, SCM_EOL);
 }
 
 
@@ -222,7 +245,7 @@ sanitise_PS_string (String t)
 }
 
 /**
-
+TODO: move into Text_item. UGH: paper_l argument shoudl be junked.
 */
 Molecule
 Lookup::text (String style, String text, Paper_def *paper_l) 
@@ -243,20 +266,14 @@ Lookup::text (String style, String text, Paper_def *paper_l)
       font_mag = (int)paper_l->get_var ("magnification_" + style);
     }
 
-  /*
-    UGH.
-  */
-  SCM l = scm_eval (gh_list (ly_symbol2scm ("style-to-cmr"),
-                            ly_str02scm (style.ch_C()),
-                            SCM_UNDEFINED));
-  
+  SCM l = scm_assoc (ly_str02scm (style.ch_C()),
+                    scm_eval (ly_symbol2scm ("cmr-alist")));
+
   if (l != SCM_BOOL_F)
     {
       style = ly_scm2string (gh_cdr(l)) +to_str  ((int)font_h);
     }
 
-  
-
   Font_metric* metric_l = 0;
 
   if (font_mag)
@@ -365,11 +382,11 @@ Lookup::accordion (SCM s, Real staff_space) const
 
   if (sym == "Discant")
     {
-      Molecule r = afm_find("scripts-accDiscant");
+      Molecule r = afm_find("accordion-accDiscant");
       m.add_molecule(r);
       if (reg.left_str(1) == "F")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 2.5 PT, Y_AXIS);
          m.add_molecule(d);
          reg = reg.right_str(reg.length_i()-1);
@@ -397,27 +414,27 @@ Lookup::accordion (SCM s, Real staff_space) const
        }
       if (eflag & 0x02)
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 1.5 PT, Y_AXIS);
          m.add_molecule(d);
        }
       if (eflag & 0x04)
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 1.5 PT, Y_AXIS);
          d.translate_axis(0.8 * staff_space PT, X_AXIS);
          m.add_molecule(d);
        }
       if (eflag & 0x01)
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 1.5 PT, Y_AXIS);
          d.translate_axis(-0.8 * staff_space PT, X_AXIS);
          m.add_molecule(d);
        }
       if (reg.left_str(2) == "SS")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(0.5 * staff_space PT, Y_AXIS);
          d.translate_axis(0.4 * staff_space PT, X_AXIS);
          m.add_molecule(d);
@@ -427,7 +444,7 @@ Lookup::accordion (SCM s, Real staff_space) const
        }
       if (reg.left_str(1) == "S")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(0.5 * staff_space PT, Y_AXIS);
          m.add_molecule(d);
          reg = reg.right_str(reg.length_i()-1);
@@ -435,29 +452,29 @@ Lookup::accordion (SCM s, Real staff_space) const
     }
   else if (sym == "Freebase")
     {
-      Molecule r = afm_find("scripts-accFreebase");
+      Molecule r = afm_find("accordion-accFreebase");
       m.add_molecule(r);
       if (reg.left_str(1) == "F")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 1.5 PT, Y_AXIS);
          m.add_molecule(d);
          reg = reg.right_str(reg.length_i()-1);
        }
       if (reg == "E")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 0.5 PT, Y_AXIS);
          m.add_molecule(d);
        }
     }
   else if (sym == "Bayanbase")
     {
-      Molecule r = afm_find("scripts-accBayanbase");
+      Molecule r = afm_find("accordion-accBayanbase");
       m.add_molecule(r);
       if (reg.left_str(1) == "T")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 2.5 PT, Y_AXIS);
          m.add_molecule(d);
          reg = reg.right_str(reg.length_i()-1);
@@ -465,14 +482,14 @@ Lookup::accordion (SCM s, Real staff_space) const
       /* include 4' reed just for completeness. You don't want to use this. */
       if (reg.left_str(1) == "F")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 1.5 PT, Y_AXIS);
          m.add_molecule(d);
          reg = reg.right_str(reg.length_i()-1);
        }
       if (reg.left_str(2) == "EE")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 0.5 PT, Y_AXIS);
          d.translate_axis(0.4 * staff_space PT, X_AXIS);
          m.add_molecule(d);
@@ -482,7 +499,7 @@ Lookup::accordion (SCM s, Real staff_space) const
        }
       if (reg.left_str(1) == "E")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 0.5 PT, Y_AXIS);
          m.add_molecule(d);
          reg = reg.right_str(reg.length_i()-1);
@@ -490,25 +507,25 @@ Lookup::accordion (SCM s, Real staff_space) const
     }
   else if (sym == "Stdbase")
     {
-      Molecule r = afm_find("scripts-accStdbase");
+      Molecule r = afm_find("accordion-accStdbase");
       m.add_molecule(r);
       if (reg.left_str(1) == "T")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 3.5 PT, Y_AXIS);
          m.add_molecule(d);
          reg = reg.right_str(reg.length_i()-1);
        }
       if (reg.left_str(1) == "F")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 2.5 PT, Y_AXIS);
          m.add_molecule(d);
          reg = reg.right_str(reg.length_i()-1);
        }
       if (reg.left_str(1) == "M")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 2 PT, Y_AXIS);
          d.translate_axis(staff_space PT, X_AXIS);
          m.add_molecule(d);
@@ -516,14 +533,14 @@ Lookup::accordion (SCM s, Real staff_space) const
        }
       if (reg.left_str(1) == "E")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 1.5 PT, Y_AXIS);
          m.add_molecule(d);
          reg = reg.right_str(reg.length_i()-1);
        }
       if (reg.left_str(1) == "S")
        {
-         Molecule d = afm_find("scripts-accDot");
+         Molecule d = afm_find("accordion-accDot");
          d.translate_axis(staff_space * 0.5 PT, Y_AXIS);
          m.add_molecule(d);
          reg = reg.right_str(reg.length_i()-1);
@@ -533,22 +550,22 @@ Lookup::accordion (SCM s, Real staff_space) const
      for the rectangle */
   else if (sym == "SB")
     {
-      Molecule r = afm_find("scripts-accSB");
+      Molecule r = afm_find("accordion-accSB");
       m.add_molecule(r);
     }
   else if (sym == "BB")
     {
-      Molecule r = afm_find("scripts-accBB");
+      Molecule r = afm_find("accordion-accBB");
       m.add_molecule(r);
     }
   else if (sym == "OldEE")
     {
-      Molecule r = afm_find("scripts-accOldEE");
+      Molecule r = afm_find("accordion-accOldEE");
       m.add_molecule(r);
     }
   else if (sym == "OldEES")
     {
-      Molecule r = afm_find("scripts-accOldEES");
+      Molecule r = afm_find("accordion-accOldEES");
       m.add_molecule(r);
     }
   return m;