本文整理汇总了C++中SVGTextMetrics::setWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGTextMetrics::setWidth方法的具体用法?C++ SVGTextMetrics::setWidth怎么用?C++ SVGTextMetrics::setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGTextMetrics
的用法示例。
在下文中一共展示了SVGTextMetrics::setWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeMetricsForCharacter
SVGTextMetrics SVGTextMetricsCalculator::computeMetricsForCharacter(unsigned textPosition)
{
if (m_bidiRun) {
if (textPosition >= static_cast<unsigned>(m_bidiRun->stop())) {
m_bidiRun = m_bidiRun->next();
// New BiDi run means new reference position for measurements, so reset |m_totalWidth|.
m_totalWidth = 0;
}
ASSERT(m_bidiRun);
ASSERT(static_cast<int>(textPosition) < m_bidiRun->stop());
m_textDirection = m_bidiRun->direction();
}
unsigned metricsLength = characterStartsSurrogatePair(textPosition) ? 2 : 1;
SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(m_text, textPosition, metricsLength, m_textDirection);
ASSERT(metrics.length() == metricsLength);
unsigned startPosition = m_bidiRun ? m_bidiRun->start() : 0;
ASSERT(startPosition <= textPosition);
SVGTextMetrics complexStartToCurrentMetrics = SVGTextMetrics::measureCharacterRange(m_text, startPosition, textPosition - startPosition + metricsLength, m_textDirection);
// Frequent case for Arabic text: when measuring a single character the arabic isolated form is taken
// when laying out the glyph "in context" (with it's surrounding characters) it changes due to shaping.
// So whenever currentWidth != currentMetrics.width(), we are processing a text run whose length is
// not equal to the sum of the individual lengths of the glyphs, when measuring them isolated.
float currentWidth = complexStartToCurrentMetrics.width() - m_totalWidth;
if (currentWidth != metrics.width())
metrics.setWidth(currentWidth);
m_totalWidth = complexStartToCurrentMetrics.width();
return metrics;
}
示例2: computeMetricsForCharacterComplex
SVGTextMetrics SVGTextMetricsCalculator::computeMetricsForCharacterComplex(unsigned textPosition)
{
unsigned metricsLength = characterStartsSurrogatePair(textPosition) ? 2 : 1;
SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(m_text, textPosition, metricsLength, m_textDirection);
ASSERT(metrics.length() == metricsLength);
unsigned startPosition = m_bidiRun ? m_bidiRun->start() : 0;
ASSERT(startPosition <= textPosition);
SVGTextMetrics complexStartToCurrentMetrics = SVGTextMetrics::measureCharacterRange(m_text, startPosition, textPosition - startPosition + metricsLength, m_textDirection);
// Frequent case for Arabic text: when measuring a single character the arabic isolated form is taken
// when rendering the glyph "in context" (with it's surrounding characters) it changes due to shaping.
// So whenever currentWidth != currentMetrics.width(), we are processing a text run whose length is
// not equal to the sum of the individual lengths of the glyphs, when measuring them isolated.
float currentWidth = complexStartToCurrentMetrics.width() - m_totalWidth;
if (currentWidth != metrics.width())
metrics.setWidth(currentWidth);
m_totalWidth = complexStartToCurrentMetrics.width();
return metrics;
}