本文整理汇总了C++中RenderBatchTriangle::draw_glyph_subpixel方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderBatchTriangle::draw_glyph_subpixel方法的具体用法?C++ RenderBatchTriangle::draw_glyph_subpixel怎么用?C++ RenderBatchTriangle::draw_glyph_subpixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderBatchTriangle
的用法示例。
在下文中一共展示了RenderBatchTriangle::draw_glyph_subpixel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_text
void GlyphCache::draw_text(FontEngine *font_engine, Canvas &canvas, float xpos, float ypos, const std::string &text, const Colorf &color)
{
std::string::size_type string_length = text.length();
if (string_length==0)
{
return;
}
RenderBatchTriangle *batcher = canvas.impl->batcher.get_triangle_batcher();
GraphicContext &gc = canvas.get_gc();
// Scan the string
UTF8_Reader reader(text.data(), text.length());
while(!reader.is_end())
{
unsigned int glyph = reader.get_char();
reader.next();
Font_TextureGlyph *gptr = get_glyph(font_engine, gc, glyph);
if (gptr == NULL) continue;
if (!gptr->texture.is_null())
{
float xp = xpos + gptr->offset.x;
float yp = ypos + gptr->offset.y;
Rectf dest_size(xp, yp, Sizef(gptr->geometry.get_size()));
if (enable_subpixel)
{
batcher->draw_glyph_subpixel(canvas, gptr->geometry, dest_size, color, gptr->texture);
}else
{
batcher->draw_image(canvas, gptr->geometry, dest_size, color, gptr->texture);
}
}
xpos += gptr->increment.x;
ypos += gptr->increment.y;
}
}
示例2: draw_text
void Font_DrawSubPixel::draw_text(Canvas &canvas, const Pointf &position, const std::string &text, const Colorf &color, float line_spacing)
{
float offset_x = 0;
float offset_y = 0;
UTF8_Reader reader(text.data(), text.length());
RenderBatchTriangle *batcher = canvas.impl->batcher.get_triangle_batcher();
while (!reader.is_end())
{
unsigned int glyph = reader.get_char();
reader.next();
if (glyph == '\n')
{
offset_x = 0;
offset_y += line_spacing;
continue;
}
Font_TextureGlyph *gptr = glyph_cache->get_glyph(canvas, font_engine, glyph);
if (gptr)
{
if (!gptr->texture.is_null())
{
float xp = offset_x + position.x + gptr->offset.x;
float yp = offset_y + position.y + gptr->offset.y;
Pointf pos = canvas.grid_fit(Pointf(xp, yp));
Rectf dest_size(pos, gptr->size);
batcher->draw_glyph_subpixel(canvas, gptr->geometry, dest_size, color, gptr->texture);
}
offset_x += gptr->metrics.advance.width;
offset_y += gptr->metrics.advance.height;
}
}
}