I'm currently trying to create glyph bitmap which contains only outside border of the glyph, without any filling inside. Using FreeType library for this. Here is my code which is similar to example 2 code from FreeType reference:
Spans outlineSpans;
FT_Stroker stroker;
FT_Stroker_New(ft, &stroker);
FT_Stroker_Set(stroker, outlineWidth, round ? FT_STROKER_LINECAP_ROUND : FT_STROKER_LINECAP_SQUARE, round ? FT_STROKER_LINEJOIN_ROUND : FT_STROKER_LINEJOIN_BEVEL, 0);
FT_Glyph g;
FT_Get_Glyph(currentFace->glyph, &g);
FT_Glyph_StrokeBorder(&g, stroker, 0, 1);
FT_Raster_Params params;
memset(¶ms, 0, sizeof(params));
params.flags = FT_RASTER_FLAG_AA | FT_RASTER_FLAG_DIRECT;
params.gray_spans = RasterCallback;
params.user = &outlineSpans;
outlineSpans.clear();
FT_Outline *o = &reinterpret_cast<FT_OutlineGlyph>(g)->outline;
int err = FT_Outline_Render(ft, o, ¶ms);
FT_Stroker_Done(stroker);
FT_Done_Glyph(g);
As result I get outlineSpans
vector filled with spans for the whole glyph image, but I need only the "border" to be rasterized.
CurrentFace->glyph
contains the glyph which I loaded using FT_Load_Char(currentFace, *ch, FT_LOAD_NO_BITMAP))
What am I doing wrong? Thanks for any help, there is not so much documentation/examples about FreeType in the net.