2 text-item.cc -- implement Text_item
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2004 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"
16 #include "paper-def.hh"
18 MAKE_SCHEME_CALLBACK (Text_item, interpret_markup, 3)
20 Text_item::interpret_markup (SCM paper, SCM props, SCM markup)
22 if (gh_string_p (markup))
24 String str = ly_scm2string (markup);
25 if (str.index_any (" \t\n\r") != -1)
27 /* Multi word string to line markup. */
28 SCM proc= ly_scheme_function ("make-simple-markup");
29 return interpret_markup (paper, props, scm_call_1 (proc, markup));
33 Paper_def *pap = unsmob_paper (paper);
34 Font_metric *fm = select_font (pap, props);
35 SCM lst = scm_list_n (ly_symbol2scm ("text"), markup, SCM_UNDEFINED);
37 if (dynamic_cast<Virtual_font_metric*> (fm))
39 programming_error ("Can't use virtual font for text.");
41 lst = fontify_atom (fm, lst);
43 Box b = fm->text_dimension (str);
44 return Stencil (b, lst).smobbed_copy ();
46 else if (gh_pair_p (markup))
48 SCM func = gh_car (markup);
49 SCM args = gh_cdr (markup);
50 if (!markup_p (markup))
51 programming_error ("Markup head has no markup signature.");
53 return scm_apply_2 (func, paper, props, args);
58 MAKE_SCHEME_CALLBACK (Text_item,print,1);
60 Text_item::print (SCM grob)
62 Grob * me = unsmob_grob (grob);
64 SCM t = me->get_property ("text");
65 SCM chain = Font_interface::text_font_alist_chain (me);
66 return interpret_markup (me->get_paper ()->self_scm (), 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 @usermanref{Text-markup}.",
84 "text baseline-skip word-space");