]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/text-item.cc
* lily/include/translator.hh (class Translator): rename
[lilypond.git] / lily / text-item.cc
index e8e9dcabf783a0fe8e9b32262e295bb25c20bb63..782cd4d1c1457e2eeecea74e0ecf6cb69ed54e1b 100644 (file)
 #include "font-interface.hh"
 #include "virtual-font-metric.hh"
 #include "paper-def.hh"
+#include "scaled-font-metric.hh"
 
-MAKE_SCHEME_CALLBACK (Text_item, interpret_markup, 3)
+MAKE_SCHEME_CALLBACK (Text_item, interpret_string, 4)
 SCM
-Text_item::interpret_markup (SCM paper, SCM props, SCM markup)
+Text_item::interpret_string (SCM paper, SCM props, SCM encoding, SCM markup)
 {
-  if (gh_string_p (markup))
-    {
-      String str = ly_scm2string (markup);
-      if (str.index_any (" \t\n\r") != -1)
-       {
-         /* Multi word string to line markup.  */
-         static SCM proc;
-         if (!proc)
-           proc = scm_c_eval_string ("make-simple-markup");
-         return interpret_markup (paper, props, scm_call_1 (proc, markup));
-       }
+  Paper_def *pap = unsmob_paper (paper);
+  
+  SCM_ASSERT_TYPE(pap, paper, SCM_ARG1, __FUNCTION__, "Paper definition");
+  SCM_ASSERT_TYPE(ly_c_string_p (markup), markup, SCM_ARG3, __FUNCTION__, "string");
+  SCM_ASSERT_TYPE(encoding == SCM_EOL
+                 || ly_c_symbol_p (encoding), encoding, SCM_ARG2, __FUNCTION__, "symbol");
+  
+  String str = ly_scm2string (markup);
+  Font_metric *fm = select_encoded_font (pap, props, encoding);
 
-      /* Simple word.  */
-      Paper_def *pap = unsmob_paper (paper);
-      Font_metric *fm = select_font (pap, props);
-      SCM lst = scm_list_n (ly_symbol2scm ("text"), markup, SCM_UNDEFINED);
+  SCM lst = SCM_EOL;      
+  Box b;
+  if (Modified_font_metric* mf = dynamic_cast<Modified_font_metric*> (fm))
+    {
+      lst = scm_list_3 (ly_symbol2scm ("text"),
+                       mf->self_scm (),
+                       markup);
+       
+      b = mf->text_dimension (str);
+    }
+  else
+    {
+      /* ARGH. */
+      programming_error ("Must have Modified_font_metric for text.");
+    }
       
-      if (dynamic_cast<Virtual_font_metric*> (fm))
-       /* ARGH. */
-       programming_error ("Can't use virtual font for text.");
-      else
-       lst = fontify_atom (fm, lst);
+  return Stencil (b, lst).smobbed_copy ();
+}
 
-      Box b = fm->text_dimension (str);
-      return Stencil (b, lst).smobbed_copy ();
-    }
-  else if (gh_pair_p (markup))
+
+MAKE_SCHEME_CALLBACK (Text_item, interpret_markup, 3)
+SCM
+Text_item::interpret_markup (SCM paper, SCM props, SCM markup)
+{
+  if (ly_c_string_p (markup))
+    return interpret_string (paper, props, SCM_EOL, markup);
+  else if (ly_c_pair_p (markup))
     {
-      SCM func = gh_car (markup);
-      SCM args = gh_cdr (markup);
+      SCM func = ly_car (markup);
+      SCM args = ly_cdr (markup);
       if (!markup_p (markup))
        programming_error ("Markup head has no markup signature.");
       
@@ -61,7 +72,7 @@ MAKE_SCHEME_CALLBACK (Text_item,print,1);
 SCM
 Text_item::print (SCM grob)
 {
-  Grob * me = unsmob_grob (grob);
+  Grob *me = unsmob_grob (grob);
   
   SCM t = me->get_property ("text");
   SCM chain = Font_interface::text_font_alist_chain (me);
@@ -76,9 +87,9 @@ bool
 Text_item::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")));
+    ly_c_string_p (x) ||
+    (ly_c_pair_p (x)
+     && SCM_BOOL_F != scm_object_property (ly_car (x), ly_symbol2scm ("markup-signature")));
 }
 
 ADD_INTERFACE (Text_item,"text-interface",