From 63a3b1e20a75efd8632ec2d2c9b2d72def1d4589 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 1 Feb 2022 11:19:09 +0000 Subject: [PATCH] Estimate outline font thickness for DRC readability checks. --- include/eda_text.h | 2 +- pcbnew/drc/drc_test_provider_text_dims.cpp | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/eda_text.h b/include/eda_text.h index b3d173b4c9..02e6143fe9 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -112,7 +112,7 @@ public: * in bold text and thickness clamping. */ void SetTextThickness( int aWidth ); - int GetTextThickness() const { return m_attributes.m_StrokeWidth; }; + int GetTextThickness() const { return m_attributes.m_StrokeWidth; }; /** * The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth. diff --git a/pcbnew/drc/drc_test_provider_text_dims.cpp b/pcbnew/drc/drc_test_provider_text_dims.cpp index 8edbf38e32..aabbd6e52f 100644 --- a/pcbnew/drc/drc_test_provider_text_dims.cpp +++ b/pcbnew/drc/drc_test_provider_text_dims.cpp @@ -30,6 +30,7 @@ #include #include #include +#include /* @@ -121,8 +122,25 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run() if( !text || !text->IsVisible() ) return true; - int actualH = text->GetTextHeight(); - int actualT = text->GetTextThickness(); + VECTOR2I size = text->GetTextSize(); + KIFONT::FONT* font = text->GetDrawFont(); + + int actualH = size.y; + int actualT = 0; + + if( font->IsStroke() ) + { + actualT = text->GetTextThickness(); + } + else if( font->IsOutline() ) + { + // The best we can do for outline fonts is estimate their thickness based + // on their fontweight. + if( font->IsBold() ) + actualT = GetPenSizeForBold( size.x ); + else + actualT = GetPenSizeForNormal( size.x ); + } if( !m_drcEngine->IsErrorLimitExceeded( DRCE_TEXT_HEIGHT ) ) {