X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Ftext-item.cc;h=098ef17402e5cad7cba87197374826aee0c61181;hb=aab300b4e582627497ab12f8ea8609f03a3c8d84;hp=2ee9cd14c03f6d655b274b7dd330b6c30638c378;hpb=617eb05b0c5da1377d5ebe1ef7f5bd99a796fbbe;p=lilypond.git diff --git a/lily/text-item.cc b/lily/text-item.cc index 2ee9cd14c0..098ef17402 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -3,12 +3,12 @@ source file of the GNU LilyPond music typesetter - (c) 1998--2002 Han-Wen Nienhuys + (c) 1998--2003 Han-Wen Nienhuys Jan Nieuwenhuizen */ #include -#include "debug.hh" +#include "warn.hh" #include "text-item.hh" #include "paper-def.hh" #include "font-interface.hh" @@ -18,7 +18,7 @@ #include "all-font-metrics.hh" #include "afm.hh" #include "lookup.hh" - +#include "virtual-font-metric.hh" /* @@ -59,7 +59,18 @@ Text_item::text2molecule (Grob *me, SCM text, SCM alist_chain) } return Molecule (); } - + + +MAKE_SCHEME_CALLBACK(Text_item,text_to_molecule,3); +SCM +Text_item::text_to_molecule (SCM grob, SCM props, SCM markup) +{ + Grob *me = unsmob_grob (grob); + + return Text_item::text2molecule (me, markup, props).smobbed_copy(); +} + + Molecule Text_item::string2molecule (Grob *me, SCM text, SCM alist_chain) { @@ -88,11 +99,21 @@ Text_item::lookup_character (Grob *, Font_metric*fm, SCM char_name) } + Molecule -Text_item::lookup_text (Grob *me, Font_metric*fm, SCM text) +Text_item::lookup_text (Grob *, Font_metric*fm, SCM text) { SCM list = scm_list_n (ly_symbol2scm ("text"), text, SCM_UNDEFINED); - list = fontify_atom (fm, list); + + if (dynamic_cast (fm)) + { + /* + ARGH. + */ + programming_error ("Can't use virtual font for text."); + } + else + list = fontify_atom (fm, list); return Molecule (fm->text_dimension (ly_scm2string (text)), list); } @@ -111,13 +132,18 @@ Molecule Text_item::markup_text2molecule (Grob *me, SCM markup_text, SCM alist_chain) { - SCM sheet = me->paper_l ()->style_sheet_; - SCM f = ly_cdr (scm_assoc (ly_symbol2scm ("markup-to-properties"), sheet)); + SCM f = me->get_paper ()->lookup_variable (ly_symbol2scm ("markup-to-properties")); SCM markup = ly_car (markup_text); SCM text = ly_cdr (markup_text); - SCM p = gh_cons (gh_call2 (f, sheet, markup), alist_chain); + /* ARGRGRRGRARGRA + */ + + SCM abbrev = me->get_paper ()->lookup_variable (ly_symbol2scm ("abbreviation-alist")); + SCM style = me->get_paper ()->lookup_variable (ly_symbol2scm ("style-alist")); + + SCM p = gh_cons (scm_call_3 (f, abbrev, style, markup), alist_chain); Real staff_space = Staff_symbol_referencer::staff_space (me); @@ -145,6 +171,7 @@ Text_item::markup_text2molecule (Grob *me, SCM markup_text, SCM r = ly_assoc_chain (ly_symbol2scm ("raise"), p); if (gh_pair_p (r) && gh_number_p (ly_cdr (r))) raise = gh_scm2double (ly_cdr (r)) * staff_space; + Interval extent; bool extent_b = false; @@ -157,13 +184,19 @@ Text_item::markup_text2molecule (Grob *me, SCM markup_text, } Offset o (kern[X_AXIS], raise - kern[Y_AXIS]); - Molecule mol = Lookup::filledbox (Box (Interval (0,0), Interval (0,0))); + + SCM cp = ly_deep_copy (p); + if (raise) + { + SCM cr = ly_assoc_chain (ly_symbol2scm ("raise"), cp); + scm_set_cdr_x (cr, gh_int2scm (0)); + } while (gh_pair_p (text)) { - Molecule m = text2molecule (me, ly_car (text), p); + Molecule m = text2molecule (me, ly_car (text), cp); if (!m.empty_b ()) { @@ -175,7 +208,8 @@ Text_item::markup_text2molecule (Grob *me, SCM markup_text, text = ly_cdr (text); } - /* Set extend to markup requested value. */ + + /* Set extend to markup evented value. */ if (extent_b) { Box b = mol.extent_box (); @@ -207,7 +241,7 @@ Text_item::brew_molecule (SCM smob) Molecule m; m.set_empty (false); mol.add_at_edge (X_AXIS, RIGHT, m, gh_scm2double (space) - * Staff_symbol_referencer::staff_space (me)); + * Staff_symbol_referencer::staff_space (me), 0); } return mol.smobbed_copy (); } @@ -215,5 +249,29 @@ Text_item::brew_molecule (SCM smob) ADD_INTERFACE (Text_item,"text-interface", - "A scheme markup text", - "text align baseline-skip lookup raise kern word-space magnify"); + "A scheme markup text, see @ref{Markup functions}.", + "text baseline-skip word-space"); + + +/* + Ugh. Duplicated from Scheme. + */ +bool +new_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"))); +} + +SCM +new_markup_brewer () +{ + static SCM proc ; + + if (!proc) + proc = scm_c_eval_string ("brew-new-markup-molecule"); + + return proc; +}