X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftext-item.cc;h=1a01eced0b90a62c1e442c40f36c35249a0c1439;hb=388121aed1734e9e536ede58bd3de98b68367842;hp=ac80893cf281ae4f701870a0f013a269bd7ad390;hpb=1d806d5a5a49dcf192259feac48510cf4e332291;p=lilypond.git diff --git a/lily/text-item.cc b/lily/text-item.cc index ac80893cf2..1a01eced0b 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -1,80 +1,100 @@ /* - text-item.cc -- implement Text_item + text-item.cc -- implement Text_interface source file of the GNU LilyPond music typesetter - (c) 1998--2003 Han-Wen Nienhuys - Jan Nieuwenhuizen - */ + (c) 1998--2004 Han-Wen Nienhuys + Jan Nieuwenhuizen +*/ + +#include "text-item.hh" + #include +#include "main.hh" +#include "config.hh" +#include "pango-font.hh" #include "warn.hh" #include "grob.hh" -#include "text-item.hh" #include "font-interface.hh" -#include "virtual-font-metric.hh" +#include "output-def.hh" +#include "modified-font-metric.hh" + + +MAKE_SCHEME_CALLBACK (Text_interface, interpret_string, 3) +SCM +Text_interface::interpret_string (SCM layout_smob, + SCM props, + SCM markup) +{ + Output_def *layout = unsmob_output_def (layout_smob); + + SCM_ASSERT_TYPE (layout, layout_smob, SCM_ARG1, + __FUNCTION__, "Layout definition"); + SCM_ASSERT_TYPE (scm_is_string (markup), markup, SCM_ARG3, + __FUNCTION__, "string"); + + String str = ly_scm2string (markup); + Font_metric *fm = select_encoded_font (layout, props); + return fm->text_stencil (str).smobbed_copy (); +} -MAKE_SCHEME_CALLBACK(Text_item,interpret_markup,3); +MAKE_SCHEME_CALLBACK (Text_interface, interpret_markup, 3) SCM -Text_item::interpret_markup (SCM grob, SCM props, SCM markup) +Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup) { - if (gh_string_p (markup)) + if (scm_is_string (markup)) + return interpret_string (layout_smob, props, markup); + else if (scm_is_pair (markup)) { - Grob *me = unsmob_grob (grob); - Font_metric *fm = Font_interface::get_font (me, props); - - SCM list = scm_list_n (ly_symbol2scm ("text"), markup, SCM_UNDEFINED); + SCM func = scm_car (markup); + SCM args = scm_cdr (markup); + if (!markup_p (markup)) + programming_error ("Markup head has no markup signature."); - if (dynamic_cast (fm)) - { - /* - ARGH. - */ - programming_error ("Can't use virtual font for text."); - } - else - list = fontify_atom (fm, list); - - Box b = fm->text_dimension (ly_scm2string (markup)); - return Molecule (b, list).smobbed_copy(); + return scm_apply_2 (func, layout_smob, props, args); } else { - SCM func = gh_car (markup); - SCM args = gh_cdr (markup); - return scm_apply_2 (func, grob, props, args); + programming_error ("Is not a markup: "); + scm_display (markup, scm_current_error_port()); + assert (false); + Box b; + b[X_AXIS].set_empty(); + b[Y_AXIS].set_empty(); + + Stencil s(b, SCM_EOL); + return s.smobbed_copy(); } } -MAKE_SCHEME_CALLBACK(Text_item,brew_molecule,1); +MAKE_SCHEME_CALLBACK (Text_interface,print,1); SCM -Text_item::brew_molecule (SCM grob) +Text_interface::print (SCM grob) { - Grob * me = unsmob_grob (grob); - - SCM t = me->get_grob_property ("text"); - SCM chain = Font_interface::font_alist_chain (me); - return interpret_markup (grob, chain, t); + 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_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 - gh_string_p (x) || - (gh_pair_p (x) - && SCM_BOOL_F != scm_object_property (gh_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 @ref{Markup functions}.", - "text baseline-skip word-space"); +ADD_INTERFACE (Text_interface,"text-interface", + "A scheme markup text, see @usermanref{Text-markup}.", + "text baseline-skip word-space");