本文整理汇总了C++中SimpleFontData::platformData方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleFontData::platformData方法的具体用法?C++ SimpleFontData::platformData怎么用?C++ SimpleFontData::platformData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleFontData
的用法示例。
在下文中一共展示了SimpleFontData::platformData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fontCache
PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)
{
// If the font hasn't loaded or an error occurred, then we've got nothing.
if (!isValid())
return 0;
if (!m_font
#if ENABLE(SVG_FONTS)
&& !m_svgFontFaceElement
#endif
) {
// We're local. Just return a SimpleFontData from the normal cache.
// We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
return fontCache()->getCachedFontData(fontDescription, m_string, true);
}
// See if we have a mapping in our FontData cache.
unsigned hashKey = (fontDescription.computedPixelSize() + 1) << 5 | fontDescription.widthVariant() << 3
| (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0);
RefPtr<SimpleFontData>& fontData = m_fontDataTable.add(hashKey, nullptr).iterator->value;
if (fontData)
return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.
// If we are still loading, then we let the system pick a font.
if (isLoaded()) {
if (m_font) {
#if ENABLE(SVG_FONTS)
if (m_hasExternalSVGFont) {
// For SVG fonts parse the external SVG document, and extract the <font> element.
if (!m_font->ensureSVGFontData())
return 0;
if (!m_externalSVGFontElement) {
String fragmentIdentifier;
size_t start = m_string.find('#');
if (start != notFound)
fragmentIdentifier = m_string.string().substring(start + 1);
m_externalSVGFontElement = m_font->getSVGFontById(fragmentIdentifier);
}
if (!m_externalSVGFontElement)
return 0;
if (auto firstFontFace = childrenOfType<SVGFontFaceElement>(m_externalSVGFontElement.get()).first()) {
if (!m_svgFontFaceElement) {
// We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
// Use the imported <font-face> tag as referencing font-face element for these cases.
m_svgFontFaceElement = firstFontFace;
}
fontData = SimpleFontData::create(SVGFontData::create(firstFontFace), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
}
} else
#endif
{
// Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
if (!m_font->ensureCustomFontData())
return 0;
fontData = SimpleFontData::create(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic,
fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false);
}
} else {
#if ENABLE(SVG_FONTS)
// In-Document SVG Fonts
if (m_svgFontFaceElement)
fontData = SimpleFontData::create(SVGFontData::create(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
#endif
}
} else {
// Kick off the load. Do it soon rather than now, because we may be in the middle of layout,
// and the loader may invoke arbitrary delegate or event handler code.
fontSelector->beginLoadingFontSoon(m_font.get());
// This temporary font is not retained and should not be returned.
FontCachePurgePreventer fontCachePurgePreventer;
SimpleFontData* temporaryFont = fontCache()->getNonRetainedLastResortFallbackFont(fontDescription);
fontData = SimpleFontData::create(temporaryFont->platformData(), true, true);
}
return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.
}
示例2: getFontData
SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)
{
// If the font hasn't loaded or an error occurred, then we've got nothing.
if (!isValid())
return 0;
#if ENABLE(SVG_FONTS)
if (!m_font && !m_svgFontFaceElement) {
#else
if (!m_font) {
#endif
SimpleFontData* fontData = fontCache()->getCachedFontData(fontDescription, m_string);
// We're local. Just return a SimpleFontData from the normal cache.
return fontData;
}
// See if we have a mapping in our FontData cache.
unsigned hashKey = fontDescription.computedPixelSize() << 3 | (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0);
if (SimpleFontData* cachedData = m_fontDataTable.get(hashKey))
return cachedData;
OwnPtr<SimpleFontData> fontData;
// If we are still loading, then we let the system pick a font.
if (isLoaded()) {
if (m_font) {
#if ENABLE(SVG_FONTS)
if (m_font->isSVGFont()) {
// For SVG fonts parse the external SVG document, and extract the <font> element.
if (!m_font->ensureSVGFontData())
return 0;
if (!m_externalSVGFontElement)
m_externalSVGFontElement = m_font->getSVGFontById(SVGURIReference::getTarget(m_string));
if (!m_externalSVGFontElement)
return 0;
SVGFontFaceElement* fontFaceElement = 0;
// Select first <font-face> child
for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) {
if (fontChild->hasTagName(SVGNames::font_faceTag)) {
fontFaceElement = static_cast<SVGFontFaceElement*>(fontChild);
break;
}
}
if (fontFaceElement) {
if (!m_svgFontFaceElement) {
// We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
// Use the imported <font-face> tag as referencing font-face element for these cases.
m_svgFontFaceElement = fontFaceElement;
}
fontData.set(new SimpleFontData(adoptPtr(new SVGFontData(fontFaceElement)), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));
}
} else
#endif
{
// Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
if (!m_font->ensureCustomFontData())
return 0;
fontData.set(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.orientation(), fontDescription.renderingMode()), true, false));
}
} else {
#if ENABLE(SVG_FONTS)
// In-Document SVG Fonts
if (m_svgFontFaceElement)
fontData.set(new SimpleFontData(adoptPtr(new SVGFontData(m_svgFontFaceElement)), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));
#endif
}
} else {
// Kick off the load now.
if (CachedResourceLoader* cachedResourceLoader = fontSelector->cachedResourceLoader())
m_font->beginLoadIfNeeded(cachedResourceLoader);
// FIXME: m_string is a URL so it makes no sense to pass it as a family name.
SimpleFontData* tempData = fontCache()->getCachedFontData(fontDescription, m_string);
if (!tempData)
tempData = fontCache()->getLastResortFallbackFont(fontDescription);
fontData.set(new SimpleFontData(tempData->platformData(), true, true));
}
SimpleFontData* fontDataRawPtr = fontData.leakPtr();
m_fontDataTable.set(hashKey, fontDataRawPtr);
return fontDataRawPtr;
}
#if ENABLE(SVG_FONTS)
bool CSSFontFaceSource::isSVGFontFaceSource() const
{
return m_svgFontFaceElement || (m_font && m_font->isSVGFont());
}
#endif
}
示例3: ENABLE
PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& fontDescription)
{
// If the font hasn't loaded or an error occurred, then we've got nothing.
if (!isValid())
return 0;
if (isLocal()) {
// We're local. Just return a SimpleFontData from the normal cache.
// We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
RefPtr<SimpleFontData> fontData = FontCache::fontCache()->getFontData(fontDescription, m_string, true);
m_histograms.recordLocalFont(fontData);
return fontData;
}
// See if we have a mapping in our FontData cache.
AtomicString emptyFontFamily = "";
FontCacheKey key = fontDescription.cacheKey(emptyFontFamily);
RefPtr<SimpleFontData>& fontData = m_fontDataTable.add(key.hash(), 0).iterator->value;
if (fontData)
return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.
// If we are still loading, then we let the system pick a font.
if (isLoaded()) {
if (m_font) {
#if ENABLE(SVG_FONTS)
if (m_hasExternalSVGFont) {
// For SVG fonts parse the external SVG document, and extract the <font> element.
if (!m_font->ensureSVGFontData())
return 0;
if (!m_externalSVGFontElement) {
String fragmentIdentifier;
size_t start = m_string.find('#');
if (start != kNotFound)
fragmentIdentifier = m_string.string().substring(start + 1);
m_externalSVGFontElement = m_font->getSVGFontById(fragmentIdentifier);
}
if (!m_externalSVGFontElement)
return 0;
SVGFontFaceElement* fontFaceElement = 0;
// Select first <font-face> child
for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) {
if (fontChild->hasTagName(SVGNames::font_faceTag)) {
fontFaceElement = toSVGFontFaceElement(fontChild);
break;
}
}
if (fontFaceElement) {
if (!m_svgFontFaceElement) {
// We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
// Use the imported <font-face> tag as referencing font-face element for these cases.
m_svgFontFaceElement = fontFaceElement;
}
fontData = SimpleFontData::create(
SVGFontData::create(fontFaceElement),
fontDescription.effectiveFontSize(),
fontDescription.isSyntheticBold(),
fontDescription.isSyntheticItalic());
}
} else
#endif
{
// Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
if (!m_font->ensureCustomFontData())
return 0;
fontData = SimpleFontData::create(
m_font->platformDataFromCustomData(fontDescription.effectiveFontSize(),
fontDescription.isSyntheticBold(), fontDescription.isSyntheticItalic(),
fontDescription.orientation(), fontDescription.widthVariant()), CustomFontData::create(false));
}
} else {
#if ENABLE(SVG_FONTS)
// In-Document SVG Fonts
if (m_svgFontFaceElement) {
fontData = SimpleFontData::create(
SVGFontData::create(m_svgFontFaceElement.get()),
fontDescription.effectiveFontSize(),
fontDescription.isSyntheticBold(),
fontDescription.isSyntheticItalic());
}
#endif
}
} else {
// This temporary font is not retained and should not be returned.
FontCachePurgePreventer fontCachePurgePreventer;
SimpleFontData* temporaryFont = FontCache::fontCache()->getNonRetainedLastResortFallbackFont(fontDescription);
if (!temporaryFont) {
ASSERT_NOT_REACHED();
return 0;
}
RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(true);
cssFontData->setCSSFontFaceSource(this);
fontData = SimpleFontData::create(temporaryFont->platformData(), cssFontData);
//.........这里部分代码省略.........
示例4: getFontData
SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)
{
// If the font hasn't loaded or an error occurred, then we've got nothing.
if (!isValid())
return 0;
if (!m_font
#if ENABLE(SVG_FONTS)
&& !m_svgFontFaceElement
#endif
) {
// We're local. Just return a SimpleFontData from the normal cache.
return fontCache()->getCachedFontData(fontDescription, m_string);
}
// See if we have a mapping in our FontData cache.
unsigned hashKey = (fontDescription.computedPixelSize() + 1) << 6 | fontDescription.widthVariant() << 4
| (fontDescription.textOrientation() == TextOrientationUpright ? 8 : 0) | (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0);
SimpleFontData*& cachedData = m_fontDataTable.add(hashKey, 0).first->second;
if (cachedData)
return cachedData;
OwnPtr<SimpleFontData> fontData;
// If we are still loading, then we let the system pick a font.
if (isLoaded()) {
if (m_font) {
#if ENABLE(SVG_FONTS)
if (m_hasExternalSVGFont) {
// For SVG fonts parse the external SVG document, and extract the <font> element.
if (!m_font->ensureSVGFontData())
return 0;
if (!m_externalSVGFontElement) {
String fragmentIdentifier;
size_t start = m_string.find('#');
if (start != notFound)
fragmentIdentifier = m_string.string().substring(start + 1);
m_externalSVGFontElement = m_font->getSVGFontById(fragmentIdentifier);
}
if (!m_externalSVGFontElement)
return 0;
SVGFontFaceElement* fontFaceElement = 0;
// Select first <font-face> child
for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) {
if (fontChild->hasTagName(SVGNames::font_faceTag)) {
fontFaceElement = static_cast<SVGFontFaceElement*>(fontChild);
break;
}
}
if (fontFaceElement) {
if (!m_svgFontFaceElement) {
// We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
// Use the imported <font-face> tag as referencing font-face element for these cases.
m_svgFontFaceElement = fontFaceElement;
}
fontData = adoptPtr(new SimpleFontData(SVGFontData::create(fontFaceElement), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));
}
} else
#endif
{
// Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
if (!m_font->ensureCustomFontData())
return 0;
fontData = adoptPtr(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.orientation(),
fontDescription.textOrientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false));
}
} else {
#if ENABLE(SVG_FONTS)
// In-Document SVG Fonts
if (m_svgFontFaceElement)
fontData = adoptPtr(new SimpleFontData(SVGFontData::create(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));
#endif
}
} else {
// Kick off the load. Do it soon rather than now, because we may be in the middle of layout,
// and the loader may invoke arbitrary delegate or event handler code.
fontSelector->beginLoadingFontSoon(m_font.get());
// This temporary font is not retained and should not be returned.
FontCachePurgePreventer fontCachePurgePreventer;
SimpleFontData* temporaryFont = fontCache()->getNonRetainedLastResortFallbackFont(fontDescription);
fontData = adoptPtr(new SimpleFontData(temporaryFont->platformData(), true, true));
}
if (Document* document = fontSelector->document()) {
cachedData = fontData.get();
document->registerCustomFont(fontData.release());
}
return cachedData;
}