Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ FreeType:如何栅格化非填充轮廓_C++_Rendering_Freetype_Glyph_Rasterizing - Fatal编程技术网

C++ FreeType:如何栅格化非填充轮廓

C++ FreeType:如何栅格化非填充轮廓,c++,rendering,freetype,glyph,rasterizing,C++,Rendering,Freetype,Glyph,Rasterizing,我目前正在尝试创建一个字形位图,它只包含字形的外部边界,内部没有任何填充。正在为此使用FreeType库。这是我的代码,类似于FreeType参考中的示例2代码: Spans outlineSpans; FT_Stroker stroker; FT_Stroker_New(ft, &stroker); FT_Stroker_Set(stroker, outlineWidth, round ? FT_STROKER_LINECAP_ROUND : FT_STROKER_LINECAP_SQ

我目前正在尝试创建一个字形位图,它只包含字形的外部边界,内部没有任何填充。正在为此使用FreeType库。这是我的代码,类似于FreeType参考中的示例2代码:

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(&params, 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, &params);

FT_Stroker_Done(stroker);
FT_Done_Glyph(g);
跨越大纲范围;
FT_-Stroker-Stroker;
FT_Stroker_New(FT和Stroker);
英尺笔划器组(笔划器,轮廓宽度,圆形?英尺笔划器?线头?圆形:英尺笔划器?线头?方形,圆形?英尺笔划器?线头?圆形:英尺笔划器?线头?斜角,0);
FT_字形g;
FT_Get_字形(currentFace->Glyph,&g);
FT_字形_笔划边框(&g,笔划器,0,1);
FT_光栅_参数;
memset(¶ms,0,sizeof(params));
params.flags=FT_光栅_FLAG_AA | FT_光栅_FLAG_DIRECT;
params.gray_span=光栅回调;
params.user=&outlinespan;
大纲平移。清除();
FT_大纲*o=&重新解释(g)->大纲;
int err=FT_Outline_Render(FT、o和params);
FT_Stroker_Done(Stroker);
FT_Done_字形(g);
结果,我得到了整个glyph图像的
outlinespan
向量,其中填充了跨距,但我只需要光栅化“边框”。
CurrentFace->glyph
包含我使用
FT\u Load\u Char(CurrentFace,*ch,FT\u Load\u NO\u位图)加载的glyph

我做错了什么?感谢您的帮助,网络上没有那么多关于FreeType的文档/示例。

在解决方案下面分享如何使用轮廓字体,因为我只使用了轮廓字体,这可能会对您有所帮助

        FT_OutlineGlyph _oGlyph;
        struct Point{
            int x;
            int y;
        };

        vector<std::pair<int, int>> pointsPairVector;

        pointCount = _oGlyph->outline.n_points;

        for(int i = 0; i < pointCount; i++)
        {
            point.first = _oGlyph->outline.points[i].x;
            point.second = _oGlyph->outline.points[i].y;
            pointsPairVector.push_back(point)
        }
        //use Cairo to connect points in pointsPairVector
FT\u OutlineGlyph\u oGlyph;
结构点{
int x;
int-y;
};
向量点向量;
pointCount=\u oGlyph->outline.n\u点;
对于(int i=0;ioutline.points[i].x;
point.second=\u oGlyph->outline.points[i].y;
点矢量。推回(点)
}
//使用Cairo连接pointsPairVector中的点