本文整理汇总了C++中TextRun::normalizeSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ TextRun::normalizeSpace方法的具体用法?C++ TextRun::normalizeSpace怎么用?C++ TextRun::normalizeSpace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextRun
的用法示例。
在下文中一共展示了TextRun::normalizeSpace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: normalizeCharacters
static void normalizeCharacters(const TextRun& run, unsigned length, UChar* destination, unsigned* destinationLength)
{
unsigned position = 0;
bool error = false;
const UChar* source;
String stringFor8BitRun;
if (run.is8Bit()) {
stringFor8BitRun = String::make16BitFrom8BitSource(run.characters8(), run.length());
source = stringFor8BitRun.characters16();
} else {
source = run.characters16();
}
*destinationLength = 0;
while (position < length) {
UChar32 character;
U16_NEXT(source, position, length, character);
// Don't normalize tabs as they are not treated as spaces for word-end.
if (run.normalizeSpace() && Character::isNormalizedCanvasSpaceCharacter(character))
character = spaceCharacter;
else if (Character::treatAsSpace(character) && character != noBreakSpaceCharacter)
character = spaceCharacter;
else if (Character::treatAsZeroWidthSpaceInComplexScript(character))
character = zeroWidthSpaceCharacter;
U16_APPEND(destination, *destinationLength, length, character, error);
ASSERT_UNUSED(error, !error);
}
}
示例2: ASSERT
ShapeResultSpacing::ShapeResultSpacing(const TextRun& run,
const FontDescription& fontDescription)
: m_textRun(run)
, m_letterSpacing(fontDescription.letterSpacing())
, m_wordSpacing(fontDescription.wordSpacing())
, m_expansion(run.expansion())
, m_expansionPerOpportunity(0)
, m_expansionOpportunityCount(0)
, m_textJustify(TextJustify::TextJustifyAuto)
, m_hasSpacing(false)
, m_normalizeSpace(run.normalizeSpace())
, m_allowTabs(run.allowTabs())
, m_isAfterExpansion(false)
, m_isVerticalOffset(fontDescription.isVerticalAnyUpright())
{
if (m_textRun.spacingDisabled())
return;
if (!m_letterSpacing && !m_wordSpacing && !m_expansion)
return;
m_hasSpacing = true;
if (!m_expansion)
return;
// Setup for justifications (expansions.)
m_textJustify = run.getTextJustify();
m_isAfterExpansion = !run.allowsLeadingExpansion();
bool isAfterExpansion = m_isAfterExpansion;
m_expansionOpportunityCount = Character::expansionOpportunityCount(run,
isAfterExpansion);
if (isAfterExpansion && !run.allowsTrailingExpansion()) {
ASSERT(m_expansionOpportunityCount > 0);
--m_expansionOpportunityCount;
}
if (m_expansionOpportunityCount)
m_expansionPerOpportunity = m_expansion / m_expansionOpportunityCount;
}