From: Han-Wen Nienhuys Date: Tue, 5 Apr 2005 10:49:42 +0000 (+0000) Subject: * lily/text-interface.cc (Module): rename from text-item.cc X-Git-Tag: release/2.5.18~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ed32442d90825777d09672a871940674b308a2da;p=lilypond.git * lily/text-interface.cc (Module): rename from text-item.cc * input/regression/apply-output.ly (texidoc): function naming fix. --- diff --git a/ChangeLog b/ChangeLog index aa5fe5bacd..55de0e226f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2005-04-05 Han-Wen Nienhuys + * lily/text-interface.cc (Module): rename from text-item.cc + + * input/regression/apply-output.ly (texidoc): function naming fix. + * lily/time-signature-performer.cc (derived_mark): new function. * lily/lily-parser-scheme.cc: print mapped file name for progress diff --git a/input/regression/apply-output.ly b/input/regression/apply-output.ly index 5f0747dabd..24394976fe 100644 --- a/input/regression/apply-output.ly +++ b/input/regression/apply-output.ly @@ -20,7 +20,7 @@ position. (if (and (memq 'note-head-interface ifs) (memq sp '(-2 -3 -5))) (begin - (ly:grob-set-property! gr 'print-function brew-new-markup-stencil) + (ly:grob-set-property! gr 'print-function Text_interface::print) (ly:grob-set-property! gr 'font-family 'roman) (ly:grob-set-property! gr 'text diff --git a/lily/text-interface.cc b/lily/text-interface.cc new file mode 100644 index 0000000000..5524d5a0b1 --- /dev/null +++ b/lily/text-interface.cc @@ -0,0 +1,96 @@ +/* + text-item.cc -- implement Text_interface + + source file of the GNU LilyPond music typesetter + + (c) 1998--2005 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 "font-interface.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_interface, interpret_markup, 3); +SCM +Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup) +{ + if (scm_is_string (markup)) + return interpret_string (layout_smob, props, markup); + else if (scm_is_pair (markup)) + { + SCM func = scm_car (markup); + SCM args = scm_cdr (markup); + if (!markup_p (markup)) + programming_error ("Markup head has no markup signature."); + + return scm_apply_2 (func, layout_smob, props, args); + } + else + { + 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_interface, print, 1); +SCM +Text_interface::print (SCM grob) +{ + 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. */ +bool +Text_interface::markup_p (SCM x) +{ + 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_interface, "text-interface", + "A scheme markup text, see @usermanref{Text markup}.", + "text baseline-skip word-space"); + diff --git a/lily/text-item.cc b/lily/text-item.cc deleted file mode 100644 index 5524d5a0b1..0000000000 --- a/lily/text-item.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - text-item.cc -- implement Text_interface - - source file of the GNU LilyPond music typesetter - - (c) 1998--2005 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 "font-interface.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_interface, interpret_markup, 3); -SCM -Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup) -{ - if (scm_is_string (markup)) - return interpret_string (layout_smob, props, markup); - else if (scm_is_pair (markup)) - { - SCM func = scm_car (markup); - SCM args = scm_cdr (markup); - if (!markup_p (markup)) - programming_error ("Markup head has no markup signature."); - - return scm_apply_2 (func, layout_smob, props, args); - } - else - { - 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_interface, print, 1); -SCM -Text_interface::print (SCM grob) -{ - 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. */ -bool -Text_interface::markup_p (SCM x) -{ - 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_interface, "text-interface", - "A scheme markup text, see @usermanref{Text markup}.", - "text baseline-skip word-space"); -