53 virtual bool Run()
override;
55 virtual const wxString
GetName()
const override
57 return wxT(
"text_dimensions" );
62 return wxT(
"Tests text height and thickness" );
69 const int progressDelta = 250;
76 reportAux( wxT(
"Text dimension violations ignored. Tests not run." ) );
83 reportAux( wxT(
"No text height or text thickness constraints found. Tests not run." ) );
90 auto checkTextHeight =
102 int actualHeight =
text->GetTextSize().y;
107 wxString msg =
formatMsg(
_(
"(%s min height %s; actual %s)" ),
112 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
113 drcItem->SetItems( item );
122 wxString msg =
formatMsg(
_(
"(%s max height %s; actual %s)" ),
127 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
128 drcItem->SetItems( item );
137 auto checkTextThickness =
156 auto* glyphs =
text->GetRenderCache( font,
text->GetShownText(
true ) );
157 bool collapsedStroke =
false;
158 bool collapsedArea =
false;
160 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : *glyphs )
165 if( !glyph->IsOutline() )
172 if( outlineCount == 0 )
175 for( ii = 0; ii < outlineCount; ++ii )
176 holeCount += outlineGlyph->HoleCount( ii );
184 int resultingHoleCount = 0;
186 for( ii = 0; ii < resultingOutlineCount; ++ii )
187 resultingHoleCount += poly.
HoleCount( ii );
189 if( ( resultingOutlineCount != outlineCount )
190 || ( resultingHoleCount != holeCount ) )
192 collapsedStroke =
true;
196 double glyphArea = outlineGlyph->Area();
204 double resultingGlyphArea = poly.
Area();
206 if( (
std::abs( resultingGlyphArea - glyphArea ) / glyphArea ) > 0.1 )
208 collapsedArea =
true;
213 if( collapsedStroke || collapsedArea )
218 msg =
_(
"(TrueType font characters with insufficient stroke weight)" );
220 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
221 drcItem->SetItems( item );
229 int actualThickness =
text->GetEffectiveTextPenWidth();
234 wxString msg =
formatMsg(
_(
"(%s min thickness %s; actual %s)" ),
239 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
240 drcItem->SetItems( item );
249 wxString msg =
formatMsg(
_(
"(%s max thickness %s; actual %s)" ),
254 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
255 drcItem->SetItems( item );
283 switch( item->
Type() )
285 case PCB_FIELD_T: text = static_cast<PCB_FIELD*>( item ); break;
286 case PCB_TEXT_T: text = static_cast<PCB_TEXT*>( item ); break;
287 case PCB_TEXTBOX_T: text = static_cast<PCB_TEXTBOX*>( item ); break;
288 default: UNIMPLEMENTED_FOR( item->GetClass() ); break;
297 checkTextThickness( item,
text );
302 checkTextHeight( item,
text );
constexpr int ARC_LOW_DEF
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
SEVERITY GetSeverity() const
MINOPTMAX< int > & Value()
DRC_RULE * GetParentRule() const
bool HasRulesForConstraintType(DRC_CONSTRAINT_T constraintID)
bool IsErrorLimitExceeded(int error_code)
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
DRC_TEST_PROVIDER_TEXT_DIMS()
virtual ~DRC_TEST_PROVIDER_TEXT_DIMS()
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
virtual const wxString GetName() const override
virtual const wxString GetDescription() const override
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out DRC_ITEM and posi...
virtual bool reportPhase(const wxString &aStageName)
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
virtual bool reportProgress(int aCount, int aSize, int aDelta)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
void reportAux(const wxString &aMsg)
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, int aConstraint, int aActual)
virtual void reportRuleStatistics()
virtual VECTOR2I GetPosition() const
KICAD_T Type() const
Returns the type of object.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
virtual bool IsOutline() const
static LSET AllLayersMask()
Represent a set of closed polygons.
@ CHAMFER_ALL_CORNERS
All angles are chamfered.
double Area()
Return the area of this poly set.
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
void Simplify(POLYGON_MODE aFastMode)
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMo...
void Deflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
int OutlineCount() const
Return the number of outlines in the set.
SHAPE_POLY_SET CloneDropTriangulation() const
@ TEXT_THICKNESS_CONSTRAINT
This file contains miscellaneous commonly used macros and functions.
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property