本文整理汇总了C++中SVGTextMetrics::length方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGTextMetrics::length方法的具体用法?C++ SVGTextMetrics::length怎么用?C++ SVGTextMetrics::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGTextMetrics
的用法示例。
在下文中一共展示了SVGTextMetrics::length方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: measureTextRenderer
static void measureTextRenderer(RenderSVGInlineText* text, MeasureTextData* data, bool processRenderer)
{
ASSERT(text);
SVGTextLayoutAttributes* attributes = text->layoutAttributes();
Vector<SVGTextMetrics>* textMetricsValues = &attributes->textMetricsValues();
if (processRenderer) {
if (data->allCharactersMap)
attributes->clear();
else
textMetricsValues->clear();
}
SVGTextMetricsCalculator calculator(text);
bool preserveWhiteSpace = text->style()->whiteSpace() == PRE;
unsigned surrogatePairCharacters = 0;
unsigned skippedCharacters = 0;
unsigned textPosition = 0;
unsigned textLength = calculator.textLength();
SVGTextMetrics currentMetrics;
for (; textPosition < textLength; textPosition += currentMetrics.length()) {
currentMetrics = calculator.computeMetricsForCharacter(textPosition);
if (!currentMetrics.length())
break;
bool characterIsWhiteSpace = calculator.characterIsWhiteSpace(textPosition);
if (characterIsWhiteSpace && !preserveWhiteSpace && data->lastCharacterWasWhiteSpace) {
if (processRenderer)
textMetricsValues->append(SVGTextMetrics(SVGTextMetrics::SkippedSpaceMetrics));
if (data->allCharactersMap)
skippedCharacters += currentMetrics.length();
continue;
}
if (processRenderer) {
if (data->allCharactersMap) {
const SVGCharacterDataMap::const_iterator it = data->allCharactersMap->find(data->valueListPosition + textPosition - skippedCharacters - surrogatePairCharacters + 1);
if (it != data->allCharactersMap->end())
attributes->characterDataMap().set(textPosition + 1, it->value);
}
textMetricsValues->append(currentMetrics);
}
if (data->allCharactersMap && calculator.characterStartsSurrogatePair(textPosition))
surrogatePairCharacters++;
data->lastCharacterWasWhiteSpace = characterIsWhiteSpace;
}
if (!data->allCharactersMap)
return;
data->valueListPosition += textPosition - skippedCharacters;
}
示例2: 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;
}
示例3: 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;
}
示例4: advanceToNextLogicalCharacter
void SVGTextLayoutEngine::advanceToNextLogicalCharacter(const SVGTextMetrics& logicalMetrics)
{
++m_logicalMetricsListOffset;
m_logicalCharacterOffset += logicalMetrics.length();
}
示例5: advanceToNextVisualCharacter
void SVGTextLayoutEngine::advanceToNextVisualCharacter(const SVGTextMetrics& visualMetrics)
{
++m_visualMetricsListOffset;
m_visualCharacterOffset += visualMetrics.length();
}