Skip to content

Commit

Permalink
Move PVG_FT_Outline_Check and PVG_FT_Outline_Get_CBox functions to pl…
Browse files Browse the repository at this point in the history
…utovg-ft-raster.c
  • Loading branch information
sammycage committed Oct 10, 2024
1 parent f48eccb commit 2d66018
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 71 deletions.
71 changes: 71 additions & 0 deletions source/plutovg-ft-raster.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,77 @@ PVG_FT_END_STMNT
}
}

PVG_FT_Error PVG_FT_Outline_Check(PVG_FT_Outline* outline)
{
if (outline) {
PVG_FT_Int n_points = outline->n_points;
PVG_FT_Int n_contours = outline->n_contours;
PVG_FT_Int end0, end;
PVG_FT_Int n;

/* empty glyph? */
if (n_points == 0 && n_contours == 0) return 0;

/* check point and contour counts */
if (n_points <= 0 || n_contours <= 0) goto Bad;

end0 = end = -1;
for (n = 0; n < n_contours; n++) {
end = outline->contours[n];

/* note that we don't accept empty contours */
if (end <= end0 || end >= n_points) goto Bad;

end0 = end;
}

if (end != n_points - 1) goto Bad;

/* XXX: check the tags array */
return 0;
}

Bad:
return ErrRaster_Invalid_Outline;
}

void PVG_FT_Outline_Get_CBox(const PVG_FT_Outline* outline, PVG_FT_BBox* acbox)
{
PVG_FT_Pos xMin, yMin, xMax, yMax;

if (outline && acbox) {
if (outline->n_points == 0) {
xMin = 0;
yMin = 0;
xMax = 0;
yMax = 0;
} else {
PVG_FT_Vector* vec = outline->points;
PVG_FT_Vector* limit = vec + outline->n_points;

xMin = xMax = vec->x;
yMin = yMax = vec->y;
vec++;

for (; vec < limit; vec++) {
PVG_FT_Pos x, y;

x = vec->x;
if (x < xMin) xMin = x;
if (x > xMax) xMax = x;

y = vec->y;
if (y < yMin) yMin = y;
if (y > yMax) yMax = y;
}
}
acbox->xMin = xMin;
acbox->xMax = xMax;
acbox->yMin = yMin;
acbox->yMax = yMax;
}
}

/*************************************************************************/
/* */
/* The following function should only compile in stand_alone mode, */
Expand Down
71 changes: 0 additions & 71 deletions source/plutovg-ft-stroker.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,77 +238,6 @@ typedef struct PVG_FT_StrokeBorderRec_ {

} PVG_FT_StrokeBorderRec, *PVG_FT_StrokeBorder;

PVG_FT_Error PVG_FT_Outline_Check(PVG_FT_Outline* outline)
{
if (outline) {
PVG_FT_Int n_points = outline->n_points;
PVG_FT_Int n_contours = outline->n_contours;
PVG_FT_Int end0, end;
PVG_FT_Int n;

/* empty glyph? */
if (n_points == 0 && n_contours == 0) return 0;

/* check point and contour counts */
if (n_points <= 0 || n_contours <= 0) goto Bad;

end0 = end = -1;
for (n = 0; n < n_contours; n++) {
end = outline->contours[n];

/* note that we don't accept empty contours */
if (end <= end0 || end >= n_points) goto Bad;

end0 = end;
}

if (end != n_points - 1) goto Bad;

/* XXX: check the tags array */
return 0;
}

Bad:
return -1; // PVG_FT_THROW( Invalid_Argument );
}

void PVG_FT_Outline_Get_CBox(const PVG_FT_Outline* outline, PVG_FT_BBox* acbox)
{
PVG_FT_Pos xMin, yMin, xMax, yMax;

if (outline && acbox) {
if (outline->n_points == 0) {
xMin = 0;
yMin = 0;
xMax = 0;
yMax = 0;
} else {
PVG_FT_Vector* vec = outline->points;
PVG_FT_Vector* limit = vec + outline->n_points;

xMin = xMax = vec->x;
yMin = yMax = vec->y;
vec++;

for (; vec < limit; vec++) {
PVG_FT_Pos x, y;

x = vec->x;
if (x < xMin) xMin = x;
if (x > xMax) xMax = x;

y = vec->y;
if (y < yMin) yMin = y;
if (y > yMax) yMax = y;
}
}
acbox->xMin = xMin;
acbox->xMax = xMax;
acbox->yMin = yMin;
acbox->yMax = yMax;
}
}

static PVG_FT_Error ft_stroke_border_grow(PVG_FT_StrokeBorder border,
PVG_FT_UInt new_points)
{
Expand Down

0 comments on commit 2d66018

Please sign in to comment.