7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 00:21:31 +00:00

Don't cover STL types.

This commit is contained in:
Jeff Young 2024-02-05 15:30:44 +00:00
parent 7b3485fcb8
commit a28f092b67
6 changed files with 33 additions and 41 deletions

View File

@ -98,7 +98,7 @@ int OUTLINE_DECOMPOSER::cubicTo( const FT_Vector* aFirstControlPoint,
{
OUTLINE_DECOMPOSER* decomposer = static_cast<OUTLINE_DECOMPOSER*>( aCallbackData );
GLYPH_POINTS bezier;
std::vector<VECTOR2D> bezier;
bezier.push_back( decomposer->m_lastEndPoint );
bezier.push_back( toVector2D( aFirstControlPoint ) );
@ -110,8 +110,9 @@ int OUTLINE_DECOMPOSER::cubicTo( const FT_Vector* aFirstControlPoint,
bezier.push_back( toVector2D( aEndPoint ) );
GLYPH_POINTS result;
std::vector<VECTOR2D> result;
decomposer->approximateBezierCurve( result, bezier );
for( const VECTOR2D& p : result )
decomposer->addContourPoint( p );
@ -121,7 +122,7 @@ int OUTLINE_DECOMPOSER::cubicTo( const FT_Vector* aFirstControlPoint,
}
void OUTLINE_DECOMPOSER::OutlineToSegments( CONTOURS* aContours )
void OUTLINE_DECOMPOSER::OutlineToSegments( std::vector<CONTOUR>* aContours )
{
m_contours = aContours;
@ -147,8 +148,8 @@ void OUTLINE_DECOMPOSER::OutlineToSegments( CONTOURS* aContours )
// use converter in kimath
bool OUTLINE_DECOMPOSER::approximateQuadraticBezierCurve( GLYPH_POINTS& aResult,
const GLYPH_POINTS& aBezier ) const
bool OUTLINE_DECOMPOSER::approximateQuadraticBezierCurve( std::vector<VECTOR2D>& aResult,
const std::vector<VECTOR2D>& aBezier ) const
{
wxASSERT( aBezier.size() == 3 );
@ -160,7 +161,7 @@ bool OUTLINE_DECOMPOSER::approximateQuadraticBezierCurve( GLYPH_POINTS& aR
// qpn = Quadratic Bezier control points (n = 0..2, 3 in total)
// cp0 = qp0, cp1 = qp0 + 2/3 * (qp1 - qp0), cp2 = qp2 + 2/3 * (qp1 - qp2), cp3 = qp2
GLYPH_POINTS cubic;
std::vector<VECTOR2D> cubic;
cubic.reserve( 4 );
cubic.push_back( aBezier[0] ); // cp0
@ -172,12 +173,11 @@ bool OUTLINE_DECOMPOSER::approximateQuadraticBezierCurve( GLYPH_POINTS& aR
}
bool OUTLINE_DECOMPOSER::approximateCubicBezierCurve( GLYPH_POINTS& aResult,
const GLYPH_POINTS& aCubicBezier ) const
bool OUTLINE_DECOMPOSER::approximateCubicBezierCurve( std::vector<VECTOR2D>& aResult,
const std::vector<VECTOR2D>& aCubicBezier ) const
{
wxASSERT( aCubicBezier.size() == 4 );
static int minimumSegmentLength = ADVANCED_CFG::GetCfg().m_MinimumSegmentLength;
BEZIER_POLY converter( aCubicBezier );
converter.GetPoly( aResult, minimumSegmentLength );
@ -186,17 +186,17 @@ bool OUTLINE_DECOMPOSER::approximateCubicBezierCurve( GLYPH_POINTS& aResul
}
bool OUTLINE_DECOMPOSER::approximateBezierCurve( GLYPH_POINTS& aResult,
const GLYPH_POINTS& aBezier ) const
bool OUTLINE_DECOMPOSER::approximateBezierCurve( std::vector<VECTOR2D>& aResult,
const std::vector<VECTOR2D>& aBezier ) const
{
switch( aBezier.size() )
{
case 4: // cubic
return approximateCubicBezierCurve( aResult, aBezier );
break;
case 3: // quadratic
return approximateQuadraticBezierCurve( aResult, aBezier );
break;
default:
// error, only 3 and 4 are acceptable values
return false;
@ -204,7 +204,7 @@ bool OUTLINE_DECOMPOSER::approximateBezierCurve( GLYPH_POINTS& aResult,
}
int OUTLINE_DECOMPOSER::winding( const GLYPH_POINTS& aContour ) const
int OUTLINE_DECOMPOSER::winding( const std::vector<VECTOR2D>& aContour ) const
{
// -1 == counterclockwise, 1 == clockwise

View File

@ -325,7 +325,7 @@ VECTOR2I OUTLINE_FONT::getTextAsGlyphsUnlocked( BOX2I* aBBox,
// contours is a collection of all outlines in the glyph; for example the 'o' glyph
// generally contains 2 contours, one for the glyph outline and one for the hole
CONTOURS contours;
std::vector<CONTOUR> contours;
OUTLINE_DECOMPOSER decomposer( face->glyph->outline );
decomposer.OutlineToSegments( &contours );
@ -335,8 +335,8 @@ VECTOR2I OUTLINE_FONT::getTextAsGlyphsUnlocked( BOX2I* aBBox,
for( CONTOUR& c : contours )
{
GLYPH_POINTS points = c.m_Points;
SHAPE_LINE_CHAIN shape;
std::vector<VECTOR2D> points = c.m_Points;
SHAPE_LINE_CHAIN shape;
shape.ReservePoints( points.size() );

View File

@ -112,10 +112,6 @@ private:
};
typedef std::vector<VECTOR2D> GLYPH_POINTS;
typedef std::vector<GLYPH_POINTS> GLYPH_POINTS_LIST;
typedef std::vector<BOX2D> GLYPH_BOUNDING_BOX_LIST;
} // namespace KIFONT

View File

@ -41,42 +41,38 @@
namespace KIFONT
{
typedef std::vector<VECTOR2D> GLYPH_POINTS;
typedef std::vector<GLYPH_POINTS> GLYPH_POINTS_LIST;
typedef std::vector<BOX2D> GLYPH_BOUNDING_BOX_LIST;
struct CONTOUR
{
GLYPH_POINTS m_Points;
int m_Winding = 0;
FT_Orientation m_Orientation;
std::vector<VECTOR2D> m_Points;
int m_Winding = 0;
FT_Orientation m_Orientation;
};
typedef std::vector<CONTOUR> CONTOURS;
class OUTLINE_DECOMPOSER
{
public:
OUTLINE_DECOMPOSER( FT_Outline& aOutline );
void OutlineToSegments( CONTOURS* aContours );
void OutlineToSegments( std::vector<CONTOUR>* aContours );
private:
void newContour();
void addContourPoint( const VECTOR2D& p );
bool approximateBezierCurve( GLYPH_POINTS& result, const GLYPH_POINTS& bezier ) const;
bool approximateQuadraticBezierCurve( GLYPH_POINTS& result, const GLYPH_POINTS& bezier ) const;
bool approximateCubicBezierCurve( GLYPH_POINTS& result, const GLYPH_POINTS& bezier ) const;
bool approximateBezierCurve( std::vector<VECTOR2D>& result,
const std::vector<VECTOR2D>& bezier ) const;
bool approximateQuadraticBezierCurve( std::vector<VECTOR2D>& result,
const std::vector<VECTOR2D>& bezier ) const;
bool approximateCubicBezierCurve( std::vector<VECTOR2D>& result,
const std::vector<VECTOR2D>& bezier ) const;
/**
* @return 1 if aContour is in clockwise order, -1 if it is in counterclockwise order,
* or 0 if the winding can't be determined.
*/
int winding( const GLYPH_POINTS& aContour ) const;
int winding( const std::vector<VECTOR2D>& aContour ) const;
inline static unsigned int onCurve( char aTags )
{
@ -115,10 +111,10 @@ private:
const FT_Vector* aEndPoint, void* aCallbackData );
private:
FT_Outline& m_outline;
CONTOURS* m_contours;
FT_Outline& m_outline;
std::vector<CONTOUR>* m_contours;
VECTOR2D m_lastEndPoint;
VECTOR2D m_lastEndPoint;
};
} //namespace KIFONT

View File

@ -138,7 +138,7 @@ private:
// cache for glyphs converted to straight segments
// key is glyph index (FT_GlyphSlot field glyph_index)
std::map<unsigned int, GLYPH_POINTS_LIST> m_contourCache;
std::map<unsigned int, std::vector<std::vector<VECTOR2D>>> m_contourCache;
// The height of the KiCad stroke font is the distance between stroke endpoints for a vertical
// line of cap-height. So the cap-height of the font is actually stroke-width taller than its

View File

@ -87,7 +87,7 @@ private:
private:
const std::vector<std::shared_ptr<GLYPH>>* m_glyphs;
const GLYPH_BOUNDING_BOX_LIST* m_glyphBoundingBoxes;
const std::vector<BOX2D>* m_glyphBoundingBoxes;
double m_maxGlyphWidth;
};