From 75b160e83a2e007b29108a519f7cfd643125d734 Mon Sep 17 00:00:00 2001
From: Jeff Young <jeff@rokeby.ie>
Date: Sun, 27 Aug 2023 13:16:34 +0100
Subject: [PATCH] Handle DXF arcs with a flipped coord system.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14905
---
 common/import_gfx/dxf_import_plugin.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/common/import_gfx/dxf_import_plugin.cpp b/common/import_gfx/dxf_import_plugin.cpp
index a34817c3d9..d4c23cfae4 100644
--- a/common/import_gfx/dxf_import_plugin.cpp
+++ b/common/import_gfx/dxf_import_plugin.cpp
@@ -587,6 +587,13 @@ void DXF_IMPORT_PLUGIN::addArc( const DL_ArcData& aData )
     EDA_ANGLE  startangle( aData.angle1, DEGREES_T );
     EDA_ANGLE  endangle( aData.angle2, DEGREES_T );
 
+    if( ( arbAxis.GetScale().x < 0 ) != ( arbAxis.GetScale().y < 0 ) )
+    {
+        startangle = ANGLE_180 - startangle;
+        endangle = ANGLE_180 - endangle;
+        std::swap( startangle, endangle );
+    }
+
     // Init arc start point
     VECTOR2D startPoint( aData.radius, 0.0 );
     RotatePoint( startPoint, -startangle );