54 virtual bool Run()
override;
56 virtual const wxString
GetName()
const override
58 return wxT(
"text_dimensions" );
63 return wxT(
"Tests text height and thickness" );
70 const int progressDelta = 250;
77 reportAux( wxT(
"Text dimension violations ignored. Tests not run." ) );
84 reportAux( wxT(
"No text height or text thickness constraints found. Tests not run." ) );
91 auto checkTextHeight =
103 int actualHeight =
text->GetTextSize().y;
110 msg.Printf(
_(
"(%s min height %s; actual %s)" ),
115 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
116 drcItem->SetItems( item );
127 msg.Printf(
_(
"(%s max height %s; actual %s)" ),
132 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
133 drcItem->SetItems( item );
142 auto checkTextThickness =
158 auto* glyphs =
text->GetRenderCache(
text->GetShownText() );
159 bool collapsedStroke =
false;
160 bool collapsedArea =
false;
162 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : *glyphs )
168 if( outlineCount == 0 )
171 for( ii = 0; ii < outlineCount; ++ii )
172 holeCount += outlineGlyph->HoleCount( ii );
179 int resultingHoleCount = 0;
181 for( ii = 0; ii < resultingOutlineCount; ++ii )
182 resultingHoleCount += poly.
HoleCount( ii );
184 if( ( resultingOutlineCount != outlineCount )
185 || ( resultingHoleCount != holeCount ) )
187 collapsedStroke =
true;
191 double glyphArea = outlineGlyph->Area();
198 double resultingGlyphArea = poly.
Area();
200 if( (
std::abs( resultingGlyphArea - glyphArea ) / glyphArea ) > 0.1 )
202 collapsedArea =
true;
207 if( collapsedStroke || collapsedArea )
212 msg =
_(
"(TrueType font characters with insufficient stroke weight)" );
214 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
215 drcItem->SetItems( item );
223 int actualThickness =
text->GetEffectiveTextPenWidth();
230 msg.Printf(
_(
"(%s min thickness %s; actual %s)" ),
235 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
236 drcItem->SetItems( item );
247 msg.Printf(
_(
"(%s max thickness %s; actual %s)" ),
252 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
253 drcItem->SetItems( item );
282 switch( item->
Type() )
284 case PCB_TEXT_T: text = static_cast<PCB_TEXT*>( item ); break;
285 case PCB_TEXTBOX_T: text = static_cast<PCB_TEXTBOX*>( item ); break;
286 case PCB_FP_TEXT_T: text = static_cast<FP_TEXT*>( item ); break;
287 case PCB_FP_TEXTBOX_T: text = static_cast<FP_TEXTBOX*>( item ); break;
288 default: UNIMPLEMENTED_FOR( item->GetClass() ); break;
297 checkTextThickness( item,
text );
302 checkTextHeight( item,
text );
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
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_ITEMs and po...
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 reportAux(wxString fmt,...)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, PCB_LAYER_ID aMarkerLayer)
EDA_UNITS userUnits() const
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.
virtual bool IsOutline() const
static LSET AllLayersMask()
Represent a set of closed polygons.
double Area()
Count the number of arc shapes present.
void Deflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
void Inflate(int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
void Simplify(POLYGON_MODE aFastMode)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
SHAPE_POLY_SET CloneDropTriangulation() const
Creates a new empty polygon in the set and returns its index.
@ 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_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint