From 99e65afa1f61083e7400e7e226209435a81b7b41 Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@wanadoo.fr>
Date: Wed, 26 Mar 2025 16:26:20 +0100
Subject: [PATCH] Pcbnew, plot F&B Fab: ensure the DNP mark is plotted only on
 the right layer.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20458
---
 pcbnew/plot_board_layers.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp
index 414da58e7b..1294691e06 100644
--- a/pcbnew/plot_board_layers.cpp
+++ b/pcbnew/plot_board_layers.cpp
@@ -633,7 +633,8 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, const LSET& aLayerMask
         if( footprint->IsDNP()
                 && !itemplotter.GetHideDNPFPsOnFabLayers()
                 && itemplotter.GetCrossoutDNPFPsOnFabLayers()
-                && ( onFrontFab || onBackFab ) )
+                && ( ( onFrontFab && footprint->GetLayer() == F_Cu ) ||
+                     ( onBackFab && footprint->GetLayer() == B_Cu ) ) )
         {
             BOX2I rect = footprint->GetBoundingHull().BBox();
             int   width = aBoard->GetDesignSettings().m_LineThickness[ LAYER_CLASS_FAB ];