From eb3a20402b80c40a63b0d37200d179c930a1cf25 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 7 Dec 2002 14:14:24 +0000 Subject: [PATCH] * lily/text-engraver.cc (process_acknowledged_grobs): use new markup for new markup texts. * lily/mark-engraver.cc (process_music): idem * lily/instrument-name-engraver.cc (create_text): idem * scm/new-markup.scm (magnify-markup): new function. * scm/molecule.scm (stack-lines): bugfix. * lily/font-interface.cc (get_font): take font-magnification from alist chain. --- ChangeLog | 16 +++++++++++++ input/regression/font-magnification.ly | 4 ++-- input/regression/markup-stack.ly | 2 +- input/regression/new-markup-syntax.ly | 2 +- lily/font-interface.cc | 6 +++-- lily/include/text-item.hh | 4 ++++ lily/instrument-name-engraver.cc | 6 ++++- lily/mark-engraver.cc | 6 +++++ lily/paper-column.cc | 31 +++++++++++++------------- lily/parser.yy | 23 ++++++++++--------- lily/text-engraver.cc | 9 +++++++- lily/text-item.cc | 19 ++++++++++++++++ scm/molecule.scm | 10 ++++----- scm/new-markup.scm | 14 ++++++++---- 14 files changed, 108 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7478c88c9c..08ece5dc40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2002-12-07 Han-Wen Nienhuys + + * lily/text-engraver.cc (process_acknowledged_grobs): use new + markup for new markup texts. + + * lily/mark-engraver.cc (process_music): idem + + * lily/instrument-name-engraver.cc (create_text): idem + + * scm/new-markup.scm (magnify-markup): new function. + + * scm/molecule.scm (stack-lines): bugfix. + + * lily/font-interface.cc (get_font): take font-magnification from + alist chain. + 2002-12-06 Han-Wen Nienhuys * lily/molecule-scheme.cc: move scheme functions to separate file. diff --git a/input/regression/font-magnification.ly b/input/regression/font-magnification.ly index c1ce9bb5fa..cfc7a0e88d 100644 --- a/input/regression/font-magnification.ly +++ b/input/regression/font-magnification.ly @@ -9,8 +9,9 @@ c4 \property Voice .NoteHead \set #'font-magnification = #0.8 +c4-"normal" % why doesn't this work? - c4-#'((font-series . bold) ((font-magnification . 2.0) ("foobar"))) + c4-\markup \bold \magnify #2.0 "foobar" \property Voice .NoteHead \set #'font-magnification = #1.2 \property Voice.TextScript \set #'font-magnification = #2.0 @@ -22,4 +23,3 @@ c4 } %% new-chords-done %% -%% new-chords-done %% diff --git a/input/regression/markup-stack.ly b/input/regression/markup-stack.ly index 30fc3806a4..c7c6395418 100644 --- a/input/regression/markup-stack.ly +++ b/input/regression/markup-stack.ly @@ -1,6 +1,6 @@ \version "1.7.6" \header {texidoc="Stacking of markup scripts."} \paper { linewidth=-1. } -\score { \notes { c^#`(columns "" (lines "1" (bold "2") "3"))}} +\score { \notes { c''^\markup { "a" \column < "1" \bold "2" "3" > } } } %% new-chords-done %% diff --git a/input/regression/new-markup-syntax.ly b/input/regression/new-markup-syntax.ly index 5a71629707..b9a482aef6 100644 --- a/input/regression/new-markup-syntax.ly +++ b/input/regression/new-markup-syntax.ly @@ -11,7 +11,7 @@ texidoc = "New markup syntax." \property Voice.TextScript \set #'molecule-callback = #brew-new-markup-molecule f'-\markup { foo \raise #0.2 \bold bar - \column < baz bazr > + \override #'(baseline-skip . 4) \column < baz bazr bla > \hspace #2.0 \override #'(font-family . music) { \lookup #"noteheads-0" diff --git a/lily/font-interface.cc b/lily/font-interface.cc index 65d4c6a5a8..e3fc738fd4 100644 --- a/lily/font-interface.cc +++ b/lily/font-interface.cc @@ -119,8 +119,10 @@ Font_interface::get_font (Grob *me, SCM chain) name = gh_call2 (proc, fonts, chain); } - SCM mag = me->get_grob_property ("font-magnification"); - Real rmag = gh_number_p (mag) ? gh_scm2double (mag) : 1.0; + SCM mag = ly_assoc_chain (ly_symbol2scm ("font-magnification"), chain); + + Real rmag = gh_pair_p (mag) && gh_number_p (gh_cdr (mag)) + ? gh_scm2double (gh_cdr (mag)) : 1.0; Font_metric *fm = me->get_paper ()->find_font (name, rmag); return fm; diff --git a/lily/include/text-item.hh b/lily/include/text-item.hh index 70a7609d21..4de0766c73 100644 --- a/lily/include/text-item.hh +++ b/lily/include/text-item.hh @@ -30,4 +30,8 @@ private: static Molecule lookup_text (Grob *me, Font_metric*, SCM text); }; +bool new_markup_p (SCM) ; +SCM new_markup_brewer (); + + #endif /* TEXT_ITEM */ diff --git a/lily/instrument-name-engraver.cc b/lily/instrument-name-engraver.cc index ed9dbadcb7..593de87001 100644 --- a/lily/instrument-name-engraver.cc +++ b/lily/instrument-name-engraver.cc @@ -15,6 +15,7 @@ #include "align-interface.hh" #include "axis-group-interface.hh" #include "translator-group.hh" +#include "text-item.hh" class Instrument_name_engraver : public Engraver { @@ -66,7 +67,10 @@ Instrument_name_engraver::create_text (SCM txt) if (text_->get_grob_property ("text") != txt) text_->set_grob_property ("text", txt); - + + if (new_markup_p (txt)) + text_->set_grob_property ("molecule-callback", new_markup_brewer()); + if (delim_) text_->set_parent (delim_, Y_AXIS); diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc index 96ca4ffcba..6457ea1b2b 100644 --- a/lily/mark-engraver.cc +++ b/lily/mark-engraver.cc @@ -19,6 +19,7 @@ #include "staff-symbol-referencer.hh" #include "item.hh" #include "group-interface.hh" +#include "text-item.hh" /** put stuff over or next to bars. Examples: bar numbers, marginal notes, @@ -127,6 +128,11 @@ Mark_engraver::process_music () */ SCM m = mark_req_->get_mus_property ("label"); + if (new_markup_p (m)) + { + text_->set_grob_property ("text",m); + text_->set_grob_property ("molecule-callback", new_markup_brewer ()); + } if (gh_pair_p (m)) // markup text text_->set_grob_property ("text",m); else diff --git a/lily/paper-column.cc b/lily/paper-column.cc index bfb71a0272..b9393c411e 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -22,22 +22,21 @@ ADD_INTERFACE (Paper_column, "paper-column-interface", - " Paper_columns form the top-most item parent. (The Paper_columns X - parent is System, which is a spanner.) - - Paper_columns form the units for the spacing engine. They are - numbered, the first (leftmost) is column 0. Numbering happens before - line-breaking, and columns are not renumbered after line breaking. - - Since many columns go unused, you should only use the rank field to - get ordering information. Two adjacent columns may have - non-adjacent numbers. - - Don't be confused by right-items: each spacing wish can also contain - a number of items, with which a spacing constraint may be kept. It's - a little baroque, but it might come in handy later on? - -", + " Paper_columns form the top-most item parent. (The Paper_columns X\n" +" parent is System, which is a spanner.)\n" +"\n" +" Paper_columns form the units for the spacing engine. They are\n" +" numbered, the first (leftmost) is column 0. Numbering happens before\n" +" line-breaking, and columns are not renumbered after line breaking.\n" +"\n" +" Since many columns go unused, you should only use the rank field to\n" +" get ordering information. Two adjacent columns may have\n" +" non-adjacent numbers.\n" +"\n" +" Don't be confused by right-items: each spacing wish can also contain\n" +" a number of items, with which a spacing constraint may be kept. It's\n" +" a little baroque, but it might come in handy later on?\n" +"\n", "between-cols between-system-string when bounded-by-me shortest-playing-duration shortest-starter-duration"); diff --git a/lily/parser.yy b/lily/parser.yy index 4eb694f409..174e84ac2c 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -79,6 +79,7 @@ TODO: #include "music-sequence.hh" #include "input-smob.hh" #include "event.hh" +#include "text-item.hh" bool regular_identifier_b (SCM id) @@ -95,6 +96,15 @@ regular_identifier_b (SCM id) return v; } +SCM +make_simple_markup (SCM a) +{ + static SCM simple; + if (!simple) + simple = scm_c_eval_string ("simple-markup"); + + return scm_list_n (simple, a, SCM_UNDEFINED); +} bool @@ -1638,10 +1648,7 @@ gen_text_def: $$ = t; } | string { - Music *t = MY_MAKE_MUSIC("TextScriptEvent"); - t->set_mus_property ("text", $1); - t->set_spot (THIS->here_input ()); - $$ = t; + $$ = make_simple_markup ($1); } | DIGIT { Music * t = MY_MAKE_MUSIC("FingerEvent"); @@ -2172,11 +2179,7 @@ full_markup: markup: STRING { - static SCM simple; - if (!simple) - simple = scm_c_eval_string ("simple-markup"); - - $$ = scm_list_n (simple, $1, SCM_UNDEFINED); + $$ = make_simple_markup ($1); } | MARKUP_HEAD_MARKUP0 markup { $$ = scm_list_n ($1, $2, SCM_UNDEFINED); @@ -2311,7 +2314,7 @@ My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid) *destination = p->self_scm(); return MUSIC_OUTPUT_DEF_IDENTIFIER; - } else if (markup_p (sid)) { + } else if (new_markup_p (sid)) { *destination = sid; return MARKUP_IDENTIFIER; } diff --git a/lily/text-engraver.cc b/lily/text-engraver.cc index 714ed9004b..486de81cac 100644 --- a/lily/text-engraver.cc +++ b/lily/text-engraver.cc @@ -14,6 +14,7 @@ #include "event.hh" #include "stem.hh" #include "rhythmic-head.hh" +#include "text-item.hh" /** @@ -111,8 +112,14 @@ Text_engraver::process_acknowledged_grobs () Direction dir = to_dir (r->get_mus_property ("direction")); if (dir) Side_position_interface::set_direction (text, dir); + + + SCM mark = r->get_mus_property ("text"); + + if (new_markup_p (mark)) + text->set_grob_property ("molecule-callback", new_markup_brewer()); - text->set_grob_property ("text", r->get_mus_property ("text")); + text->set_grob_property ("text", mark); announce_grob (text, r->self_scm ()); texts_.push (text); } diff --git a/lily/text-item.cc b/lily/text-item.cc index c1a63c94c3..916185be14 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -251,3 +251,22 @@ Text_item::brew_molecule (SCM smob) ADD_INTERFACE (Text_item,"text-interface", "A scheme markup text", "text axis baseline-skip extent lookup raise kern word-space"); + + +bool +new_markup_p (SCM x) +{ + return 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; +} diff --git a/scm/molecule.scm b/scm/molecule.scm index 0e3f21ecaa..5de26e4a58 100644 --- a/scm/molecule.scm +++ b/scm/molecule.scm @@ -16,15 +16,15 @@ "Stack vertically with a baseline-skip." (if (null? mols) '() - (if (pair? mols) + (if (null? (cdr mols)) + (car mols) (ly:combine-molecule-at-edge (car mols) Y dir - (stack-lines Y dir padding (cdr mols)) - padding baseline + (stack-lines dir padding baseline (cdr mols)) + padding baseline ) ) )) - (define-public (fontify-text font-metric text) "Set TEXT with font FONT-METRIC, returning a molecule." (let* ((b (ly:text-dimension font-metric text))) @@ -45,8 +45,6 @@ mol )) - - (define-public (box-molecule xext yext) "Make a filled box." diff --git a/scm/new-markup.scm b/scm/new-markup.scm index 4dfb2cbdb7..5f90f7f3e0 100644 --- a/scm/new-markup.scm +++ b/scm/new-markup.scm @@ -1,6 +1,3 @@ - - - (define-public (simple-markup grob props . rest) (Text_item::text_to_molecule grob props (car rest)) ) @@ -25,6 +22,13 @@ )) +(define-public (magnify-markup grob props . rest ) + (interpret-markup grob + (cons (cons `(font-magnification . ,(car rest)) + (car props)) (cdr props)) + (cadr rest)) + ) + (define-public bold-markup (font-markup 'font-series 'bold)) (define-public dynamic-markup @@ -32,6 +36,8 @@ (define-public italic-markup (font-markup 'font-shape 'italic)) + +;; TODO: baseline-skip should come from the font. (define-public (column-markup grob props . rest) (stack-lines -1 0.0 (cdr (chain-assoc 'baseline-skip props)) @@ -86,7 +92,7 @@ (cons dynamic-markup 'markup0) (cons char-markup 'scm0) (cons hspace-markup 'scm0) - + (cons magnify-markup 'scm0-markup1) )) -- 2.39.2