diff --git a/common/font/outline_decomposer.cpp b/common/font/outline_decomposer.cpp index b89763449b..0c66d8e854 100644 --- a/common/font/outline_decomposer.cpp +++ b/common/font/outline_decomposer.cpp @@ -98,7 +98,7 @@ int OUTLINE_DECOMPOSER::cubicTo( const FT_Vector* aFirstControlPoint, { OUTLINE_DECOMPOSER* decomposer = static_cast( aCallbackData ); - GLYPH_POINTS bezier; + std::vector 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 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* 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& aResult, + const std::vector& 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 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& aResult, + const std::vector& 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& aResult, + const std::vector& 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& aContour ) const { // -1 == counterclockwise, 1 == clockwise diff --git a/common/font/outline_font.cpp b/common/font/outline_font.cpp index 87dc683251..e569701c89 100644 --- a/common/font/outline_font.cpp +++ b/common/font/outline_font.cpp @@ -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 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 points = c.m_Points; + SHAPE_LINE_CHAIN shape; shape.ReservePoints( points.size() ); diff --git a/include/font/glyph.h b/include/font/glyph.h index 07c3f4f641..ef3ed7a7e0 100644 --- a/include/font/glyph.h +++ b/include/font/glyph.h @@ -112,10 +112,6 @@ private: }; -typedef std::vector GLYPH_POINTS; -typedef std::vector GLYPH_POINTS_LIST; -typedef std::vector GLYPH_BOUNDING_BOX_LIST; - } // namespace KIFONT diff --git a/include/font/outline_decomposer.h b/include/font/outline_decomposer.h index 6e611d1fc6..0b8f07ab0d 100644 --- a/include/font/outline_decomposer.h +++ b/include/font/outline_decomposer.h @@ -41,42 +41,38 @@ namespace KIFONT { -typedef std::vector GLYPH_POINTS; -typedef std::vector GLYPH_POINTS_LIST; -typedef std::vector GLYPH_BOUNDING_BOX_LIST; - struct CONTOUR { - GLYPH_POINTS m_Points; - int m_Winding = 0; - FT_Orientation m_Orientation; + std::vector m_Points; + int m_Winding = 0; + FT_Orientation m_Orientation; }; -typedef std::vector CONTOURS; - - class OUTLINE_DECOMPOSER { public: OUTLINE_DECOMPOSER( FT_Outline& aOutline ); - void OutlineToSegments( CONTOURS* aContours ); + void OutlineToSegments( std::vector* 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& result, + const std::vector& bezier ) const; + bool approximateQuadraticBezierCurve( std::vector& result, + const std::vector& bezier ) const; + bool approximateCubicBezierCurve( std::vector& result, + const std::vector& 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& 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* m_contours; - VECTOR2D m_lastEndPoint; + VECTOR2D m_lastEndPoint; }; } //namespace KIFONT diff --git a/include/font/outline_font.h b/include/font/outline_font.h index a077d49b2f..782aa556d9 100644 --- a/include/font/outline_font.h +++ b/include/font/outline_font.h @@ -138,7 +138,7 @@ private: // cache for glyphs converted to straight segments // key is glyph index (FT_GlyphSlot field glyph_index) - std::map m_contourCache; + std::map>> 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 diff --git a/include/font/stroke_font.h b/include/font/stroke_font.h index 4ff1e88c30..de09a03585 100644 --- a/include/font/stroke_font.h +++ b/include/font/stroke_font.h @@ -87,7 +87,7 @@ private: private: const std::vector>* m_glyphs; - const GLYPH_BOUNDING_BOX_LIST* m_glyphBoundingBoxes; + const std::vector* m_glyphBoundingBoxes; double m_maxGlyphWidth; };