本文整理汇总了C++中SVGFontElement::horizontalKerningMapIsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGFontElement::horizontalKerningMapIsEmpty方法的具体用法?C++ SVGFontElement::horizontalKerningMapIsEmpty怎么用?C++ SVGFontElement::horizontalKerningMapIsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGFontElement
的用法示例。
在下文中一共展示了SVGFontElement::horizontalKerningMapIsEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applySVGKerning
bool SVGTextRunRenderingContext::applySVGKerning(const SimpleFontData* fontData, WidthIterator& iterator, GlyphBuffer* glyphBuffer, int from) const
{
ASSERT(glyphBuffer);
ASSERT(glyphBuffer->size() > 1);
SVGFontElement* fontElement = 0;
SVGFontFaceElement* fontFaceElement = 0;
svgFontAndFontFaceElementForFontData(fontData, fontFaceElement, fontElement);
if (!fontElement || !fontFaceElement)
return false;
if (fontElement->horizontalKerningMapIsEmpty())
return true;
float scale = scaleEmToUnits(fontData->platformData().size(), fontFaceElement->unitsPerEm());
String lastGlyphName;
String lastUnicodeString;
int characterOffset = iterator.m_currentCharacter;
String text = iterator.run().string();
const int glyphCount = glyphBuffer->size() - from;
GlyphBufferAdvance* advances = glyphBuffer->advances(from);
for (int i = 0; i < glyphCount; ++i) {
Glyph glyph = glyphBuffer->glyphAt(from + i);
if (!glyph)
continue;
float kerning = 0;
SVGGlyph svgGlyph = fontElement->svgGlyphForGlyph(glyph);
String unicodeString = text.substring(characterOffset, svgGlyph.unicodeStringLength);
if (i >= 1) {
// FIXME: Support vertical text.
kerning = fontElement->horizontalKerningForPairOfStringsAndGlyphs(lastUnicodeString, lastGlyphName, unicodeString, svgGlyph.glyphName);
advances[i - 1].setWidth(advances[i - 1].width() - kerning * scale);
}
lastGlyphName = svgGlyph.glyphName;
lastUnicodeString = unicodeString;
characterOffset += svgGlyph.unicodeStringLength;
}
return true;
}