2 stencil-interpret.cc -- implement Stencil expression interpreting
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
12 interpret_stencil_expression (SCM expr,
13 void (*func) (void *, SCM),
19 if (!scm_is_pair (expr))
22 SCM head = scm_car (expr);
24 if (head == ly_symbol2scm ("translate-stencil"))
26 o += ly_scm2offset (scm_cadr (expr));
27 expr = scm_caddr (expr);
29 else if (head == ly_symbol2scm ("combine-stencil"))
32 for (SCM x = scm_cdr (expr); scm_is_pair (x); x = scm_cdr (x))
33 interpret_stencil_expression (scm_car (x), func, func_arg, o);
36 else if (head == ly_symbol2scm ("grob-cause"))
38 SCM grob = scm_cadr (expr);
40 (*func) (func_arg, scm_list_3 (head,
41 ly_quote_scm (ly_offset2scm (o)), grob));
42 interpret_stencil_expression (scm_caddr (expr), func, func_arg, o);
43 (*func) (func_arg, scm_list_1 (ly_symbol2scm ("no-origin")));
46 else if (head == ly_symbol2scm ("color"))
48 SCM color = scm_cadr (expr);
49 SCM r = scm_car (color);
50 SCM g = scm_cadr (color);
51 SCM b = scm_caddr (color);
53 (*func) (func_arg, scm_list_4 (ly_symbol2scm ("setcolor"), r, g, b));
54 interpret_stencil_expression (scm_caddr (expr), func, func_arg, o);
55 (*func) (func_arg, scm_list_1 (ly_symbol2scm ("resetcolor")));
59 else if (head == ly_symbol2scm ("rotate-stencil"))
61 SCM args = scm_cadr (expr);
62 SCM angle = scm_car (args);
63 Offset tmp = o + robust_scm2offset (scm_cadr (args), Offset (0.0, 0.0));
65 SCM offset = ly_offset2scm (tmp);
66 SCM x = scm_car (offset);
67 SCM y = scm_cdr (offset);
69 (*func) (func_arg, scm_list_4 (ly_symbol2scm ("setrotation"), angle, x, y));
70 interpret_stencil_expression (scm_caddr (expr), func, func_arg, o);
71 (*func) (func_arg, scm_list_4 (ly_symbol2scm ("resetrotation"), angle, x, y));
78 scm_list_4 (ly_symbol2scm ("placebox"),
79 scm_from_double (o[X_AXIS]),
80 scm_from_double (o[Y_AXIS]),
93 find_font_function (void *fs, SCM x)
95 Font_list *me = (Font_list *) fs;
97 if (scm_car (x) == ly_symbol2scm ("placebox"))
99 SCM args = scm_cdr (x);
100 SCM what = scm_caddr (args);
102 if (scm_is_pair (what))
104 SCM head = scm_car (what);
105 if (ly_symbol2scm ("text") == head)
106 me->fonts_ = scm_cons (scm_cadr (what), me->fonts_);
107 else if (head == ly_symbol2scm ("char"))
108 me->fonts_ = scm_cons (scm_cadr (what), me->fonts_);
114 find_expression_fonts (SCM expr)
120 interpret_stencil_expression (expr, &find_font_function,
121 (void *) & fl, Offset (0, 0));