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. */
30 proc = scm_c_eval_string ("make-simple-markup");
31 return interpret_markup (paper, props, scm_call_1 (proc, markup));
35 Paper_def *pap = unsmob_paper (paper);
36 Font_metric *fm = select_font (pap, props);
37 SCM lst = scm_list_n (ly_symbol2scm ("text"), markup, SCM_UNDEFINED);
39 if (dynamic_cast<Virtual_font_metric*> (fm))
41 programming_error ("Can't use virtual font for text.");
43 lst = fontify_atom (fm, lst);
45 Box b = fm->text_dimension (str);
46 return Stencil (b, lst).smobbed_copy ();
48 else if (gh_pair_p (markup))
50 SCM func = gh_car (markup);
51 SCM args = gh_cdr (markup);
52 if (!markup_p (markup))
53 programming_error ("Markup head has no markup signature.");
55 return scm_apply_2 (func, paper, props, args);
60 MAKE_SCHEME_CALLBACK (Text_item,print,1);
62 Text_item::print (SCM grob)
64 Grob * me = unsmob_grob (grob);
66 SCM t = me->get_property ("text");
67 SCM chain = Font_interface::font_alist_chain (me);
68 return interpret_markup (me->get_paper ()->self_scm (), chain, t);
73 Ugh. Duplicated from Scheme.
76 Text_item::markup_p (SCM x)
81 && SCM_BOOL_F != scm_object_property (gh_car (x), ly_symbol2scm ("markup-signature")));
84 ADD_INTERFACE (Text_item,"text-interface",
85 "A scheme markup text, see @usermanref{Text-markup}.",
86 "text baseline-skip word-space");