From a12bc3a4108137417fa956cfccf8f748d504723b Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <seth@kipro-pcb.com>
Date: Fri, 5 Apr 2024 14:28:49 -0700
Subject: [PATCH] Don't knock out anti-text box

Knockout text should only prevent filling directly around the text
itself, not the larger anti-text fill around it.  This prevents minimum
width provisions from kicking in unneccesarily

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17665
---
 pcbnew/zone_filler.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp
index 3dff5699e8..9035ce70f9 100644
--- a/pcbnew/zone_filler.cpp
+++ b/pcbnew/zone_filler.cpp
@@ -820,8 +820,11 @@ void ZONE_FILLER::addKnockout( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int aGap,
         {
             if( text->IsKnockout() )
             {
-                int antiGap = -m_maxError * 2;   // Don't leave gaps around knockout text
-                text->TransformShapeToPolygon( aHoles, aLayer, antiGap, m_maxError, ERROR_OUTSIDE );
+                // Knockout text should only leave holes where the text is, not where the copper fill
+                // around it would be.
+                PCB_TEXT textCopy = *text;
+                textCopy.SetIsKnockout( false );
+                textCopy.TransformShapeToPolygon( aHoles, aLayer, 0, m_maxError, ERROR_OUTSIDE );
             }
             else
             {