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:
29 Chord_name::ly_word2molecule (SCM word) const
31 Dictionary<SCM> option_dict;
34 SCM options = gh_cdr (word);
36 while (gh_pair_p (options))
38 SCM option = gh_car (options);
39 if (option != SCM_UNDEFINED && option != SCM_BOOL_F
40 && gh_pair_p (option))
42 SCM key = gh_car (option);
43 SCM val = gh_cdr (option);
45 if (gh_symbol_p (key))
46 k = ly_symbol2string (key);
47 else if (gh_string_p (key))
48 k = ly_scm2string (key);
53 options = gh_cdr (options);
56 Real ex = lookup_l ()->text ("", "x", paper_l ()).extent
58 if (gh_string_p (word))
60 String w = ly_scm2string (word);
65 if (option_dict.elem_b ("size"))
66 size = gh_scm2int (option_dict["size"]);
69 if (option_dict.elem_b ("style"))
70 style = ly_scm2string (option_dict["style"]);
72 if (option_dict.elem_b ("type")
73 && ly_scm2string (option_dict["type"]) == "super")
75 Real super_y = ex / 2;
76 //super_y += -acc.extent ()[Y_AXIS][MIN];
77 offset = Offset (0, super_y);
81 if (option_dict.elem_b ("offset"))
84 SCM s = option_dict["offset"];
86 offset = Offset (gh_scm2double (gh_car (s)),
87 gh_scm2double (gh_cdr (s))) * ex;
89 if (option_dict.elem_b ("font")
90 && ly_scm2string (option_dict["font"]) == "feta")
91 mol = paper_l ()->lookup_l (size)->afm_find (w);
93 mol = paper_l ()->lookup_l (size)->text (style, w, paper_l ());
95 mol.translate (offset);
102 ;; text: list of word
103 ;; word: string + optional list of property
104 ;; property: align, kern, font (?), size
107 Chord_name::ly_text2molecule (SCM text) const
110 if (gh_list_p (text))
112 while (gh_cdr (text) != SCM_EOL)
114 Molecule m = ly_word2molecule (gh_car (text));
116 mol.add_at_edge (X_AXIS, RIGHT, m, 0);
117 text = gh_cdr (text);
119 text = gh_car (text);
121 Molecule m = ly_word2molecule (text);
123 mol.add_at_edge (X_AXIS, RIGHT, m, 0);
128 Chord_name::do_brew_molecule () const
130 SCM style = get_elt_property ("style");
131 if (style == SCM_UNDEFINED)
132 style = ly_str02scm ("banter");
134 SCM inversion = get_elt_property ("inversion");
135 if (inversion == SCM_UNDEFINED)
136 inversion = SCM_BOOL_F;
138 SCM bass = get_elt_property ("bass");
139 if (bass == SCM_UNDEFINED)
142 SCM pitches = get_elt_property ("pitches");
144 SCM text = scm_eval (gh_list (ly_symbol2scm ("chord::user-name"),
146 ly_quote_scm (pitches),
147 ly_quote_scm (gh_cons (inversion, bass)),
150 return ly_text2molecule (text);