本文整理汇总了C++中glyph_positions::size方法的典型用法代码示例。如果您正苦于以下问题:C++ glyph_positions::size方法的具体用法?C++ glyph_positions::size怎么用?C++ glyph_positions::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glyph_positions
的用法示例。
在下文中一共展示了glyph_positions::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepare_glyphs
void text_renderer::prepare_glyphs(glyph_positions const& positions)
{
FT_Matrix matrix;
FT_Vector pen;
FT_Error error;
glyphs_.reserve(positions.size());
for (auto const& glyph_pos : positions)
{
glyph_info const& glyph = glyph_pos.glyph;
glyph.face->set_character_sizes(glyph.format->text_size * scale_factor_); //TODO: Optimize this?
matrix.xx = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);
matrix.xy = static_cast<FT_Fixed>(-glyph_pos.rot.sin * 0x10000L);
matrix.yx = static_cast<FT_Fixed>( glyph_pos.rot.sin * 0x10000L);
matrix.yy = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);
pixel_position pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
pen.x = static_cast<FT_Pos>(pos.x * 64);
pen.y = static_cast<FT_Pos>(pos.y * 64);
FT_Face face = glyph.face->get_face();
FT_Set_Transform(face, &matrix, &pen);
error = FT_Load_Glyph(face, glyph.glyph_index, FT_LOAD_NO_HINTING);
if (error) continue;
FT_Glyph image;
error = FT_Get_Glyph(face->glyph, &image);
if (error) continue;
glyphs_.emplace_back(image, *glyph.format);
}
}
示例2: prepare_glyphs
void text_renderer::prepare_glyphs(glyph_positions const& positions)
{
FT_Matrix matrix;
FT_Vector pen;
FT_Error error;
glyphs_.clear();
glyphs_.reserve(positions.size());
for (auto const& glyph_pos : positions)
{
glyph_info const& glyph = glyph_pos.glyph;
FT_Int32 load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING;
FT_Face face = glyph.face->get_face();
if (glyph.face->is_color())
{
load_flags |= FT_LOAD_COLOR ;
if (face->num_fixed_sizes > 0)
{
int scaled_size = static_cast<int>(glyph.format->text_size * scale_factor_);
int best_match = 0;
int diff = std::abs(scaled_size - face->available_sizes[0].width);
for (int i = 1; i < face->num_fixed_sizes; ++i)
{
int ndiff = std::abs(scaled_size - face->available_sizes[i].height);
if (ndiff < diff)
{
best_match = i;
diff = ndiff;
}
}
error = FT_Select_Size(face, best_match);
}
}
else
{
glyph.face->set_character_sizes(glyph.format->text_size * scale_factor_);
}
double size = glyph.format->text_size * scale_factor_;
matrix.xx = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);
matrix.xy = static_cast<FT_Fixed>(-glyph_pos.rot.sin * 0x10000L);
matrix.yx = static_cast<FT_Fixed>( glyph_pos.rot.sin * 0x10000L);
matrix.yy = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);
pixel_position pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
pen.x = static_cast<FT_Pos>(pos.x * 64);
pen.y = static_cast<FT_Pos>(pos.y * 64);
FT_Set_Transform(face, &matrix, &pen);
error = FT_Load_Glyph(face, glyph.glyph_index, load_flags);
if (error) continue;
FT_Glyph image;
error = FT_Get_Glyph(face->glyph, &image);
if (error) continue;
box2d<double> bbox(0, glyph_pos.glyph.ymin(), glyph_pos.glyph.advance(), glyph_pos.glyph.ymax());
glyphs_.emplace_back(image, *glyph.format, pos, glyph_pos.rot, size, bbox);
}
}