本文整理汇总了C++中SVGFontElement::missingGlyph方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGFontElement::missingGlyph方法的具体用法?C++ SVGFontElement::missingGlyph怎么用?C++ SVGFontElement::missingGlyph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGFontElement
的用法示例。
在下文中一共展示了SVGFontElement::missingGlyph方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeFontData
void SVGFontData::initializeFontData(SimpleFontData* fontData, float fontSize)
{
ASSERT(fontData);
SVGFontFaceElement* svgFontFaceElement = this->svgFontFaceElement();
ASSERT(svgFontFaceElement);
SVGFontElement* svgFontElement = svgFontFaceElement->associatedFontElement();
ASSERT(svgFontElement);
GlyphData missingGlyphData;
missingGlyphData.fontData = fontData;
missingGlyphData.glyph = svgFontElement->missingGlyph();
fontData->setMissingGlyphData(missingGlyphData);
fontData->setZeroWidthSpaceGlyph(0);
fontData->determinePitch();
unsigned unitsPerEm = svgFontFaceElement->unitsPerEm();
float scale = scaleEmToUnits(fontSize, unitsPerEm);
float xHeight = svgFontFaceElement->xHeight() * scale;
float ascent = svgFontFaceElement->ascent() * scale;
float descent = svgFontFaceElement->descent() * scale;
float lineGap = 0.1f * fontSize;
GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(fontData, 0)->page();
if (!xHeight && glyphPageZero) {
// Fallback if x_heightAttr is not specified for the font element.
Glyph letterXGlyph = glyphPageZero->glyphDataForCharacter('x').glyph;
xHeight = letterXGlyph ? fontData->widthForGlyph(letterXGlyph) : 2 * ascent / 3;
}
FontMetrics& fontMetrics = fontData->fontMetrics();
fontMetrics.setUnitsPerEm(unitsPerEm);
fontMetrics.setAscent(ascent);
fontMetrics.setDescent(descent);
fontMetrics.setLineGap(lineGap);
fontMetrics.setLineSpacing(roundf(ascent) + roundf(descent) + roundf(lineGap));
fontMetrics.setXHeight(xHeight);
if (!glyphPageZero) {
fontData->setSpaceGlyph(0);
fontData->setSpaceWidths(0);
fontData->setAvgCharWidth(0);
fontData->setMaxCharWidth(ascent);
return;
}
// Calculate space width.
Glyph spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph;
fontData->setSpaceGlyph(spaceGlyph);
fontData->setSpaceWidths(fontData->widthForGlyph(spaceGlyph));
// Estimate average character width.
Glyph numeralZeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph;
fontData->setAvgCharWidth(numeralZeroGlyph ? fontData->widthForGlyph(numeralZeroGlyph) : fontData->spaceWidth());
// Estimate maximum character width.
Glyph letterWGlyph = glyphPageZero->glyphDataForCharacter('W').glyph;
fontData->setMaxCharWidth(letterWGlyph ? fontData->widthForGlyph(letterWGlyph) : ascent);
}