- if (abs (pos) > interspaces + 1)
- {
- Interval head_size = h->extent (common[X_AXIS], X_AXIS);
- Interval ledger_size = head_size;
- ledger_size.widen (ledger_size.length ()* length_fraction);
-
- Interval max_size = reqs[Paper_column::get_rank (h->get_column ())][Direction (sign (pos))].ledger_extent_;
-
- ledger_size.intersect (max_size);
- Real left_shorten = 0.0;
- if (Grob *g = unsmob_grob (h->get_property ("accidental-grob")))
- {
- Interval accidental_size = g->extent (common[X_AXIS], X_AXIS);
- Real d
- = linear_combination (Drul_array<Real> (accidental_size[RIGHT],
- head_size[LEFT]),
- 0.0);
-
- left_shorten = (-ledger_size[LEFT] + d) >? 0;
-
- /*
- TODO: shorten 2 ledger lines for the case natural +
- downstem.
- */
-
- }
-
- ledgers.add_stencil (brew_ledger_lines (staff, pos, interspaces,
- halfspace,
- ledgerlinethickness,
- ledger_size,
- left_shorten));
- }
+ vector<Real> ledger_positions = Staff_symbol::ledger_positions (staff, pos);
+ if (!ledger_positions.empty ())
+ {
+ int ledger_count = ledger_positions.size ();
+ Interval head_size = h->extent (common[X_AXIS], X_AXIS);
+ Interval ledger_size = head_size;
+ ledger_size.widen (ledger_size.length () * length_fraction);
+
+ if (pos && !staff_extent.contains (pos))
+ {
+ Interval max_size = reqs[h->get_column ()->get_rank ()]
+ [Direction (sign (pos))].ledger_extent_;
+
+ if (!max_size.is_empty ())
+ ledger_size.intersect (max_size);
+ }
+
+ for (int i = 0; i < ledger_count; i++)
+ {
+ Real lpos = ledger_positions[i];
+ Interval x_extent = ledger_size;
+
+ if (i == 0)
+ if (Grob *g = Grob::unsmob (h->get_object ("accidental-grob")))
+ {
+ Interval accidental_size = g->extent (common[X_AXIS], X_AXIS);
+ Real d
+ = linear_combination (Drul_array<Real> (accidental_size[RIGHT],
+ head_size[LEFT]),
+ 0.0);
+
+ Real left_shorten = max (-ledger_size[LEFT] + d, 0.0);
+
+ x_extent[LEFT] += left_shorten;
+ /*
+ TODO: shorten 2 ledger lines for the case natural +
+ downstem.
+ */
+ }
+
+ Real blotdiameter = ledgerlinethickness;
+ Interval y_extent
+ = Interval (-0.5 * (ledgerlinethickness),
+ +0.5 * (ledgerlinethickness));
+ Stencil ledger_line
+ = Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter);
+
+ ledger_line.translate_axis ( lpos * halfspace, Y_AXIS);
+ ledgers.add_stencil (ledger_line);
+ }
+ }