From 617eb05b0c5da1377d5ebe1ef7f5bd99a796fbbe Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 24 May 2002 11:49:45 +0000 Subject: [PATCH] (markup_text2molecule): Junk ugly lookahead by using translate-robust add_molecule instead of add_at_edge. Bugfix for #(lines (finger "" "1")). --- ChangeLog | 6 +++ input/test/markup.ly | 108 +++++++++++++++++++++++++++++-------------- lily/text-item.cc | 64 ++++++------------------- 3 files changed, 94 insertions(+), 84 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25534d9db8..fa5d23ab60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-05-24 Jan Nieuwenhuizen + + * lily/text-item.cc (markup_text2molecule): Junk ugly lookahead by + using translate-robust add_molecule instead of add_at_edge. + Bugfix for #(lines (finger "" "1")). + 2002-05-24 Han-Wen * lily/stem-tremolo.cc (brew_molecule): clean up and fix stem diff --git a/input/test/markup.ly b/input/test/markup.ly index 17474621c2..01ab852e53 100644 --- a/input/test/markup.ly +++ b/input/test/markup.ly @@ -1,43 +1,81 @@ \version "1.3.146" +\header { + texidoc ="Test font selection and scm text markup" +%% Note that the font-encoding trick only works when uning latex, +%% ie, you must use ly2dvi. +} -% -% Test new font selection and scm text markup -% \score{ - \notes\relative c''{ - \stemUp -% { - a-"text" - b-#"texta" - c-#'(bold "textb") + \notes\relative c''{ + \stemUp + % { + a-"text" + b-#"texta" + c-#'(bold "textb") - d-#'(lines "one" "two" "three") - e-#'(lines (bold "one") - (columns "and" "there" "is" ((font-family . number) "2")) - (italic "three")) - f-#'(finger "3") - g-#'(music (named "noteheads-2" "flags-u3")) - b-#'(columns "a" (((kern . 3) (raise . 2)) "b") "c") - c-#'(columns "1" (((raise . -2) (kern . -1)) "2") "3") -% } - d-#'(lines "Violoncello" " e" "Contrabasso") - e-#'((lines (baselineskip . 0) (kern . 1.5)) "Violoncello" " e" "Contrabasso") - e-#'(((baselineskip . 0) (kern . 1.5) lines) "Violoncello" " e" "Contrabasso") - g-"ÅÖÄÜÇÕ" - } - \paper{ - linewidth = -1.\mm - fontenc = "T1" - \translator{ - \ScoreContext - TextScript \override #'font-family = #'roman - TextScript \override #'font-shape = #'upright - TextScript \revert #'no-spacing-rods - TextScript \override #'direction = #1 - TextScript \override #'font-encoding = #'T1 - } - } + d-#'(lines "one" "two" "three") + e-#'(lines (bold "one") + (columns "and" "there" "is" ((font-family . number) "2")) + (italic "three")) + f-#'(finger "3") + g-#'(music (named "noteheads-2" + ((kern . -0.1) "flags-stem") + (((kern . -0.1) (raise . 3.5)) "flags-u3")))) + b-#'(columns "a" (((kern . 3) (raise . 2)) "b") "c") + c-#'(columns "1" (((raise . -2) (kern . -1)) "2") "3") + % } + d-#'(lines "Violoncello" " e" "Contrabasso") + e-#'((lines (baselineskip . 0) (kern . 1.5)) "Violoncello" " e" "Contrabasso") + e-#'(((baselineskip . 0) (kern . 1.5) lines) "Violoncello" " e" "Contrabasso") + g-"ÅÖÄÜÇÕ" + c,, + c1 c1 + + \stemUp + c4^#'(lines "1" "" "2") + c^#'(lines "3" "4" "5") + \stemDown + c_#'(lines "6" "" "7") + c_#'(lines "8" "9" "0") + + \stemUp + c4^#'(lines "1" "") + c^#'(lines "2" "3") + \stemDown + c_#'(lines "" "4") + c_#'(lines "5" "6") + + c^#'(columns "foe" ((raise . 3) "bar")) + c^#'(columns "foe" (super "12") (sub "3 4")) + c^#'(columns "foe" (super (overstrike "o") "/") (sub "x")) + c^#'(columns "foe" (overstrike "o") "/") + c^#'(columns "foe" ((bold roman overstrike) "o") "/") + c^#'(columns "foe" ((extent . (0 . 0)) "o") "/") + c^#'(columns "foo" (super "bar" (super "baz"))) + c + %% c^#`(columns (lines "" ";" "") (lines "1" ((bold) "2") "3")) + c^#`(columns (lines "" ";" "") (lines "1" "2" "3")) + c^#`(columns (lines "" ";" "") (lines "1" (bold "2") "3")) + c^#`(columns (lines "" ";" "") (lines "1" (columns (bold "2")) "3")) + + + } + \paper{ + %linewidth = -1.\mm + fontenc = "T1" + \translator{ + \ScoreContext + TextScript \override #'font-family = #'roman + TextScript \override #'font-shape = #'upright + TextScript \revert #'no-spacing-rods + TextScript \override #'direction = #1 + TextScript \override #'font-encoding = #'T1 + } + } } +%%% Local variables: +%%% LilyPond-indent-level:2 +%%% End: diff --git a/lily/text-item.cc b/lily/text-item.cc index a63c3784d5..2ee9cd14c0 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -17,6 +17,7 @@ #include "main.hh" #include "all-font-metrics.hh" #include "afm.hh" +#include "lookup.hh" /* @@ -96,6 +97,7 @@ Text_item::lookup_text (Grob *me, Font_metric*fm, SCM text) return Molecule (fm->text_dimension (ly_scm2string (text)), list); } + /* TODO: @@ -154,73 +156,37 @@ Text_item::markup_text2molecule (Grob *me, SCM markup_text, extent_b = true; } - Offset o (0, (axis == Y_AXIS ? - kern[axis] : 0)); + Offset o (kern[X_AXIS], raise - kern[Y_AXIS]); - Molecule mol; + + Molecule mol = Lookup::filledbox (Box (Interval (0,0), Interval (0,0))); + while (gh_pair_p (text)) { - Molecule m = text2molecule (me, ly_car (text), p); - /* - TODO: look at padding? - - Look ahead here for kern and raise. - - (cols "foo" ((raise . 1) "bar")) - (cols "foo" ((bold (raise . 1)) "bar")) - - When constructing the molecule for bar, all normal extra - properties found, such as bold, are used for the construction - of bar's molecule. But for kern or raise, it seems that we're - too late then, translating bar's molecule has no effect (or - maybe the effect of translating gets nullified when bar's - molecule is `added_to_edge' of the molecule for foo?) - - So, while constructing foo's molecule, we look ahead for the - raise of bar. The HEAD of the description of bar may be a - single property, or a list, so we must check that too. - */ - - SCM next_p = SCM_EOL; - if (gh_pair_p (ly_car (text))) - next_p = scm_list_n (gh_call2 (f, sheet, ly_caar (text)), SCM_UNDEFINED); - SCM next_k = ly_assoc_chain (ly_symbol2scm ("kern"), next_p); - Real next_kern = kern[axis]; - if (gh_pair_p (next_k) && gh_number_p (ly_cdr (next_k))) - next_kern = gh_scm2double (ly_cdr (next_k)) * staff_space; - - SCM next_r = ly_assoc_chain (ly_symbol2scm ("raise"), next_p); - Real next_raise = 0; - if (gh_pair_p (next_r) && gh_number_p (ly_cdr (next_r))) - next_raise = gh_scm2double (ly_cdr (next_r)) * staff_space; - - o[Y_AXIS] = next_raise; - if (!m.empty_b ()) { - m.translate (o); - if (mol.empty_b ()) - mol = m; - else - { - if (axis == Y_AXIS && baseline_skip) - next_kern += baseline_skip - m.extent (Y_AXIS)[UP]; - mol.add_at_edge (axis, axis == X_AXIS ? RIGHT : DOWN, m, next_kern); - } + m.translate_axis (mol.extent (axis)[axis == X_AXIS ? RIGHT : DOWN] + - (axis == Y_AXIS ? baseline_skip : 0), + axis); + mol.add_molecule (m); } text = ly_cdr (text); } + /* Set extend to markup requested value. */ if (extent_b) { - /* we're not setting extents for unknown reasons. */ Box b = mol.extent_box (); SCM expr = mol.get_expr (); b[axis] = extent; mol = Molecule (b, expr); - } + } + + mol.translate (o); + return mol; } -- 2.39.5