+ cairo_glyph_t brace_glyph;
+ cairo_text_extents_t brace_extents;
+
+ cairo_save (cr);
+
+ cairo_select_font_face (cr, "Gonville-Brace", 0, 0);
+
+ /* XXX: This hard-coded glyph index is pretty ugly. We should
+ * figure out how to lookup the glyph we want, (though, as it
+ * turns out, this brace font pretty much just has numbered glyph
+ * names for different sizes, so it wouldn't be all that different
+ * than just the bare index here). */
+ brace_glyph.index = 300;
+ brace_glyph.x = 0;
+ brace_glyph.y = score->staff_height * (brace->first_staff + (2 * brace->num_staves - 1) / 2.0) + 1;
+
+ /* XXX: This font size (in conjunction with the glyph selection)
+ * is a rough guess at best. We should figure out how the brace
+ * font is intended to be used and actually measure to find the
+ * correctly-sized glyph. */
+ cairo_set_font_size (cr, (score->staff_height * 3) / 3.85);
+
+ cairo_glyph_extents (cr, &brace_glyph, 1, &brace_extents);
+
+ /* Subtract space for brace itself */
+ cairo_translate (cr, -brace_extents.x_bearing, 0);
+
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
+ cairo_show_glyphs (cr, &brace_glyph, 1);
+
+ cairo_restore (cr);
+
+ *brace_width = (int) -brace_extents.x_bearing;
+}
+
+/* Line containing middle C for the given clef. */
+static int
+_score_clef_c_line (score_clef_t clef)
+{
+ switch (clef)
+ {
+ default:
+ case SCORE_CLEF_G:
+ return 5;
+ case SCORE_CLEF_F:
+ return -1;
+ }
+}
+
+static double
+_score_note_to_line (score_staff_t *staff, score_note_t *note)
+{
+ score_pitch_name_t name = SCORE_PITCH_NAME (note->pitch);
+ int c_line = _score_clef_c_line (staff->clef);
+
+ return c_line - (name - SCORE_PITCH_NAME_C) / 2.0 - 3.5 * (note->octave - 4);
+}