2 chord-name.cc -- implement Chord_name
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2000 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "chord-name.hh"
10 #include "musical-request.hh"
13 #include "molecule.hh"
14 #include "paper-def.hh"
16 #include "staff-symbol-referencer.hh"
20 TODO: move text lookup out of Chord_name
24 word is roman text or property-styled text:
26 ("text" . property-alist)
30 Chord_name::ly_word2molecule (SCM word, Real* x) const
34 SCM options = SCM_EOL;
37 options = gh_cdr (word);
41 if (gh_string_p (word))
44 UGH. Should read from font metric structure.
46 Real ex = lookup_l ()->text ("", "x",
47 paper_l ()).extent (Y_AXIS).length ();
48 Real em = lookup_l ()->text ("", "m",
49 paper_l ()).extent (X_AXIS).length ();
51 String w = ly_scm2string (word);
54 SCM s = scm_assoc (ly_symbol2scm ("style"), options);
57 style = ly_scm2string (gh_cdr (s));
65 s = scm_assoc (ly_symbol2scm ("type"), options);
66 if (s != SCM_BOOL_F && ly_scm2string (gh_cdr (s)) == "super")
68 Real super_y = ex / 2;
69 offset = Offset (0, super_y);
74 s = scm_assoc (ly_symbol2scm ("size"), options);
77 size = gh_scm2int (gh_cdr (s));
80 s = scm_assoc (ly_symbol2scm ("offset"), options);
86 offset = Offset (0, gh_scm2double (gh_cdr (o))) * ex;
87 *x = gh_scm2double (gh_car (o)) * em;
91 s = scm_assoc (ly_symbol2scm ("font"), options);
92 if (s != SCM_BOOL_F && ly_scm2string (gh_cdr (s)) == "feta")
93 mol = paper_l ()->lookup_l (size)->afm_find (w);
95 mol = paper_l ()->lookup_l (size)->text (style, w, paper_l ());
97 mol.translate (offset);
104 ;; text: list of word
105 ;; word: string + optional list of property
106 ;; property: align, kern, font (?), size
109 Chord_name::ly_text2molecule (SCM text) const
112 if (gh_list_p (text))
114 while (gh_cdr (text) != SCM_EOL)
117 Molecule m = ly_word2molecule (gh_car (text), &x);
119 mol.add_at_edge (X_AXIS, RIGHT, m, x);
120 text = gh_cdr (text);
122 text = gh_car (text);
125 Molecule m = ly_word2molecule (text, &x);
127 mol.add_at_edge (X_AXIS, RIGHT, m, x);
131 MAKE_SCHEME_SCORE_ELEMENT_CALLBACKS(Chord_name);
134 Chord_name::do_brew_molecule () const
136 SCM style = get_elt_property ("style");
137 if (style == SCM_UNDEFINED)
138 style = ly_str02scm ("banter");
140 SCM inversion = get_elt_property ("inversion");
141 if (inversion == SCM_UNDEFINED)
142 inversion = SCM_BOOL_F;
144 SCM bass = get_elt_property ("bass");
145 if (bass == SCM_UNDEFINED)
148 SCM pitches = get_elt_property ("pitches");
150 SCM text = scm_eval (gh_list (ly_symbol2scm ("chord::user-name"),
152 ly_quote_scm (pitches),
153 ly_quote_scm (gh_cons (inversion, bass)),
156 return ly_text2molecule (text);
159 Chord_name::Chord_name (SCM s)