34 m_outline( aOutline ),
91 return cubicTo( aControlPoint,
nullptr, aEndPoint, aCallbackData );
96 const FT_Vector* aSecondControlPoint,
const FT_Vector* aEndPoint,
101 std::vector<VECTOR2D> bezier;
103 bezier.push_back(
toVector2D( aFirstControlPoint ) );
105 if( aSecondControlPoint )
108 bezier.push_back(
toVector2D( aSecondControlPoint ) );
113 std::vector<VECTOR2D> result;
129 FT_Outline_Funcs callbacks;
131 callbacks.move_to =
moveTo;
132 callbacks.line_to =
lineTo;
138 FT_Error e = FT_Outline_Decompose( &
m_outline, &callbacks,
this );
144 c.m_Winding =
winding( c.m_Points );
152 const std::vector<VECTOR2D>& aBezier )
const
154 wxASSERT( aBezier.size() == 3 );
164 std::vector<VECTOR2D> cubic;
167 cubic.push_back( aBezier[0] );
168 cubic.push_back( aBezier[0] + ( ( aBezier[1] - aBezier[0] ) * 2 / 3 ) );
169 cubic.push_back( aBezier[2] + ( ( aBezier[1] - aBezier[2] ) * 2 / 3 ) );
170 cubic.push_back( aBezier[2] );
177 const std::vector<VECTOR2D>& aCubicBezier )
const
179 wxASSERT( aCubicBezier.size() == 4 );
183 converter.
GetPoly( aResult, minimumSegmentLength );
190 const std::vector<VECTOR2D>& aBezier )
const
192 switch( aBezier.size() )
214 if( aContour.size() < 2 )
224 size_t len = aContour.size();
226 for(
size_t i = 0; i < len - 1; i++ )
231 sum += ( ( p2.
x - p1.
x ) * ( p2.
y + p1.
y ) );
234 sum += ( ( aContour[0].x - aContour[len - 1].x ) * ( aContour[0].y + aContour[len - 1].y ) );
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Bezier curves to polygon converter.
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMinSegLen=0, int aMaxSegCount=32)
Convert a Bezier curve to a polygon.
bool approximateBezierCurve(std::vector< VECTOR2D > &result, const std::vector< VECTOR2D > &bezier) const
void addContourPoint(const VECTOR2D &p)
OUTLINE_DECOMPOSER(FT_Outline &aOutline)
std::vector< CONTOUR > * m_contours
static int cubicTo(const FT_Vector *aFirstControlPoint, const FT_Vector *aSecondControlPoint, const FT_Vector *aEndPoint, void *aCallbackData)
static int moveTo(const FT_Vector *aEndPoint, void *aCallbackData)
bool OutlineToSegments(std::vector< CONTOUR > *aContours)
bool approximateCubicBezierCurve(std::vector< VECTOR2D > &result, const std::vector< VECTOR2D > &bezier) const
static int lineTo(const FT_Vector *aEndPoint, void *aCallbackData)
static int quadraticTo(const FT_Vector *aControlPoint, const FT_Vector *aEndPoint, void *aCallbackData)
bool approximateQuadraticBezierCurve(std::vector< VECTOR2D > &result, const std::vector< VECTOR2D > &bezier) const
int winding(const std::vector< VECTOR2D > &aContour) const
int m_MinimumSegmentLength
Length of the minimum segment for the outline decomposer.
constexpr double GLYPH_SIZE_SCALER
static VECTOR2D toVector2D(const FT_Vector *aFreeTypeVector)
FT_Orientation m_Orientation
VECTOR2< double > VECTOR2D