From f14e24d2cf7dbd685a2c3c1465f341e1bb0d2174 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 21 Jan 2023 20:11:43 +0100 Subject: [PATCH] PDF_plotter: fix crash when the font used to plot texts is not specified. (In this case the default Kicad font must be used) Fixes #13615 https://gitlab.com/kicad/code/kicad/issues/13615 --- common/plotters/PDF_plotter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index d75ec3f747..fa38b83354 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -7,7 +7,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2012 Lorenzo Marcantonio, l.marcantonio@logossrl.com - * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1385,6 +1385,10 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos, wxStringTokenizer str_tok( aText, " ", wxTOKEN_RET_DELIMS ); + // If aFont is not specilied (== nullptr), use the default kicad stroke font + if( !aFont ) + aFont = KIFONT::FONT::GetFont(); + VECTOR2I full_box( aFont->StringBoundaryLimits( aText, aSize, aWidth, aBold, aItalic ) ); VECTOR2I box_x( full_box.x, 0 ); VECTOR2I box_y( 0, full_box.y );