2 text-item.cc -- implement Text_item
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "text-item.hh"
14 #include "font-interface.hh"
15 #include "virtual-font-metric.hh"
19 MAKE_SCHEME_CALLBACK(Text_item,interpret_markup,3);
21 Text_item::interpret_markup (SCM grob, SCM props, SCM markup)
23 if (gh_string_p (markup))
25 Grob *me = unsmob_grob (grob);
26 Font_metric *fm = Font_interface::get_font (me, props);
28 SCM list = scm_list_n (ly_symbol2scm ("text"), markup, SCM_UNDEFINED);
30 if (dynamic_cast<Virtual_font_metric*> (fm))
35 programming_error ("Can't use virtual font for text.");
38 list = fontify_atom (fm, list);
40 Box b = fm->text_dimension (ly_scm2string (markup));
41 return Molecule (b, list).smobbed_copy();
43 else if (gh_pair_p (markup))
45 SCM func = gh_car (markup);
46 SCM args = gh_cdr (markup);
47 if (!markup_p (markup))
48 programming_error ("Markup head has no markup signature.");
50 return scm_apply_2 (func, grob, props, args);
58 MAKE_SCHEME_CALLBACK(Text_item,brew_molecule,1);
60 Text_item::brew_molecule (SCM grob)
62 Grob * me = unsmob_grob (grob);
64 SCM t = me->get_grob_property ("text");
65 SCM chain = Font_interface::font_alist_chain (me);
66 return interpret_markup (grob, chain, t);
71 Ugh. Duplicated from Scheme.
74 Text_item::markup_p (SCM x)
79 && SCM_BOOL_F != scm_object_property (gh_car (x), ly_symbol2scm ("markup-signature")));
82 ADD_INTERFACE (Text_item,"text-interface",
83 "A scheme markup text, see @ref{Markup functions}.",
84 "text baseline-skip word-space");