I've encountered a strange issue with FT_Outline_Get_BBox(). When getting the
dimensions
of the following shape bbox.yMin overflows into the negative:
setvector(v1, 28800, 9600);
FT_Stroker_BeginSubPath(stroker, &v1, 0);
FT_Stroker_LineTo(stroker, &v1);
setvector(v1, 28800, 6400);
FT_Stroker_LineTo(stroker, &v1);
setvector(v1, 28800, 10666);
setvector(v2, 22400, 10666);
setvector(v3, 22400, 6400);
FT_Stroker_CubicTo(stroker, &v1, &v2, &v3);
setvector(v1, 22400, 2133);
setvector(v2, 28800, 2133);
setvector(v3, 28800, 6399);
FT_Stroker_CubicTo(stroker, &v1, &v2, &v3);
Here is the result returned by FT_Outline_Get_BBox():
BBOX: 22400 -2147474048 28866 9599
Is this a bug or have I done something wrong here?
Small demo source attached.
Marco
#include <stdio.h>
#include <math.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_OUTLINE_H
#include FT_SYNTHESIS_H
#include FT_STROKER_H
#include FT_BBOX_H
#define setvector(pv, px, py) (pv).x = (px); (pv).y = (py);
static FT_Library freetype_library = NULL;
int main(int argc, char *argv[])
{
FT_Stroker stroker;
FT_UInt points, contours;
FT_Outline outline;
FT_BBox bbox;
FT_Vector v1, v2, v3;
FT_Init_FreeType(&freetype_library);
FT_Stroker_New(freetype_library, &stroker);
setvector(v1, 28800, 9600);
FT_Stroker_BeginSubPath(stroker, &v1, 0);
FT_Stroker_LineTo(stroker, &v1);
setvector(v1, 28800, 6400);
FT_Stroker_LineTo(stroker, &v1);
setvector(v1, 28800, 10666);
setvector(v2, 22400, 10666);
setvector(v3, 22400, 6400);
FT_Stroker_CubicTo(stroker, &v1, &v2, &v3);
setvector(v1, 22400, 2133);
setvector(v2, 28800, 2133);
setvector(v3, 28800, 6399);
FT_Stroker_CubicTo(stroker, &v1, &v2, &v3);
FT_Stroker_EndSubPath(stroker);
FT_Stroker_GetBorderCounts(stroker, FT_STROKER_BORDER_LEFT, &points,
&contours);
memset(&outline, 0, sizeof(FT_Outline));
FT_Outline_New(freetype_library, 1024, 512, &outline);
outline.n_points = 0;
outline.n_contours = 0;
FT_Stroker_Export(stroker, &outline);
FT_Stroker_Done(stroker);
FT_Outline_Get_BBox(&outline, &bbox);
printf("BBOX: %d %d %d %d\n", bbox.xMin, bbox.yMin, bbox.xMax,
bbox.yMax);
FT_Outline_Done(freetype_library, &outline);
FT_Done_FreeType(freetype_library);
return 0;
}
_______________________________________________
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype