本文整理汇总了C++中GlyphBuffer::swap方法的典型用法代码示例。如果您正苦于以下问题:C++ GlyphBuffer::swap方法的具体用法?C++ GlyphBuffer::swap怎么用?C++ GlyphBuffer::swap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlyphBuffer
的用法示例。
在下文中一共展示了GlyphBuffer::swap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawComplexText
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point,
int from, int to) const
{
// This glyph buffer holds our glyphs + advances + font data for each glyph.
GlyphBuffer glyphBuffer;
float startX = point.x();
CoreTextController controller(this, run);
controller.advance(from);
float beforeWidth = controller.runWidthSoFar();
controller.advance(to, &glyphBuffer);
// We couldn't generate any glyphs for the run. Give up.
if (glyphBuffer.isEmpty())
return;
float afterWidth = controller.runWidthSoFar();
if (run.rtl()) {
startX += controller.totalWidth() + controller.finalRoundingWidth() - afterWidth;
for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
glyphBuffer.swap(i, end);
} else
startX += beforeWidth;
// Draw the glyph buffer now at the starting point returned in startX.
FloatPoint startPoint(startX, point.y());
drawGlyphBuffer(context, glyphBuffer, run, startPoint);
}
示例2: drawSimpleText
void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
// This glyph buffer holds our glyphs+advances+font data for each glyph.
GlyphBuffer glyphBuffer;
float startX = point.x();
WidthIterator it(this, run);
it.advance(from);
float beforeWidth = it.m_runWidthSoFar;
it.advance(to, &glyphBuffer);
// We couldn't generate any glyphs for the run. Give up.
if (glyphBuffer.isEmpty())
return;
float afterWidth = it.m_runWidthSoFar;
if (run.rtl()) {
float finalRoundingWidth = it.m_finalRoundingWidth;
it.advance(run.length());
startX += finalRoundingWidth + it.m_runWidthSoFar - afterWidth;
} else
startX += beforeWidth;
// Swap the order of the glyphs if right-to-left.
if (run.rtl())
for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
glyphBuffer.swap(i, end);
// Calculate the starting point of the glyphs to be displayed by adding
// all the advances up to the first glyph.
FloatPoint startPoint(startX, point.y());
drawGlyphBuffer(context, glyphBuffer, run, startPoint);
}
示例3: getGlyphsAndAdvancesForComplexText
float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
{
float initialAdvance;
ComplexTextController controller(this, run, false, 0, forTextEmphasis);
controller.advance(from);
float beforeWidth = controller.runWidthSoFar();
controller.advance(to, &glyphBuffer);
if (glyphBuffer.isEmpty())
return 0;
float afterWidth = controller.runWidthSoFar();
if (run.rtl()) {
initialAdvance = controller.totalWidth() - afterWidth;
for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
glyphBuffer.swap(i, end);
} else
initialAdvance = beforeWidth;
return initialAdvance;
}