@@ -18,6 +18,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1818
1919#include < cairo-pdf.h>
2020#include < stdio.h>
21+ #include < float.h>
2122
2223// //////////////////////////////////////////////////////////////////////////////
2324
@@ -750,26 +751,47 @@ void transform_point(double &x, double &y, const MCCustomPrinterTransform &p_tra
750751 x = t_x;
751752}
752753
754+ // MW-2014-08-19: [[ Bug 13220 ]] It seems Cairo doesn't like (M p) (L _)* (L p) (C)
755+ // as it ends up treating it is as a degenerate point. Therefore we clean up this
756+ // case - if there is a lineTo which returns to the original moveTo then a close
757+ // it ignores the final lineTo.
753758bool MCPDFPrintingDevice::draw_path (const MCCustomPrinterPath &p_path)
754759{
755760 bool t_success = true ;
756761
757762 MCCustomPrinterPathCommand *t_commands = p_path.commands ;
758763 MCCustomPrinterPoint *t_points = p_path.coords ;
759764
765+ double t_first_x, t_first_y;
766+ t_first_x = t_first_y = DBL_MAX ;
767+
768+ double t_last_x, t_last_y;
769+ t_last_x = t_last_y = DBL_MAX ;
770+
760771 while (t_success && *t_commands != kMCCustomPrinterPathEnd )
761772 {
762773 switch (*t_commands++)
763774 {
764775 case kMCCustomPrinterPathMoveTo :
765776 {
766777 cairo_move_to (m_context, t_points->x , t_points->y );
778+ t_first_x = t_points -> x;
779+ t_first_y = t_points -> y;
767780 t_points++;
768781 }
769782 break ;
770783 case kMCCustomPrinterPathLineTo :
771784 {
772- cairo_line_to (m_context, t_points->x , t_points->y );
785+ if (t_last_x != t_points -> x || t_last_y != t_points -> y)
786+ {
787+ if (*t_commands != kMCCustomPrinterPathClose ||
788+ (t_first_x != t_points -> x || t_first_y != t_points -> y))
789+ {
790+ cairo_line_to (m_context, t_points->x , t_points->y );
791+ t_last_x = t_points -> x;
792+ t_last_y = t_points -> y;
793+ }
794+ }
773795 t_points++;
774796 }
775797 break ;
0 commit comments