]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lookup.cc
patch::: 1.3.78.jcn1
[lilypond.git] / lily / lookup.cc
index fc4d696d93656fa456f7bb1e132ba0671e51b9cd..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
@@ -53,8 +77,8 @@ Lookup::afm_find (String s, bool warn) const
       me->afm_l_ = all_fonts_global_p->find_afm (font_name_);
       if (!me->afm_l_)
        {
-         warning (_f ("Can't find font: `%s'", font_name_));
-         warning (_f ("(search path `%s')", global_path.str ().ch_C()));
+         warning (_f ("can't find font: `%s'", font_name_));
+         warning (_f ("(search path: `%s')", global_path.str ().ch_C()));
          error (_ ("Aborting"));
        }
     }
@@ -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);
 }
@@ -105,10 +130,10 @@ Molecule
 Lookup::dashed_slur (Bezier b, Real thick, Real dash)
 {
   SCM l = SCM_EOL;
-  // this is silly, we have array_to_scm
+
   for (int i= 4; i -- ;)
     {
-      l = gh_cons (to_scm (b.control_[i]), l);
+      l = gh_cons (ly_offset2scm (b.control_[i]), l);
     }
 
   SCM at = (gh_list (ly_symbol2scm ("dashed-slur"),
@@ -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,17 +266,14 @@ Lookup::text (String style, String text, Paper_def *paper_l)
       font_mag = (int)paper_l->get_var ("magnification_" + style);
     }
 
-  /*
-    UGH.
-  */
-  SCM l = ly_eval_str (("(style-to-cmr \"" + style + "\")").ch_C());
+  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)
@@ -285,6 +305,8 @@ Lookup::text (String style, String text, Paper_def *paper_l)
       lines[i] = str;
     }
 
+  if (!lines.size())
+       return Molecule();
 
   SCM first = gh_list (ly_symbol2scm ("text"),
                         ly_str02scm (lines[0].ch_C()),
@@ -325,11 +347,11 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick)
   back.control_[2] += curvethick * complex_exp (Offset (0, alpha + M_PI/2));  
 
   SCM scontrols[8];
-  // this is silly, we have array_to_scm
+
   for (int i=4; i--;)
-    scontrols[ i ] = to_scm (back.control_[i]);
+    scontrols[ i ] = ly_offset2scm(back.control_[i]);
   for (int i=4 ; i--;)
-    scontrols[i+4] = to_scm (curve.control_[i]);
+    scontrols[i+4] = ly_offset2scm (curve.control_[i]);
 
   /*
     Need the weird order b.o. the way PS want its arguments  
@@ -360,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);
@@ -392,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);
@@ -422,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);
@@ -430,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);
@@ -460,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);
@@ -477,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);
@@ -485,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);
@@ -511,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);
@@ -528,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;