- Real staffht = me->paper_l ()->get_var ("staffheight");
- int staff_size = int (rint (staffht ));
-
- // URG
- Real step = 1.0;
- int minht = 2 * staff_size;
- int maxht = 7 * minht;
- int idx = int (((maxht - step) <? y - minht) / step);
- idx = idx >? 0;
-
- SCM l = scm_assoc (ly_str02scm ("brace"),
- scm_eval2 (ly_symbol2scm ("cmr-alist"), SCM_EOL));
-
- String nm = "feta-braces";
- if (l != SCM_BOOL_F)
- nm = ly_scm2string (gh_cdr (l));
- nm += to_str (staff_size);
- SCM e =gh_list (ly_symbol2scm ("char"), gh_int2scm (idx), SCM_UNDEFINED);
- SCM at = (e);
-
- at = fontify_atom (find_font (nm), at);
-
- Box b (Interval (0,0), Interval (-y/2, y/2));
+ Font_metric *fm = 0;
+ /* We go through the style sheet to lookup the font file
+ name. This is better than using find_font directly,
+ esp. because that triggers mktextfm for non-existent
+ fonts. */
+ SCM fam = scm_cons (ly_symbol2scm ("font-encoding"),
+ ly_symbol2scm ("fetaBraces"));
+
+ SCM alist = scm_list_n (fam, SCM_UNDEFINED);
+ fm = select_font (me->get_layout (), scm_list_n (alist, SCM_UNDEFINED));
+
+ int lo = 0;
+ int hi = (fm->count () - 1) >? 2;
+ Box b;
+
+ /* do a binary search for each Y, not very efficient, but passable? */
+ do
+ {
+ int cmp = (lo + hi) / 2;
+ b = fm->get_indexed_char (cmp);
+ if (b[Y_AXIS].is_empty () || b[Y_AXIS].length () > y)
+ hi = cmp;
+ else
+ lo = cmp;
+ }
+ while (hi - lo > 1);
+
+ Stencil stil (fm->find_by_name ("brace" + to_string (lo)));
+ b = stil.extent_box ();
+ b[X_AXIS] = Interval (0, 0);