From 8b1a36e2dbe6930e4d166327e564d2420eb0febe Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Sat, 26 Feb 2011 11:14:11 +0000 Subject: Correctly centering lines on pixel grid if their width is even. svn path=/trunk/netsurf/; revision=11823 --- cocoa/plotter.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cocoa/plotter.m b/cocoa/plotter.m index c51e82c91..c42f0d9a6 100644 --- a/cocoa/plotter.m +++ b/cocoa/plotter.m @@ -70,7 +70,7 @@ static void cocoa_plot_path_set_stroke_pattern(NSBezierPath *path,const plot_sty break; } - [path setLineWidth: cocoa_px_to_pt( pstyle->stroke_width )]; + [path setLineWidth: cocoa_px_to_pt( pstyle->stroke_width > 0 ? pstyle->stroke_width : 1 )]; } static bool plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle) @@ -87,7 +87,9 @@ static bool plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle const bool horizontal = y0 == y1; const bool vertical = x0 == x1; - cocoa_center_pixel( !horizontal, !vertical ); + const bool oddThickness = pstyle->stroke_width != 0 ? (pstyle->stroke_width % 2) != 0 : true; + + if (oddThickness) cocoa_center_pixel( !horizontal, !vertical ); [cocoa_convert_colour( pstyle->stroke_colour ) set]; [path stroke]; @@ -141,7 +143,7 @@ void cocoa_plot_render_path(NSBezierPath *path,const plot_style_t *pstyle) } if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) { - cocoa_center_pixel( true, true ); + if (pstyle->stroke_width % 2 != 0) cocoa_center_pixel( true, true ); cocoa_plot_path_set_stroke_pattern(path,pstyle); -- cgit v1.2.3