* that we do support opened paths, and do not scale the outline.
*/
SW_FT_Error SW_FT_Stroker_ParseOutline(SW_FT_Stroker stroker,
- const SW_FT_Outline* outline,
- SW_FT_Bool opened)
+ const SW_FT_Outline* outline)
{
SW_FT_Vector v_last;
SW_FT_Vector v_control;
tags--;
}
- error = SW_FT_Stroker_BeginSubPath(stroker, &v_start, opened);
+ error = SW_FT_Stroker_BeginSubPath(stroker, &v_start, outline->contours_flag[n]);
if (error) goto Exit;
while (point < limit) {
* outline ::
* The source outline.
*
- * opened ::
- * A boolean. If~1, the outline is treated as an open path instead
- * of a closed one.
*
* @return:
* FreeType error code. 0~means success.
* If `opened' is~0 (the default), the outline is treated as a closed
* path, and the stroker generates two distinct `border' outlines.
*
- * If `opened' is~1, the outline is processed as an open path, and the
- * stroker generates a single `stroke' outline.
*
* This function calls @SW_FT_Stroker_Rewind automatically.
*/
SW_FT_Error
SW_FT_Stroker_ParseOutline( SW_FT_Stroker stroker,
- const SW_FT_Outline* outline,
- SW_FT_Bool opened );
+ const SW_FT_Outline* outline);
/**************************************************************
{
if (mPointSize) delete[] ft.points;
if (mTagSize) delete[] ft.tags;
- if (mSegmentSize) delete[] ft.contours;
+ if (mSegmentSize) {
+ delete[] ft.contours;
+ delete[] ft.contours_flag;
+ }
}
void reset();
void grow(int, int);
SW_FT_Stroker_LineJoin ftJoin;
SW_FT_Fixed ftWidth;
SW_FT_Fixed ftMeterLimit;
- SW_FT_Bool ftClosed;
};
void FTOutline::reset()
}
if (segment_size > mSegmentSize) {
- if (mSegmentSize) delete [] ft.contours;
+ if (mSegmentSize) {
+ delete [] ft.contours;
+ delete [] ft.contours_flag;
+ }
ft.contours = new short[segment_size];
+ ft.contours_flag = new char[segment_size];
mSegmentSize = segment_size;
}
void FTOutline::convert(CapStyle cap, JoinStyle join, float width,
float meterLimit)
{
- ftClosed = (SW_FT_Bool)closed;
-
// map strokeWidth to freetype. It uses as the radius of the pen not the
// diameter
width = width / 2.0;
ft.contours[ft.n_contours] = ft.n_points - 1;
ft.n_contours++;
}
+ // mark the current contour as open
+ // will be updated if ther is a close tag at the end.
+ ft.contours_flag[ft.n_contours] = 1;
+
ft.n_points++;
- closed = false;
}
void FTOutline::lineTo(const VPointF &pt)
ft.points[ft.n_points].y = TO_FT_COORD(pt.y());
ft.tags[ft.n_points] = SW_FT_CURVE_TAG_ON;
ft.n_points++;
- closed = false;
}
void FTOutline::cubicTo(const VPointF &cp1, const VPointF &cp2,
ft.points[ft.n_points].y = TO_FT_COORD(ep.y());
ft.tags[ft.n_points] = SW_FT_CURVE_TAG_ON;
ft.n_points++;
- closed = false;
}
void FTOutline::close()
{
+ // mark the contour as a close path.
+ ft.contours_flag[ft.n_contours] = 0;
+
int index;
if (ft.n_contours) {
index = ft.contours[ft.n_contours - 1] + 1;
ft.points[ft.n_points].y = ft.points[index].y;
ft.tags[ft.n_points] = SW_FT_CURVE_TAG_ON;
ft.n_points++;
- closed = true;
}
void FTOutline::end()
SW_FT_Stroker_Set(stroker, outRef.ftWidth, outRef.ftCap, outRef.ftJoin,
outRef.ftMeterLimit);
- SW_FT_Stroker_ParseOutline(stroker, &outRef.ft, !outRef.ftClosed);
+ SW_FT_Stroker_ParseOutline(stroker, &outRef.ft);
SW_FT_Stroker_GetCounts(stroker, &points, &contors);
outRef.grow(points, contors);