本文整理汇总了C++中FontFace::GetFTFace方法的典型用法代码示例。如果您正苦于以下问题:C++ FontFace::GetFTFace方法的具体用法?C++ FontFace::GetFTFace怎么用?C++ FontFace::GetFTFace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FontFace
的用法示例。
在下文中一共展示了FontFace::GetFTFace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
Glyph::Glyph(FT_Library &library, FontFace &fontFace, int c, int outlineWidth, bool hinting) :
mFont(fontFace)
{
mChar = c;
FT_Face &face = fontFace.GetFTFace();
int flags = FT_LOAD_DEFAULT;
if (!hinting)
{
flags = FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING;
}
FT_Error error = FT_Load_Char(face, c, flags);
if (error) {
return;
}
mGlyphIndex = FT_Get_Char_Index(face, c);
// Load The Glyph For Our Character.
if(FT_Load_Glyph( face, mGlyphIndex, flags ))
throw std::runtime_error("FT_Load_Glyph failed");
// Move The Face's Glyph Into A Glyph Object.
FT_Glyph glyph;
if(FT_Get_Glyph( face->glyph, &glyph ))
throw std::runtime_error("FT_Get_Glyph failed");
FT_Stroker stroker;
FT_Stroker_New(library, &stroker);
FT_Stroker_Set(stroker, outlineWidth * 64, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
FT_Glyph_StrokeBorder(&glyph, stroker, false, true);
FT_OutlineGlyph olglyph = reinterpret_cast<FT_OutlineGlyph>(glyph);
FT_Outline outline = olglyph->outline;
RenderSpans(library, &outline);
FT_Stroker_Done(stroker);
// Get metrics
FT_Glyph_Metrics metrics = face->glyph->metrics;
mAdvance.x = metrics.horiAdvance * kOneOver64;
mAdvance.y = metrics.vertAdvance * kOneOver64;
mBearing.x = metrics.horiBearingX * kOneOver64;
mBearing.y = metrics.horiBearingY * kOneOver64;
mSize.x = glm::round(metrics.width * kOneOver64);
mSize.y = glm::round(metrics.height * kOneOver64);
// Adjust for outline?
mAdvance.x += outlineWidth;
// Draw spans
if(mSpans.size() > 0)
{
GlyphSpan front = mSpans.front();
Rect bounds(front.x, front.y, front.x, front.y);
for(int i = 0; i < mSpans.size(); i++)
{
bounds.Include(mSpans[i].x, mSpans[i].y + 1);
bounds.Include(mSpans[i].x + mSpans[i].width, mSpans[i].y);
}
int width = bounds.GetWidth();
int height = bounds.GetHeight();
mDataSize.x = width;
mDataSize.y = height;
int size = width * height;
mBuffer = new unsigned char[size];
memset(mBuffer, 0, size);
for(int i = 0; i < mSpans.size(); i++)
{
GlyphSpan &span = mSpans[i];
for (int w = 0; w < span.width; ++w)
{
mBuffer[(int)((height - 1 - (span.y - bounds.top)) * width
+ span.x - bounds.left + w)] = span.coverage;
}
}
}
FT_Done_Glyph(glyph);
}