]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/text-item.cc
* configure.in: Test for and accept lmodern if EC fonts not found.
[lilypond.git] / lily / text-item.cc
index 10fdc67ec0fa7783d9568d811bf2da7fb8a653a0..fdceef15f849d002c8d1a78b64b1825664cb996d 100644 (file)
@@ -1,44 +1,49 @@
 /*   
-  text-item.cc -- implement Text_item
+  text-item.cc -- implement Text_interface
 
   source file of the GNU LilyPond music typesetter
   
   (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  Jan Nieuwenhuizen <janneke@gnu.org>
- */
-#include <math.h>
+                 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "text-item.hh"
+
+#include <cmath>
 
 #include "warn.hh"
 #include "grob.hh"
-#include "text-item.hh"
 #include "font-interface.hh"
 #include "virtual-font-metric.hh"
 #include "output-def.hh"
-#include "scaled-font-metric.hh"
+#include "modified-font-metric.hh"
 #include "ly-module.hh"
 
-MAKE_SCHEME_CALLBACK (Text_item, interpret_string, 4)
+MAKE_SCHEME_CALLBACK (Text_interface, interpret_string, 4)
 SCM
-Text_item::interpret_string (SCM paper, SCM props, SCM encoding, SCM markup)
+Text_interface::interpret_string (SCM layout_smob,
+                                 SCM props, SCM input_encoding, SCM markup)
 {
-  Output_def *pap = unsmob_output_def (paper);
+  Output_def *layout = unsmob_output_def (layout_smob);
   
-  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");
+  SCM_ASSERT_TYPE (layout, layout_smob, SCM_ARG1,
+                  __FUNCTION__, "Layout definition");
+  SCM_ASSERT_TYPE (scm_is_string (markup), markup, SCM_ARG3,
+                  __FUNCTION__, "string");
+  SCM_ASSERT_TYPE (input_encoding == SCM_EOL || scm_is_symbol (input_encoding),
+                  input_encoding, SCM_ARG2, __FUNCTION__, "symbol");
   
   String str = ly_scm2string (markup);
-  if (!ly_c_symbol_p (encoding))
+  if (!scm_is_symbol (input_encoding))
     {
-      SCM var = ly_module_lookup (pap->scope_,
-                                 ly_symbol2scm ("inputencoding"));
-      if (var != SCM_BOOL_F) 
-       encoding = scm_variable_ref (var);
-      
+      SCM enc = layout->lookup_variable (ly_symbol2scm ("inputencoding"));
+      if (scm_is_string (enc))
+       input_encoding = scm_string_to_symbol (enc);
+      else if (scm_is_symbol (enc))
+       input_encoding = enc;
     }
   
-  Font_metric *fm = select_encoded_font (pap, props, encoding);
+  Font_metric *fm = select_encoded_font (layout, props, input_encoding);
 
   SCM lst = SCM_EOL;      
   Box b;
@@ -61,51 +66,49 @@ Text_item::interpret_string (SCM paper, SCM props, SCM encoding, SCM markup)
 }
 
 
-MAKE_SCHEME_CALLBACK (Text_item, interpret_markup, 3)
+MAKE_SCHEME_CALLBACK (Text_interface, interpret_markup, 3)
 SCM
-Text_item::interpret_markup (SCM paper, SCM props, SCM markup)
+Text_interface::interpret_markup (SCM layout_smob, 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))
+  if (scm_is_string (markup))
+    return interpret_string (layout_smob, props, SCM_EOL, markup);
+  else if (scm_is_pair (markup))
     {
-      SCM func = ly_car (markup);
-      SCM args = ly_cdr (markup);
+      SCM func = scm_car (markup);
+      SCM args = scm_cdr (markup);
       if (!markup_p (markup))
        programming_error ("Markup head has no markup signature.");
       
-      return scm_apply_2 (func, paper, props, args);
+      return scm_apply_2 (func, layout_smob, props, args);
     }
   return SCM_EOL;
 }
 
-MAKE_SCHEME_CALLBACK (Text_item,print,1);
+MAKE_SCHEME_CALLBACK (Text_interface,print,1);
 SCM
-Text_item::print (SCM grob)
+Text_interface::print (SCM grob)
 {
   Grob *me = unsmob_grob (grob);
   
   SCM t = me->get_property ("text");
   SCM chain = Font_interface::text_font_alist_chain (me);
-  return interpret_markup (me->get_paper ()->self_scm (), chain, t);
+  return interpret_markup (me->get_layout ()->self_scm (), chain, t);
 }
 
-
-/*
-  Ugh. Duplicated from Scheme.
- */
+/* Ugh. Duplicated from Scheme.  */
 bool
-Text_item::markup_p (SCM x)
+Text_interface::markup_p (SCM x)
 {
-  return
-    ly_c_string_p (x) ||
-    (ly_c_pair_p (x)
-     && SCM_BOOL_F != scm_object_property (ly_car (x), ly_symbol2scm ("markup-signature")));
+  return (scm_is_string (x)
+         || (scm_is_pair (x)
+             && SCM_BOOL_F
+             != scm_object_property (scm_car (x),
+                                     ly_symbol2scm ("markup-signature"))));
 }
 
-ADD_INTERFACE (Text_item,"text-interface",
-  "A scheme markup text, see @usermanref{Text-markup}.",
-  "text baseline-skip word-space");
+ADD_INTERFACE (Text_interface,"text-interface",
+              "A scheme markup text, see @usermanref{Text-markup}.",
+              "text baseline-skip word-space");