]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/font-size-engraver.cc
* lily/lily-parser-scheme.cc (LY_DEFINE): don't set 'parser
[lilypond.git] / lily / font-size-engraver.cc
index b8d91ae55cc93c501baff57c2491680d6a923902..d1ac0e634b5cbce42ec98a4dcb02707b3836ac0e 100644 (file)
@@ -1,40 +1,51 @@
-/*   
-  font-size-grav.cc --  implement Font_size_engraver
-  
+/*
+  font-size-engraver.cc -- implement Font_size_engraver
+
   source file of the GNU LilyPond music typesetter
-  
-  (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
- */
 
-#include "font-size-engraver.hh"
-#include "score-element.hh"
-#include "lily-guile.hh"
+  (c) 2001--2005  Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
 
-Font_size_engraver::Font_size_engraver ()
+#include "grob.hh"
+#include "engraver.hh"
+
+class Font_size_engraver : public Engraver
 {
-  size_i_ = 0;
-}
 
-void
-Font_size_engraver::do_process_requests ()
+  TRANSLATOR_DECLARATIONS (Font_size_engraver);
+protected:
+  virtual void acknowledge_grob (Grob_info gi);
+private:
+};
+
+Font_size_engraver::Font_size_engraver ()
 {
-  SCM s (get_property ("fontSize", 0));
-  
-  if (SCM_NUMBERP(s))
-    {
-      size_i_ = gh_scm2int (s);
-    }
 }
 
 void
-Font_size_engraver::acknowledge_element (Score_element_info e)
+Font_size_engraver::acknowledge_grob (Grob_info gi)
 {
-  if (size_i_ && e.elem_l_->get_elt_property (fontsize_scm_sym) == SCM_BOOL_F)
+  SCM sz = get_property ("fontSize");
+
+  /*
+    We only want to process a grob once.
+  */
+  if (gi.context () != context ())
+    return;
+
+  if (scm_is_number (sz) && scm_to_double (sz))
     {
-      e.elem_l_->set_elt_property (fontsize_scm_sym,
-                                  gh_int2scm (size_i_));
+      Real font_size = scm_to_double (sz);
+
+      font_size += robust_scm2double (gi.grob ()->get_property ("font-size"), 0);
+      gi.grob ()->set_property ("font-size", scm_make_real (font_size));
     }
 }
-ADD_THIS_TRANSLATOR (Font_size_engraver);
 
+ADD_TRANSLATOR (Font_size_engraver,
+               /* descr */ "Puts fontSize into font-relative-size grob property.",
+               /* creats*/ "",
+               /* accepts */ "",
+               /* acks  */ "font-interface",
+               /* reads */ "fontSize",
+               /* write */ "");