本文整理汇总了C++中TextRun::apply方法的典型用法代码示例。如果您正苦于以下问题:C++ TextRun::apply方法的具体用法?C++ TextRun::apply怎么用?C++ TextRun::apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextRun
的用法示例。
在下文中一共展示了TextRun::apply方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
TextLayout::TextLayout(VirtualFont *virtualFont, const TextRun &run)
:
direction(run.direction)
{
auto buffer = hb_buffer_create();
map<uint32_t, Cluster> clusterMap;
advance = 0;
for (auto font : virtualFont->getFontSet(run.lang))
{
hb_buffer_clear_contents(buffer);
run.apply(buffer);
hb_shape(font->hbFont, buffer, NULL, 0);
auto glyphCount = hb_buffer_get_length(buffer);
auto glyphInfos = hb_buffer_get_glyph_infos(buffer, NULL);
auto glyphPositions = hb_buffer_get_glyph_positions(buffer, NULL);
bool hasMissingGlyphs = false;
for (int i = 0; i < glyphCount; i++)
{
auto codepoint = glyphInfos[i].codepoint;
auto cluster = glyphInfos[i].cluster;
auto it = clusterMap.find(cluster);
bool clusterFound = (it != clusterMap.end());
if (codepoint)
{
if (clusterFound && (it->second.font != font))
{
continue; // CLUSTER FOUND, WITH ANOTHER FONT (E.G. SPACE)
}
else
{
auto offset = Vec2f(glyphPositions[i].x_offset, -glyphPositions[i].y_offset) * font->scale;
float advance = glyphPositions[i].x_advance * font->scale.x;
if (clusterFound)
{
it->second.addShape(codepoint, offset, advance);
}
else
{
clusterMap.insert(make_pair(cluster, Cluster(font, codepoint, offset, advance)));
}
}
}
else if (!clusterFound)
{
hasMissingGlyphs = true;
}
}
if (!hasMissingGlyphs)
{
break; // NO NEED TO PROCEED TO THE NEXT FONT IN THE LIST
}
}
if (run.direction == HB_DIRECTION_RTL)
{
for (auto it = clusterMap.rbegin(); it != clusterMap.rend(); ++it)
{
addCluster(it->second);
}
}
else
{
for (auto it = clusterMap.begin(); it != clusterMap.end(); ++it)
{
addCluster(it->second);
}
}
hb_buffer_destroy(buffer);
}