本文整理汇总了C++中SVGFontElement::getGlyphIdentifiersForString方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGFontElement::getGlyphIdentifiersForString方法的具体用法?C++ SVGFontElement::getGlyphIdentifiersForString怎么用?C++ SVGFontElement::getGlyphIdentifiersForString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGFontElement
的用法示例。
在下文中一共展示了SVGFontElement::getGlyphIdentifiersForString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ENABLE
SimpleFontData::SimpleFontData(const FontPlatformData& f, bool customFont, bool loading, SVGFontData* svgFontData)
: m_maxCharWidth(-1)
, m_avgCharWidth(-1)
, m_unitsPerEm(defaultUnitsPerEm)
, m_platformData(f)
, m_treatAsFixedPitch(false)
#if ENABLE(SVG_FONTS)
, m_svgFontData(svgFontData)
#endif
, m_isCustomFont(customFont)
, m_isLoading(loading)
, m_smallCapsFontData(0)
#if (PLATFORM(WKC))
, m_lineSpacing(0)
#endif
{
#if !ENABLE(SVG_FONTS)
UNUSED_PARAM(svgFontData);
#else
if (SVGFontFaceElement* svgFontFaceElement = svgFontData ? svgFontData->svgFontFaceElement() : 0) {
m_unitsPerEm = svgFontFaceElement->unitsPerEm();
double scale = f.size();
if (m_unitsPerEm)
scale /= m_unitsPerEm;
m_ascent = static_cast<int>(svgFontFaceElement->ascent() * scale);
m_descent = static_cast<int>(svgFontFaceElement->descent() * scale);
m_xHeight = static_cast<int>(svgFontFaceElement->xHeight() * scale);
m_lineGap = 0.1f * f.size();
m_lineSpacing = m_ascent + m_descent + m_lineGap;
SVGFontElement* associatedFontElement = svgFontFaceElement->associatedFontElement();
Vector<SVGGlyphIdentifier> spaceGlyphs;
associatedFontElement->getGlyphIdentifiersForString(String(" ", 1), spaceGlyphs);
m_spaceWidth = spaceGlyphs.isEmpty() ? m_xHeight : static_cast<float>(spaceGlyphs.first().horizontalAdvanceX * scale);
Vector<SVGGlyphIdentifier> numeralZeroGlyphs;
associatedFontElement->getGlyphIdentifiersForString(String("0", 1), numeralZeroGlyphs);
m_avgCharWidth = numeralZeroGlyphs.isEmpty() ? m_spaceWidth : static_cast<float>(numeralZeroGlyphs.first().horizontalAdvanceX * scale);
Vector<SVGGlyphIdentifier> letterWGlyphs;
associatedFontElement->getGlyphIdentifiersForString(String("W", 1), letterWGlyphs);
m_maxCharWidth = letterWGlyphs.isEmpty() ? m_ascent : static_cast<float>(letterWGlyphs.first().horizontalAdvanceX * scale);
// FIXME: is there a way we can get the space glyph from the SVGGlyphIdentifier above?
m_spaceGlyph = 0;
determinePitch();
m_adjustedSpaceWidth = roundf(m_spaceWidth);
m_missingGlyphData.fontData = this;
m_missingGlyphData.glyph = 0;
return;
}
#endif
platformInit();
platformGlyphInit();
platformCharWidthInit();
}
示例2: roundf
SimpleFontData::SimpleFontData(PassOwnPtr<SVGFontData> svgFontData, int size, bool syntheticBold, bool syntheticItalic)
: m_platformData(FontPlatformData(size, syntheticBold, syntheticItalic))
, m_treatAsFixedPitch(false)
, m_svgFontData(svgFontData)
, m_isCustomFont(true)
, m_isLoading(false)
, m_isTextOrientationFallback(false)
, m_isBrokenIdeographFallback(false)
, m_hasVerticalGlyphs(false)
{
SVGFontFaceElement* svgFontFaceElement = m_svgFontData->svgFontFaceElement();
unsigned unitsPerEm = svgFontFaceElement->unitsPerEm();
float scale = size;
if (unitsPerEm)
scale /= unitsPerEm;
float xHeight = svgFontFaceElement->xHeight() * scale;
float ascent = svgFontFaceElement->ascent() * scale;
float descent = svgFontFaceElement->descent() * scale;
float lineGap = 0.1f * size;
SVGFontElement* associatedFontElement = svgFontFaceElement->associatedFontElement();
if (!xHeight) {
// Fallback if x_heightAttr is not specified for the font element.
Vector<SVGGlyphIdentifier> letterXGlyphs;
associatedFontElement->getGlyphIdentifiersForString(String("x", 1), letterXGlyphs);
xHeight = letterXGlyphs.isEmpty() ? 2 * ascent / 3 : letterXGlyphs.first().horizontalAdvanceX * scale;
}
m_fontMetrics.setUnitsPerEm(unitsPerEm);
m_fontMetrics.setAscent(ascent);
m_fontMetrics.setDescent(descent);
m_fontMetrics.setLineGap(lineGap);
m_fontMetrics.setLineSpacing(roundf(ascent) + roundf(descent) + roundf(lineGap));
m_fontMetrics.setXHeight(xHeight);
Vector<SVGGlyphIdentifier> spaceGlyphs;
associatedFontElement->getGlyphIdentifiersForString(String(" ", 1), spaceGlyphs);
m_spaceWidth = spaceGlyphs.isEmpty() ? xHeight : spaceGlyphs.first().horizontalAdvanceX * scale;
Vector<SVGGlyphIdentifier> numeralZeroGlyphs;
associatedFontElement->getGlyphIdentifiersForString(String("0", 1), numeralZeroGlyphs);
m_avgCharWidth = numeralZeroGlyphs.isEmpty() ? m_spaceWidth : numeralZeroGlyphs.first().horizontalAdvanceX * scale;
Vector<SVGGlyphIdentifier> letterWGlyphs;
associatedFontElement->getGlyphIdentifiersForString(String("W", 1), letterWGlyphs);
m_maxCharWidth = letterWGlyphs.isEmpty() ? ascent : letterWGlyphs.first().horizontalAdvanceX * scale;
// FIXME: is there a way we can get the space glyph from the SVGGlyphIdentifier above?
m_spaceGlyph = 0;
m_zeroWidthSpaceGlyph = 0;
determinePitch();
m_missingGlyphData.fontData = this;
m_missingGlyphData.glyph = 0;
}
示例3: determinePitch
SimpleFontData::SimpleFontData(PassOwnPtr<SVGFontData> svgFontData, int size, bool syntheticBold, bool syntheticItalic)
: m_orientation(Horizontal)
, m_platformData(FontPlatformData(size, syntheticBold, syntheticItalic))
, m_treatAsFixedPitch(false)
, m_svgFontData(svgFontData)
, m_isCustomFont(true)
, m_isLoading(false)
, m_isBrokenIdeographFont(false)
{
SVGFontFaceElement* svgFontFaceElement = m_svgFontData->svgFontFaceElement();
m_unitsPerEm = svgFontFaceElement->unitsPerEm();
double scale = size;
if (m_unitsPerEm)
scale /= m_unitsPerEm;
m_ascent = static_cast<int>(svgFontFaceElement->ascent() * scale);
m_descent = static_cast<int>(svgFontFaceElement->descent() * scale);
m_xHeight = static_cast<int>(svgFontFaceElement->xHeight() * scale);
m_lineGap = 0.1f * size;
m_lineSpacing = m_ascent + m_descent + m_lineGap;
SVGFontElement* associatedFontElement = svgFontFaceElement->associatedFontElement();
Vector<SVGGlyphIdentifier> spaceGlyphs;
associatedFontElement->getGlyphIdentifiersForString(String(" ", 1), spaceGlyphs);
m_spaceWidth = spaceGlyphs.isEmpty() ? m_xHeight : static_cast<float>(spaceGlyphs.first().horizontalAdvanceX * scale);
Vector<SVGGlyphIdentifier> numeralZeroGlyphs;
associatedFontElement->getGlyphIdentifiersForString(String("0", 1), numeralZeroGlyphs);
m_avgCharWidth = numeralZeroGlyphs.isEmpty() ? m_spaceWidth : static_cast<float>(numeralZeroGlyphs.first().horizontalAdvanceX * scale);
Vector<SVGGlyphIdentifier> letterWGlyphs;
associatedFontElement->getGlyphIdentifiersForString(String("W", 1), letterWGlyphs);
m_maxCharWidth = letterWGlyphs.isEmpty() ? m_ascent : static_cast<float>(letterWGlyphs.first().horizontalAdvanceX * scale);
// FIXME: is there a way we can get the space glyph from the SVGGlyphIdentifier above?
m_spaceGlyph = 0;
m_zeroWidthSpaceGlyph = 0;
determinePitch();
m_adjustedSpaceWidth = roundf(m_spaceWidth);
m_missingGlyphData.fontData = this;
m_missingGlyphData.glyph = 0;
}