From b92ea16ef75d8aaa7bdb9f492b58d7af906e7945 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Janek=20Warcho=C5=82?= Date: Sun, 13 Mar 2011 11:33:25 +0100 Subject: [PATCH] Ends of barlines are hidden in staff lines. Barlines are made a little shorter, so that the end of the barline doesn't touch the outer edge of staff line - it ends in the middle of staff line now. This prevets artifacts in pdf viewing and printing. --- lily/bar-line.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lily/bar-line.cc b/lily/bar-line.cc index a56c5f6408..e256e8fe55 100644 --- a/lily/bar-line.cc +++ b/lily/bar-line.cc @@ -34,8 +34,22 @@ Bar_line::calc_bar_extent (SCM smob) Interval result; Grob *me = unsmob_grob (smob); if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me)) - result = staff->extent (staff, Y_AXIS); - + { + result = staff->extent (staff, Y_AXIS); + + /* Due to rounding problems, bar lines extending to the outermost edges + of the staff lines appear wrongly in on-screen display + (and, to a lesser extent, in print) - they stick out a pixel. + The solution is to extend bar lines only to the middle + of the staff line - unless they have different colors, + when it would be undesirable. + */ + SCM bar_line_color = me->get_property ("color"); + SCM staff_color = staff->get_property ("color"); + if (bar_line_color == staff_color) + result *= (1 - 0.5 * (Staff_symbol_referencer::line_thickness (me) / + Staff_symbol_referencer::staff_radius (me))); + } return ly_interval2scm (result); } -- 2.39.2