mono / libgdiplus

C-based implementation of the GDI+ API
http://www.mono-project.com/
MIT License
334 stars 171 forks source link

Fix some pen width problems #638

Closed PreferLinux closed 4 years ago

PreferLinux commented 4 years ago

First, base the 1px minimum line width on output line width, not pen width. If scaling up with a pen width < 1, the output width may well be more than 1px, in which case the correct output is that width, not 1px.

Second, cairo_device_to_user_distance() can provide negative values. Use the absolute value of its outputs. The negative comes from mirror-type transforms (negative scale values). Using a negative value results in no line being drawn; and if dash_count > 0, also an error from Cairo.

Third, use the maximum of widthx and widthy, because scaling is not necessarily uniform. Setting a minimum line width is only necessary because Cairo produces dashed lines when scaling up and the output width is < 1px, and we don't want that happening when scaling Y more than X.