]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/text-item.cc
release commit
[lilypond.git] / lily / text-item.cc
index 389129867042648d28140ea7b982a2b07831a9a2..8c6e9501ebe50b7aeb0a605714e1599605e8a07c 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
   
-  (c) 1998--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1998--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   Jan Nieuwenhuizen <janneke@gnu.org>
  */
 #include <math.h>
@@ -18,7 +18,7 @@
 #include "all-font-metrics.hh"
 #include "afm.hh"
 #include "lookup.hh"
-
+#include "virtual-font-metric.hh"
 
 /*
 
@@ -59,7 +59,18 @@ Text_item::text2molecule (Grob *me, SCM text, SCM alist_chain)
     }
   return Molecule ();
 }
-            
+
+
+MAKE_SCHEME_CALLBACK(Text_item,text_to_molecule,3);
+SCM
+Text_item::text_to_molecule (SCM grob, SCM props, SCM markup)
+{
+  Grob *me = unsmob_grob (grob);
+  
+  return Text_item::text2molecule (me, markup, props).smobbed_copy();
+}
+
+
 Molecule
 Text_item::string2molecule (Grob *me, SCM text, SCM alist_chain)
 {
@@ -88,11 +99,21 @@ Text_item::lookup_character (Grob *, Font_metric*fm, SCM char_name)
 }
 
 
+
 Molecule
 Text_item::lookup_text (Grob *, Font_metric*fm, SCM text)
 {
   SCM list = scm_list_n (ly_symbol2scm ("text"), text, SCM_UNDEFINED);
-  list = fontify_atom (fm, list);
+
+  if (dynamic_cast<Virtual_font_metric*> (fm))
+    {
+      /*
+       ARGH.
+       */
+      programming_error ("Can't use virtual font for text.");
+    }
+  else
+    list = fontify_atom (fm, list);
   
   return Molecule (fm->text_dimension (ly_scm2string (text)), list);
 }
@@ -111,13 +132,18 @@ Molecule
 Text_item::markup_text2molecule (Grob *me, SCM markup_text,
                                 SCM alist_chain)
 {
-  SCM sheet = me->get_paper ()->style_sheet_;
-  SCM f = ly_cdr (scm_assoc (ly_symbol2scm ("markup-to-properties"), sheet));
+  SCM f = me->get_paper ()->lookup_variable (ly_symbol2scm ("markup-to-properties"));
   
   SCM markup = ly_car (markup_text);
   SCM text = ly_cdr (markup_text);
 
-  SCM p = gh_cons (gh_call2 (f, sheet, markup), alist_chain);
+  /* ARGRGRRGRARGRA
+   */
+
+  SCM abbrev = me->get_paper ()->lookup_variable (ly_symbol2scm ("abbreviation-alist"));
+  SCM style = me->get_paper ()->lookup_variable (ly_symbol2scm ("style-alist"));
+  
+  SCM p = gh_cons (scm_call_3 (f, abbrev, style, markup), alist_chain);
 
   Real staff_space = Staff_symbol_referencer::staff_space (me);
 
@@ -183,7 +209,7 @@ Text_item::markup_text2molecule (Grob *me, SCM markup_text,
     }
   
   
-  /* Set extend to markup requested value. */
+  /* Set extend to markup evented value. */
   if (extent_b)
     {
       Box b = mol.extent_box ();
@@ -215,7 +241,7 @@ Text_item::brew_molecule (SCM smob)
       Molecule m;
       m.set_empty (false);
       mol.add_at_edge (X_AXIS, RIGHT, m, gh_scm2double (space)
-                      * Staff_symbol_referencer::staff_space (me));
+                      * Staff_symbol_referencer::staff_space (me), 0);
     }
   return mol.smobbed_copy (); 
 }
@@ -223,5 +249,44 @@ Text_item::brew_molecule (SCM smob)
 
 
 ADD_INTERFACE (Text_item,"text-interface",
-  "A scheme markup text",
-  "text align baseline-skip lookup raise kern word-space magnify");
+  "A scheme markup text, see @ref{Markup functions}.",
+  "text baseline-skip word-space");
+
+
+/*
+  Ugh. Duplicated from Scheme.
+ */
+bool
+new_markup_p (SCM x)
+{
+  return
+    gh_string_p (x) ||
+    (gh_pair_p (x)
+     && SCM_BOOL_F != scm_object_property (gh_car (x), ly_symbol2scm ("markup-signature")));
+}
+
+SCM
+new_markup_brewer ()
+{
+  static SCM proc ;
+
+  if (!proc)
+    proc = scm_c_eval_string ("brew-new-markup-molecule");
+
+  return proc;
+}
+
+
+Molecule
+Text_item::interpret_new_markup (SCM grob, SCM achain,
+                                SCM markup)
+{
+  static SCM proc;
+  if (!proc)
+    proc = scm_c_eval_string ("interpret-markup");
+
+  if (new_markup_p (markup))
+    return *unsmob_molecule (scm_call_3 (proc, grob, achain, markup));
+  else
+    return Molecule();
+}