+ head-expression is a list, containing a tag and a variable number of
+ arguments. If necessary, the number of arguments can be stored in a alist,
+
+ '(
+ (tag1 . argcount1)
+ (tag2 . argcount2)
+
+ ... etc
+
+ )
+
+ or even entries like
+
+ (tag . (argcount function-to-handle-the-tag ))
+
+ */
+
+Molecule
+Text_item::text2molecule (Score_element *me, SCM text, SCM alist_chain)
+{
+ if (gh_string_p (text))
+ return string2molecule (me, text, alist_chain);
+ else if (gh_list_p (text))
+ {
+ if (!gh_pair_p (gh_car (text)) && gh_string_p (gh_car (text)))
+ return string2molecule (me, gh_car (text), alist_chain);
+ else
+ return markup_sentence2molecule (me, text, alist_chain);
+ }
+ return Molecule ();
+}
+
+SCM
+ly_assoc_chain (SCM key, SCM achain)
+{
+ if (gh_pair_p (achain))
+ {
+ SCM handle = scm_assoc (key, gh_car (achain));
+ if (gh_pair_p (handle))
+ return handle;
+ else
+ return ly_assoc_chain (key, gh_cdr (achain));
+ }
+ else
+ return SCM_BOOL_F;
+}
+
+Molecule
+Text_item::string2molecule (Score_element *me, SCM text, SCM alist_chain)
+{
+ SCM style = ly_assoc_chain (ly_symbol2scm ("font-style"),
+ alist_chain);
+ if (gh_pair_p (style))
+ style = gh_cdr (style);
+
+ SCM sheet = me->paper_l ()->style_sheet_;
+
+ if (gh_symbol_p (style))
+ {
+ SCM style_alist = gh_cdr (scm_assoc (ly_symbol2scm ("style-alist"), sheet));
+ SCM entry = scm_assoc (style, style_alist);
+ entry = gh_pair_p (entry) ? gh_cdr (entry) : SCM_EOL;
+ alist_chain = gh_cons (entry, alist_chain);
+ }
+
+ SCM fonts = gh_cdr (scm_assoc (ly_symbol2scm ("fonts"), sheet));
+ SCM proc = gh_cdr (scm_assoc (ly_symbol2scm ("properties-to-font"), sheet));
+ SCM font_name = gh_call2 (proc, fonts, alist_chain);