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 styled text:
30 UGH. remove Dictionary< > and use Scheme_hash_table
33 Chord_name::ly_word2molecule (SCM word) const
35 Dictionary<SCM> option_dict; // junkme
38 SCM options = gh_cdr (word);
40 while (gh_pair_p (options))
42 SCM option = gh_car (options);
43 if (option != SCM_UNDEFINED && option != SCM_BOOL_F
44 && gh_pair_p (option))
46 SCM key = gh_car (option);
47 SCM val = gh_cdr (option);
49 if (gh_symbol_p (key))
50 k = ly_symbol2string (key);
51 else if (gh_string_p (key))
52 k = ly_scm2string (key);
57 options = gh_cdr (options);
60 Real ex = lookup_l ()->text ("", "x", paper_l ()).extent
62 if (gh_string_p (word))
64 String w = ly_scm2string (word);
69 if (option_dict.elem_b ("size"))
70 size = gh_scm2int (option_dict["size"]);
73 if (option_dict.elem_b ("style"))
74 style = ly_scm2string (option_dict["style"]);
76 if (option_dict.elem_b ("type")
77 && ly_scm2string (option_dict["type"]) == "super")
79 Real super_y = ex / 2;
80 //super_y += -acc.extent ()[Y_AXIS][MIN];
81 offset = Offset (0, super_y);
85 if (option_dict.elem_b ("offset"))
88 SCM s = option_dict["offset"];
90 offset = Offset (gh_scm2double (gh_car (s)),
91 gh_scm2double (gh_cdr (s))) * ex;
93 if (option_dict.elem_b ("font")
94 && ly_scm2string (option_dict["font"]) == "feta")
95 mol = paper_l ()->lookup_l (size)->afm_find (w);
97 mol = paper_l ()->lookup_l (size)->text (style, w, paper_l ());
99 mol.translate (offset);
106 ;; text: list of word
107 ;; word: string + optional list of property
108 ;; property: align, kern, font (?), size
111 Chord_name::ly_text2molecule (SCM text) const
114 if (gh_list_p (text))
116 while (gh_cdr (text) != SCM_EOL)
118 Molecule m = ly_word2molecule (gh_car (text));
120 mol.add_at_edge (X_AXIS, RIGHT, m, 0);
121 text = gh_cdr (text);
123 text = gh_car (text);
125 Molecule m = ly_word2molecule (text);
127 mol.add_at_edge (X_AXIS, RIGHT, m, 0);
132 Chord_name::do_brew_molecule () const
134 SCM style = get_elt_property ("style");
135 if (style == SCM_UNDEFINED)
136 style = ly_str02scm ("banter");
138 SCM inversion = get_elt_property ("inversion");
139 if (inversion == SCM_UNDEFINED)
140 inversion = SCM_BOOL_F;
142 SCM bass = get_elt_property ("bass");
143 if (bass == SCM_UNDEFINED)
146 SCM pitches = get_elt_property ("pitches");
148 SCM text = scm_eval (gh_list (ly_symbol2scm ("chord::user-name"),
150 ly_quote_scm (pitches),
151 ly_quote_scm (gh_cons (inversion, bass)),
154 return ly_text2molecule (text);