本文整理汇总了C++中TextRun::xPos方法的典型用法代码示例。如果您正苦于以下问题:C++ TextRun::xPos方法的具体用法?C++ TextRun::xPos怎么用?C++ TextRun::xPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextRun
的用法示例。
在下文中一共展示了TextRun::xPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adoptPtr
PassRefPtr<ShapeResult> ShapeResult::createForTabulationCharacters(const Font* font,
const TextRun& textRun, float positionOffset, unsigned count)
{
const SimpleFontData* fontData = font->primaryFont();
OwnPtr<ShapeResult::RunInfo> run = adoptPtr(new ShapeResult::RunInfo(fontData,
// Tab characters are always LTR or RTL, not TTB, even when isVerticalAnyUpright().
textRun.rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR,
HB_SCRIPT_COMMON, 0, count, count));
float position = textRun.xPos() + positionOffset;
float startPosition = position;
for (unsigned i = 0; i < count; i++) {
float advance = font->tabWidth(*fontData, textRun.getTabSize(), position);
run->m_glyphData[i].characterIndex = i;
run->setGlyphAndPositions(i, fontData->spaceGlyph(), advance, 0, 0);
position += advance;
}
run->m_width = position - startPosition;
RefPtr<ShapeResult> result = ShapeResult::create(font, count, textRun.direction());
result->m_width = run->m_width;
result->m_numGlyphs = count;
ASSERT(result->m_numGlyphs == count); // no overflow
result->m_hasVerticalOffsets = fontData->platformData().isVerticalAnyUpright();
result->m_runs.append(run.release());
return result.release();
}