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"
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 Paper_def
*pap
= unsmob_paper (paper
);
25 Font_metric
*fm
= select_font (pap
, props
);
27 SCM list
= scm_list_n (ly_symbol2scm ("text"), markup
, SCM_UNDEFINED
);
29 if (dynamic_cast<Virtual_font_metric
*> (fm
))
34 programming_error ("Can't use virtual font for text.");
37 list
= fontify_atom (fm
, list
);
39 Box b
= fm
->text_dimension (ly_scm2string (markup
));
40 return Molecule (b
, list
).smobbed_copy();
42 else if (gh_pair_p (markup
))
44 SCM func
= gh_car (markup
);
45 SCM args
= gh_cdr (markup
);
46 if (!markup_p (markup
))
47 programming_error ("Markup head has no markup signature.");
49 return scm_apply_2 (func
, paper
, props
, args
);
57 MAKE_SCHEME_CALLBACK(Text_item
,brew_molecule
,1);
59 Text_item::brew_molecule (SCM grob
)
61 Grob
* me
= unsmob_grob (grob
);
63 SCM t
= me
->get_grob_property ("text");
64 SCM chain
= Font_interface::font_alist_chain (me
);
65 return interpret_markup (me
->get_paper ()->self_scm (), chain
, t
);
70 Ugh. Duplicated from Scheme.
73 Text_item::markup_p (SCM x
)
78 && SCM_BOOL_F
!= scm_object_property (gh_car (x
), ly_symbol2scm ("markup-signature")));
81 ADD_INTERFACE (Text_item
,"text-interface",
82 "A scheme markup text, see @ref{Markup functions}.",
83 "text baseline-skip word-space");