const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) { #if defined(USE_FREETYPE) FcResult fresult; FontPlatformData* prim = const_cast<FontPlatformData*>(&font.primaryFont()->platformData()); if (!prim->m_fallbacks) prim->m_fallbacks = FcFontSort(NULL, prim->m_pattern, FcTrue, NULL, &fresult); FcFontSet* fs = prim->m_fallbacks; for (int i = 0; i < fs->nfont; i++) { FcPattern* fin = FcFontRenderPrepare(NULL, prim->m_pattern, fs->fonts[i]); cairo_font_face_t* fontFace = cairo_ft_font_face_create_for_pattern(fin); FontPlatformData alternateFont(fontFace, font.fontDescription().computedPixelSize(), false, false); cairo_font_face_destroy(fontFace); alternateFont.m_pattern = fin; SimpleFontData* sfd = getCachedFontData(&alternateFont); if (sfd->containsCharacters(characters, length)) return sfd; } #endif return 0; }
void RemoteFontFaceSource::pruneTable() { if (m_fontDataTable.isEmpty()) return; for (const auto& item : m_fontDataTable) { SimpleFontData* fontData = item.value.get(); if (fontData && fontData->customFontData()) fontData->customFontData()->clearFontFaceSource(); } m_fontDataTable.clear(); }
const SimpleFontData* Font::fontDataForCombiningCharacterSequence(const UChar* characters, size_t length, FontDataVariant variant) const { UChar32 baseCharacter; size_t baseCharacterLength = 0; U16_NEXT(characters, baseCharacterLength, length, baseCharacter); GlyphData baseCharacterGlyphData = glyphDataForCharacter(baseCharacter, false, variant); if (!baseCharacterGlyphData.glyph) return 0; if (length == baseCharacterLength) return baseCharacterGlyphData.fontData; bool triedBaseCharacterFontData = false; unsigned i = 0; for (const FontData* fontData = fontDataAt(0); fontData; fontData = fontDataAt(++i)) { const SimpleFontData* simpleFontData = fontData->fontDataForCharacter(baseCharacter); if (variant == NormalVariant) { if (simpleFontData->platformData().orientation() == Vertical) { if (isCJKIdeographOrSymbol(baseCharacter) && !simpleFontData->hasVerticalGlyphs()) { variant = BrokenIdeographVariant; simpleFontData = simpleFontData->brokenIdeographFontData().get(); } else if (m_fontDescription.nonCJKGlyphOrientation() == NonCJKGlyphOrientationVerticalRight) { SimpleFontData* verticalRightFontData = simpleFontData->verticalRightOrientationFontData().get(); Glyph verticalRightGlyph = verticalRightFontData->glyphForCharacter(baseCharacter); if (verticalRightGlyph == baseCharacterGlyphData.glyph) simpleFontData = verticalRightFontData; } else { SimpleFontData* uprightFontData = simpleFontData->uprightOrientationFontData().get(); Glyph uprightGlyph = uprightFontData->glyphForCharacter(baseCharacter); if (uprightGlyph != baseCharacterGlyphData.glyph) simpleFontData = uprightFontData; } } } else { if (const SimpleFontData* variantFontData = simpleFontData->variantFontData(m_fontDescription, variant).get()) simpleFontData = variantFontData; } if (simpleFontData == baseCharacterGlyphData.fontData) triedBaseCharacterFontData = true; if (simpleFontData->canRenderCombiningCharacterSequence(characters, length)) return simpleFontData; } if (!triedBaseCharacterFontData && baseCharacterGlyphData.fontData && baseCharacterGlyphData.fontData->canRenderCombiningCharacterSequence(characters, length)) return baseCharacterGlyphData.fontData; return SimpleFontData::systemFallback(); }
void RemoteFontFaceSource::pruneTable() { if (m_fontDataTable.isEmpty()) return; for (FontDataTable::iterator it = m_fontDataTable.begin(); it != m_fontDataTable.end(); ++it) { SimpleFontData* fontData = it->value.get(); if (fontData && fontData->customFontData()) fontData->customFontData()->clearFontFaceSource(); } m_fontDataTable.clear(); }
PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData(const FontDescription& fontDescription) { // 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 nullptr; } RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(this, m_font->exceedsFontLoadWaitLimit() ? CSSCustomFontData::VisibleFallback : CSSCustomFontData::InvisibleFallback); return SimpleFontData::create(temporaryFont->platformData(), cssFontData); }
const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) { SimpleFontData* fontData = 0; fontData = getCachedFontData(font.fontDescription(), font.family().family()); if (!fontData->containsCharacters(characters, length)) fontData = getSimilarFontPlatformData(font); if (!fontData->containsCharacters(characters, length)) fontData = getLastResortFallbackFont(font.fontDescription()); ASSERT(fontData); return fontData; }
float SimpleShaper::adjustSpacing(float width, const CharacterData& charData, const SimpleFontData& fontData, GlyphBuffer* glyphBuffer) { // Account for letter-spacing. if (width) width += m_font->fontDescription().letterSpacing(); bool treatAsSpace = Character::treatAsSpace(charData.character); if (treatAsSpace) { // Distribute the run's total expansion evenly over all expansion opportunities in the run. if (m_expansion) { if (!treatAsSpace && !m_isAfterExpansion) { // Take the expansion opportunity before this ideograph. m_expansion -= m_expansionPerOpportunity; float expansionAtThisOpportunity = m_expansionPerOpportunity; m_runWidthSoFar += expansionAtThisOpportunity; if (glyphBuffer) { if (glyphBuffer->isEmpty()) { if (m_forTextEmphasis) glyphBuffer->add(fontData.zeroWidthSpaceGlyph(), &fontData, m_expansionPerOpportunity); else glyphBuffer->add(fontData.spaceGlyph(), &fontData, expansionAtThisOpportunity); } else { glyphBuffer->expandLastAdvance(expansionAtThisOpportunity); } } } if (m_run.allowsTrailingExpansion() || (m_run.ltr() && charData.characterOffset + charData.clusterLength < static_cast<size_t>(m_run.length())) || (m_run.rtl() && charData.characterOffset)) { m_expansion -= m_expansionPerOpportunity; width += m_expansionPerOpportunity; m_isAfterExpansion = true; } } else { m_isAfterExpansion = false; } // Account for word spacing. // We apply additional space between "words" by adding width to the space character. if (treatAsSpace && (charData.character != '\t' || !m_run.allowTabs()) && (charData.characterOffset || charData.character == noBreakSpace) && m_font->fontDescription().wordSpacing()) { width += m_font->fontDescription().wordSpacing(); } } else { m_isAfterExpansion = false; } return width; }
static bool canUseForText(const CharacterType* text, unsigned length, const SimpleFontData& fontData) { // FIXME: <textarea maxlength=0> generates empty text node. if (!length) return false; for (unsigned i = 0; i < length; ++i) { UChar character = text[i]; if (character == ' ') continue; // These would be easy to support. if (character == noBreakSpace) return false; if (character == softHyphen) return false; UCharDirection direction = u_charDirection(character); if (direction == U_RIGHT_TO_LEFT || direction == U_RIGHT_TO_LEFT_ARABIC || direction == U_RIGHT_TO_LEFT_EMBEDDING || direction == U_RIGHT_TO_LEFT_OVERRIDE || direction == U_LEFT_TO_RIGHT_EMBEDDING || direction == U_LEFT_TO_RIGHT_OVERRIDE || direction == U_POP_DIRECTIONAL_FORMAT || direction == U_BOUNDARY_NEUTRAL) return false; if (!fontData.glyphForCharacter(character)) return false; } return true; }
const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) { FcResult fresult; // Avoid copying FontPlatformData. FontPlatformData* prim = const_cast<FontPlatformData*>(&font.primaryFont()->m_font); if (!prim->m_fallbacks) prim->m_fallbacks = FcFontSort(NULL, prim->m_pattern, FcTrue, NULL, &fresult); FcFontSet* fs = prim->m_fallbacks; FT_Library library = FontPlatformData::m_library; FcChar8* fc_filename; char* filename; int id; FT_Face face; for (int i = 0; i < fs->nfont; i++) { FcPattern* fin = FcFontRenderPrepare(0, prim->m_pattern, fs->fonts[i]); if (FcPatternGetString(fin, FC_FILE, 0, &fc_filename) != FcResultMatch) continue; filename = (char *) fc_filename; // Use C cast as FcChar is a fontconfig type. if (FcPatternGetInteger(fin, FC_INDEX, 0, &id) != FcResultMatch) continue; if (FT_Error error = FT_New_Face(library, filename, id, &face)) continue; // FIXME: is it really necessary ? FT_Set_Pixel_Sizes(face, 0, static_cast<uint> (font.fontDescription().computedSize())); FontPlatformData alternateFont(face, font.fontDescription().computedPixelSize(), false, false); // FIXME: FT_Done_Face(face); we should clean the face correctly the FT_Face but we can't do that here... alternateFont.m_pattern = fin; SimpleFontData* sfd = getCachedFontData(&alternateFont); if (sfd->containsCharacters(characters, length)) return sfd; } return 0; }
std::unique_ptr<GlyphToPathTranslator> SVGTextRunRenderingContext::createGlyphToPathTranslator(const SimpleFontData& fontData, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const { SVGFontElement* fontElement = 0; SVGFontFaceElement* fontFaceElement = 0; const SVGFontData* svgFontData = svgFontAndFontFaceElementForFontData(&fontData, fontFaceElement, fontElement); if (!fontElement || !fontFaceElement) return std::make_unique<DummyGlyphToPathTranslator>(); auto& elementRenderer = renderer().isRenderElement() ? toRenderElement(renderer()) : *renderer().parent(); RenderStyle& style = elementRenderer.style(); bool isVerticalText = style.svgStyle().isVerticalWritingMode(); float scale = scaleEmToUnits(fontData.platformData().size(), fontFaceElement->unitsPerEm()); return std::make_unique<SVGGlyphToPathTranslator>(glyphBuffer, point, *svgFontData, *fontElement, from, numGlyphs, scale, isVerticalText); }
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() + 1) << 6 | fontDescription.widthVariant() << 4 | (fontDescription.textOrientation() == TextOrientationUpright ? 8 : 0) | (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_hasExternalSVGFont) { // 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.textOrientation(), fontDescription.widthVariant(), 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.get())), 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) SVGFontFaceElement* CSSFontFaceSource::svgFontFaceElement() const { return m_svgFontFaceElement.get(); } void CSSFontFaceSource::setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement> element) { m_svgFontFaceElement = element; } bool CSSFontFaceSource::isSVGFontFaceSource() const { return m_svgFontFaceElement || m_hasExternalSVGFont; } #endif }
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 // 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); 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_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 now. Do it on a zero-delay timer rather than synchronously, because we may be in // the middle of layout, and the loader may invoke arbitrary delegate or event handler code. m_fontSelector = fontSelector; if (!m_loadStartTimer.isActive()) m_loadStartTimer.startOneShot(0); // 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)); } SimpleFontData* fontDataRawPtr = fontData.leakPtr(); m_fontDataTable.set(hashKey, fontDataRawPtr); return fontDataRawPtr; } void CSSFontFaceSource::startLoadingTimerFired(Timer<WebCore::CSSFontFaceSource>*) { ASSERT(m_font); ASSERT(m_fontSelector); if (CachedResourceLoader* cachedResourceLoader = m_fontSelector->cachedResourceLoader()) m_font->beginLoadIfNeeded(cachedResourceLoader); m_fontSelector = nullptr; }
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, 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 != notFound) fragmentIdentifier = m_string.string().substring(start + 1); m_externalSVGFontElement = m_font->getSVGFontById(fragmentIdentifier); } if (!m_externalSVGFontElement) return 0; if (auto fontFaceElement = Traversal<SVGFontFaceElement>::firstChild(m_externalSVGFontElement.get())) { 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.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. }
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); } return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable. }