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 UGH. remove Dictionary< >
32 Chord_name::ly_word2molecule (SCM word) const
34 Dictionary<SCM> option_dict; // junkme
37 SCM options = gh_cdr (word);
39 while (gh_pair_p (options))
41 SCM option = gh_car (options);
42 if (option != SCM_UNDEFINED && option != SCM_BOOL_F
43 && gh_pair_p (option))
45 SCM key = gh_car (option);
46 SCM val = gh_cdr (option);
48 if (gh_symbol_p (key))
49 k = ly_symbol2string (key);
50 else if (gh_string_p (key))
51 k = ly_scm2string (key);
56 options = gh_cdr (options);
59 Real ex = lookup_l ()->text ("", "x", paper_l ()).extent
61 if (gh_string_p (word))
63 String w = ly_scm2string (word);
68 if (option_dict.elem_b ("size"))
69 size = gh_scm2int (option_dict["size"]);
72 if (option_dict.elem_b ("style"))
73 style = ly_scm2string (option_dict["style"]);
75 if (option_dict.elem_b ("type")
76 && ly_scm2string (option_dict["type"]) == "super")
78 Real super_y = ex / 2;
79 //super_y += -acc.extent ()[Y_AXIS][MIN];
80 offset = Offset (0, super_y);
84 if (option_dict.elem_b ("offset"))
87 SCM s = option_dict["offset"];
89 offset = Offset (gh_scm2double (gh_car (s)),
90 gh_scm2double (gh_cdr (s))) * ex;
92 if (option_dict.elem_b ("font")
93 && ly_scm2string (option_dict["font"]) == "feta")
94 mol = paper_l ()->lookup_l (size)->afm_find (w);
96 mol = paper_l ()->lookup_l (size)->text (style, w, paper_l ());
98 mol.translate (offset);
105 ;; text: list of word
106 ;; word: string + optional list of property
107 ;; property: align, kern, font (?), size
110 Chord_name::ly_text2molecule (SCM text) const
113 if (gh_list_p (text))
115 while (gh_cdr (text) != SCM_EOL)
117 Molecule m = ly_word2molecule (gh_car (text));
119 mol.add_at_edge (X_AXIS, RIGHT, m, 0);
120 text = gh_cdr (text);
122 text = gh_car (text);
124 Molecule m = ly_word2molecule (text);
126 mol.add_at_edge (X_AXIS, RIGHT, m, 0);
131 Chord_name::do_brew_molecule () const
133 SCM style = get_elt_property ("style");
134 if (style == SCM_UNDEFINED)
135 style = ly_str02scm ("banter");
137 SCM inversion = get_elt_property ("inversion");
138 if (inversion == SCM_UNDEFINED)
139 inversion = SCM_BOOL_F;
141 SCM bass = get_elt_property ("bass");
142 if (bass == SCM_UNDEFINED)
145 SCM pitches = get_elt_property ("pitches");
147 SCM text = scm_eval (gh_list (ly_symbol2scm ("chord::user-name"),
149 ly_quote_scm (pitches),
150 ly_quote_scm (gh_cons (inversion, bass)),
153 return ly_text2molecule (text);