33 m_outline( aOutline ),
90 return cubicTo( aControlPoint,
nullptr, aEndPoint, aCallbackData );
95 const FT_Vector* aSecondControlPoint,
const FT_Vector* aEndPoint,
102 bezier.push_back(
toVector2D( aFirstControlPoint ) );
104 if( aSecondControlPoint )
107 bezier.push_back(
toVector2D( aSecondControlPoint ) );
127 FT_Outline_Funcs callbacks;
129 callbacks.move_to =
moveTo;
130 callbacks.line_to =
lineTo;
136 FT_Error e = FT_Outline_Decompose( &
m_outline, &callbacks,
this );
144 c.m_Winding =
winding( c.m_Points );
152 wxASSERT( aBezier.size() == 3 );
165 cubic.push_back( aBezier[0] );
166 cubic.push_back( aBezier[0] + ( ( aBezier[1] - aBezier[0] ) * 2 / 3 ) );
167 cubic.push_back( aBezier[2] + ( ( aBezier[1] - aBezier[2] ) * 2 / 3 ) );
168 cubic.push_back( aBezier[2] );
177 wxASSERT( aCubicBezier.size() == 4 );
182 constexpr int minimumSegmentLength = 10;
184 converter.
GetPoly( aResult, minimumSegmentLength );
193 switch( aBezier.size() )
215 if( aContour.size() < 2 )
225 size_t len = aContour.size();
227 for(
size_t i = 0; i < len - 1; i++ )
232 sum += ( ( p2.
x - p1.
x ) * ( p2.
y + p1.
y ) );
235 sum += ( ( aContour[0].x - aContour[len - 1].x ) * ( aContour[0].y + aContour[len - 1].y ) );
Bezier curves to polygon converter.
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMinSegLen=0, int aMaxSegCount=32)
Convert a Bezier curve to a polygon.
void addContourPoint(const VECTOR2D &p)
OUTLINE_DECOMPOSER(FT_Outline &aOutline)
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)
static int lineTo(const FT_Vector *aEndPoint, void *aCallbackData)
void OutlineToSegments(CONTOURS *aContours)
bool approximateQuadraticBezierCurve(GLYPH_POINTS &result, const GLYPH_POINTS &bezier) const
int winding(const GLYPH_POINTS &aContour) const
static int quadraticTo(const FT_Vector *aControlPoint, const FT_Vector *aEndPoint, void *aCallbackData)
bool approximateCubicBezierCurve(GLYPH_POINTS &result, const GLYPH_POINTS &bezier) const
bool approximateBezierCurve(GLYPH_POINTS &result, const GLYPH_POINTS &bezier) const
std::vector< CONTOUR > CONTOURS
constexpr double GLYPH_SIZE_SCALER
std::vector< VECTOR2D > GLYPH_POINTS
static VECTOR2D toVector2D(const FT_Vector *aFreeTypeVector)
FT_Orientation m_Orientation
VECTOR2< double > VECTOR2D