Diff
Modified: trunk/LayoutTests/ChangeLog (177489 => 177490)
--- trunk/LayoutTests/ChangeLog 2014-12-18 09:55:48 UTC (rev 177489)
+++ trunk/LayoutTests/ChangeLog 2014-12-18 12:16:12 UTC (rev 177490)
@@ -1,3 +1,17 @@
+2014-12-18 Antti Koivisto <[email protected]>
+
+ Stop returning GlyphPage from various Font functions
+ https://bugs.webkit.org/show_bug.cgi?id=139627
+
+ Reviewed by Darin Adler.
+
+ These are progressions. We now correctly draw the specified missing glyph.
+
+ * platform/mac/svg/W3C-SVG-1.1/fonts-glyph-03-t-expected.png:
+ * platform/mac/svg/W3C-SVG-1.1/fonts-glyph-03-t-expected.txt:
+ * platform/mac/svg/custom/glyph-selection-lang-attribute-expected.png:
+ * svg/custom/glyph-selection-lang-attribute-expected.txt:
+
2014-12-17 Daniel Bates <[email protected]>
[iOS] More test gardening
Modified: trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-glyph-03-t-expected.png
(Binary files differ)
Modified: trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-glyph-03-t-expected.txt (177489 => 177490)
--- trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-glyph-03-t-expected.txt 2014-12-18 09:55:48 UTC (rev 177489)
+++ trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-glyph-03-t-expected.txt 2014-12-18 12:16:12 UTC (rev 177490)
@@ -2,9 +2,9 @@
RenderView at (0,0) size 480x360
layer at (0,0) size 480x360
RenderSVGRoot {svg} at (0,0) size 480x360
- RenderSVGContainer {g} at (50,10) size 28x260
+ RenderSVGContainer {g} at (50,10) size 25x260
RenderSVGHiddenContainer {defs} at (0,0) size 0x0
- RenderSVGContainer {g} at (50,10) size 28x260
+ RenderSVGContainer {g} at (50,10) size 25x260
RenderSVGText {text} at (50,10) size 25x50 contains 1 chunk(s)
RenderSVGInlineText {#text} at (0,0) size 25x50
chunk 1 text run 1 at (50.00,50.00) startOffset 0 endOffset 1 width 25.00: "a"
@@ -14,9 +14,9 @@
RenderSVGText {text} at (50,150) size 25x50 contains 1 chunk(s)
RenderSVGInlineText {#text} at (0,0) size 25x50
chunk 1 text run 1 at (50.00,190.00) startOffset 0 endOffset 1 width 25.00: "a"
- RenderSVGText {text} at (50,220) size 28x50 contains 1 chunk(s)
- RenderSVGInlineText {#text} at (0,0) size 28x50
- chunk 1 text run 1 at (50.00,260.00) startOffset 0 endOffset 1 width 28.00: "a"
+ RenderSVGText {text} at (50,220) size 25x50 contains 1 chunk(s)
+ RenderSVGInlineText {#text} at (0,0) size 25x50
+ chunk 1 text run 1 at (50.00,260.00) startOffset 0 endOffset 1 width 25.00: "a"
RenderSVGText {text} at (10,304) size 284x46 contains 1 chunk(s)
RenderSVGInlineText {#text} at (0,0) size 284x46
chunk 1 text run 1 at (10.00,340.00) startOffset 0 endOffset 17 width 284.00: "$Revision: 1.10 $"
Modified: trunk/LayoutTests/platform/mac/svg/custom/glyph-selection-lang-attribute-expected.png
(Binary files differ)
Modified: trunk/LayoutTests/svg/custom/glyph-selection-lang-attribute-expected.txt (177489 => 177490)
--- trunk/LayoutTests/svg/custom/glyph-selection-lang-attribute-expected.txt 2014-12-18 09:55:48 UTC (rev 177489)
+++ trunk/LayoutTests/svg/custom/glyph-selection-lang-attribute-expected.txt 2014-12-18 12:16:12 UTC (rev 177490)
@@ -3,22 +3,22 @@
layer at (0,0) size 800x600
RenderSVGRoot {svg} at (0,0) size 800x600
RenderSVGHiddenContainer {defs} at (0,0) size 0x0
- RenderSVGContainer {g} at (83,16) size 47x551
+ RenderSVGContainer {g} at (83,16) size 42x551
RenderSVGText {text} at (50,10) size 25x50 contains 1 chunk(s)
RenderSVGInlineText {#text} at (0,0) size 25x50
chunk 1 text run 1 at (50.00,50.00) startOffset 0 endOffset 1 width 24.90: "a"
RenderSVGText {text} at (50,80) size 25x50 contains 1 chunk(s)
RenderSVGInlineText {#text} at (0,0) size 25x50
chunk 1 text run 1 at (50.00,120.00) startOffset 0 endOffset 1 width 24.90: "a"
- RenderSVGText {text} at (50,150) size 28x50 contains 1 chunk(s)
- RenderSVGInlineText {#text} at (0,0) size 28x50
- chunk 1 text run 1 at (50.00,190.00) startOffset 0 endOffset 1 width 27.60: "a"
- RenderSVGText {text} at (50,220) size 28x50 contains 1 chunk(s)
- RenderSVGInlineText {#text} at (0,0) size 28x50
- chunk 1 text run 1 at (50.00,260.00) startOffset 0 endOffset 1 width 27.60: "a"
- RenderSVGText {text} at (50,290) size 28x50 contains 1 chunk(s)
- RenderSVGInlineText {#text} at (0,0) size 28x50
- chunk 1 text run 1 at (50.00,330.00) startOffset 0 endOffset 1 width 27.60: "a"
+ RenderSVGText {text} at (50,150) size 25x50 contains 1 chunk(s)
+ RenderSVGInlineText {#text} at (0,0) size 25x50
+ chunk 1 text run 1 at (50.00,190.00) startOffset 0 endOffset 1 width 24.90: "a"
+ RenderSVGText {text} at (50,220) size 25x50 contains 1 chunk(s)
+ RenderSVGInlineText {#text} at (0,0) size 25x50
+ chunk 1 text run 1 at (50.00,260.00) startOffset 0 endOffset 1 width 24.90: "a"
+ RenderSVGText {text} at (50,290) size 25x50 contains 1 chunk(s)
+ RenderSVGInlineText {#text} at (0,0) size 25x50
+ chunk 1 text run 1 at (50.00,330.00) startOffset 0 endOffset 1 width 24.90: "a"
RenderSVGContainer {g} at (250,16) size 42x551 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,0.00)}]
RenderSVGText {text} at (50,10) size 25x50 contains 1 chunk(s)
RenderSVGInlineText {#text} at (0,0) size 25x50
Modified: trunk/Source/WebCore/ChangeLog (177489 => 177490)
--- trunk/Source/WebCore/ChangeLog 2014-12-18 09:55:48 UTC (rev 177489)
+++ trunk/Source/WebCore/ChangeLog 2014-12-18 12:16:12 UTC (rev 177490)
@@ -1,3 +1,46 @@
+2014-12-18 Antti Koivisto <[email protected]>
+
+ Stop returning GlyphPage from various Font functions
+ https://bugs.webkit.org/show_bug.cgi?id=139627
+
+ Reviewed by Darin Adler.
+
+ Make all
+
+ std::pair<GlyphData, GlyphPage*> glyphDataAndPage*(...)
+
+ style functions to just return GlyphData only. The GlyphPage value was only used for an obscure SVG fallback case.
+
+ * platform/graphics/Font.h:
+ (WebCore::Font::glyphDataForCharacter):
+ (WebCore::Font::glyphDataAndPageForCharacter): Deleted.
+ * platform/graphics/FontGlyphs.cpp:
+ (WebCore::glyphDataForCJKCharacterWithoutSyntheticItalic):
+ (WebCore::glyphDataForNonCJKCharacterWithGlyphOrientation):
+ (WebCore::FontGlyphs::glyphDataForSystemFallback):
+ (WebCore::FontGlyphs::glyphDataForVariant):
+ (WebCore::FontGlyphs::glyphDataForCharacter):
+ (WebCore::glyphDataAndPageForCJKCharacterWithoutSyntheticItalic): Deleted.
+ (WebCore::glyphDataAndPageForNonCJKCharacterWithGlyphOrientation): Deleted.
+ (WebCore::FontGlyphs::glyphDataAndPageForSystemFallback): Deleted.
+ (WebCore::FontGlyphs::glyphDataAndPageForVariant): Deleted.
+ (WebCore::FontGlyphs::glyphDataAndPageForCharacter): Deleted.
+ * platform/graphics/FontGlyphs.h:
+ (WebCore::FontGlyphs::GlyphPagesStateSaver::GlyphPagesStateSaver): Deleted.
+ (WebCore::FontGlyphs::GlyphPagesStateSaver::~GlyphPagesStateSaver): Deleted.
+
+ No longer needed.
+
+ * rendering/svg/SVGTextRunRenderingContext.cpp:
+ (WebCore::SVGTextRunRenderingContext::glyphDataForCharacter):
+
+ Simplify by not trying to resolve fallbacks in case context sensitive (based on lang attribute etc)
+ glyph selection fails. Instead just fall back to a default font. This behavior is not specified
+ anywhere as far as I can see. (normal non-context sensitive fallbacks will still work fine).
+ This removes the need to hackishly mutate glyph pages.
+
+ Also fix a bug where we didn't use the specified missing glyph when context sensitive selection failed.
+
2014-12-18 Chris Dumez <[email protected]>
Move 'list-style-image' CSS property to the new StyleBuilder
Modified: trunk/Source/WebCore/platform/graphics/Font.h (177489 => 177490)
--- trunk/Source/WebCore/platform/graphics/Font.h 2014-12-18 09:55:48 UTC (rev 177489)
+++ trunk/Source/WebCore/platform/graphics/Font.h 2014-12-18 12:16:12 UTC (rev 177490)
@@ -187,15 +187,11 @@
const FontData* fontDataAt(unsigned) const;
GlyphData glyphDataForCharacter(UChar32 c, bool mirror, FontDataVariant variant = AutoVariant) const
{
- return glyphDataAndPageForCharacter(c, mirror, variant).first;
+ return m_glyphs->glyphDataForCharacter(m_fontDescription, c, mirror, variant);
}
#if PLATFORM(COCOA)
const SimpleFontData* fontDataForCombiningCharacterSequence(const UChar*, size_t length, FontDataVariant) const;
#endif
- std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(UChar32 c, bool mirror, FontDataVariant variant) const
- {
- return m_glyphs->glyphDataAndPageForCharacter(m_fontDescription, c, mirror, variant);
- }
bool primaryFontHasGlyphForCharacter(UChar32) const;
static bool isCJKIdeograph(UChar32);
Modified: trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp (177489 => 177490)
--- trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp 2014-12-18 09:55:48 UTC (rev 177489)
+++ trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp 2014-12-18 12:16:12 UTC (rev 177490)
@@ -209,7 +209,8 @@
return false;
}
-static inline std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCJKCharacterWithoutSyntheticItalic(UChar32 character, GlyphData& data, GlyphPage* page, unsigned pageNumber)
+#if PLATFORM(COCOA)
+static GlyphData glyphDataForCJKCharacterWithoutSyntheticItalic(UChar32 character, GlyphData& data, unsigned pageNumber)
{
RefPtr<SimpleFontData> nonItalicFontData = data.fontData->nonSyntheticItalicFontData();
GlyphPageTreeNode* nonItalicNode = GlyphPageTreeNode::getRootChild(nonItalicFontData.get(), pageNumber);
@@ -217,12 +218,13 @@
if (nonItalicPage) {
GlyphData nonItalicData = nonItalicPage->glyphDataForCharacter(character);
if (nonItalicData.fontData)
- return std::make_pair(nonItalicData, nonItalicPage);
+ return nonItalicData;
}
- return std::make_pair(data, page);
+ return data;
}
+#endif
-static inline std::pair<GlyphData, GlyphPage*> glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(UChar32 character, NonCJKGlyphOrientation orientation, GlyphData& data, GlyphPage* page, unsigned pageNumber)
+static GlyphData glyphDataForNonCJKCharacterWithGlyphOrientation(UChar32 character, NonCJKGlyphOrientation orientation, GlyphData& data, unsigned pageNumber)
{
if (orientation == NonCJKGlyphOrientationUpright || shouldIgnoreRotation(character)) {
RefPtr<SimpleFontData> uprightFontData = data.fontData->uprightOrientationFontData();
@@ -232,11 +234,11 @@
GlyphData uprightData = uprightPage->glyphDataForCharacter(character);
// If the glyphs are the same, then we know we can just use the horizontal glyph rotated vertically to be upright.
if (data.glyph == uprightData.glyph)
- return std::make_pair(data, page);
+ return data;
// The glyphs are distinct, meaning that the font has a vertical-right glyph baked into it. We can't use that
// glyph, so we fall back to the upright data and use the horizontal glyph.
if (uprightData.fontData)
- return std::make_pair(uprightData, uprightPage);
+ return uprightData;
}
} else if (orientation == NonCJKGlyphOrientationVerticalRight) {
RefPtr<SimpleFontData> verticalRightFontData = data.fontData->verticalRightOrientationFontData();
@@ -247,16 +249,16 @@
// If the glyphs are distinct, we will make the assumption that the font has a vertical-right glyph baked
// into it.
if (data.glyph != verticalRightData.glyph)
- return std::make_pair(data, page);
+ return data;
// The glyphs are identical, meaning that we should just use the horizontal glyph.
if (verticalRightData.fontData)
- return std::make_pair(verticalRightData, verticalRightPage);
+ return verticalRightData;
}
}
- return std::make_pair(data, page);
+ return data;
}
-std::pair<GlyphData, GlyphPage*> FontGlyphs::glyphDataAndPageForSystemFallback(UChar32 c, const FontDescription& description, FontDataVariant variant, unsigned pageNumber, GlyphPageTreeNode& node)
+GlyphData FontGlyphs::glyphDataForSystemFallback(UChar32 c, const FontDescription& description, FontDataVariant variant, unsigned pageNumber, GlyphPageTreeNode& node)
{
ASSERT(node.page());
ASSERT(node.isSystemFallback());
@@ -290,9 +292,9 @@
node.page()->setGlyphDataForCharacter(c, data.glyph, data.fontData);
data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node.level()));
if (!Font::isCJKIdeographOrSymbol(c) && data.fontData->platformData().orientation() != Horizontal && !data.fontData->isTextOrientationFallback())
- return glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, fallbackPage, pageNumber);
+ return glyphDataForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, pageNumber);
}
- return std::make_pair(data, node.page());
+ return data;
}
// Even system fallback can fail; use the missing glyph in that case.
@@ -302,10 +304,10 @@
node.page()->setGlyphDataForCharacter(c, data.glyph, data.fontData);
data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node.level()));
}
- return std::make_pair(data, node.page());
+ return data;
}
-std::pair<GlyphData, GlyphPage*> FontGlyphs::glyphDataAndPageForVariant(UChar32 c, const FontDescription& description, FontDataVariant variant, unsigned pageNumber, GlyphPageTreeNode*& node)
+GlyphData FontGlyphs::glyphDataForVariant(UChar32 c, const FontDescription& description, FontDataVariant variant, unsigned pageNumber, GlyphPageTreeNode*& node)
{
while (true) {
if (GlyphPage* page = node->page()) {
@@ -315,30 +317,30 @@
// But if it does, we will just render the capital letter big.
RefPtr<SimpleFontData> variantFontData = data.fontData->variantFontData(description, variant);
if (!variantFontData)
- return std::make_pair(data, page);
+ return data;
GlyphPageTreeNode* variantNode = GlyphPageTreeNode::getRootChild(variantFontData.get(), pageNumber);
GlyphPage* variantPage = variantNode->page();
if (variantPage) {
GlyphData data = ""
if (data.fontData)
- return std::make_pair(data, variantPage);
+ return data;
}
// Do not attempt system fallback off the variantFontData. This is the very unlikely case that
// a font has the lowercase character but the small caps font does not have its uppercase version.
- return std::make_pair(variantFontData->missingGlyphData(), page);
+ return variantFontData->missingGlyphData();
}
if (node->isSystemFallback())
- return glyphDataAndPageForSystemFallback(c, description, variant, pageNumber, *node);
+ return glyphDataForSystemFallback(c, description, variant, pageNumber, *node);
}
node = node->getChild(realizeFontDataAt(description, node->level()), pageNumber);
}
}
-std::pair<GlyphData, GlyphPage*> FontGlyphs::glyphDataAndPageForCharacter(const FontDescription& description, UChar32 c, bool mirror, FontDataVariant variant)
+GlyphData FontGlyphs::glyphDataForCharacter(const FontDescription& description, UChar32 c, bool mirror, FontDataVariant variant)
{
ASSERT(isMainThread());
@@ -364,7 +366,7 @@
node = GlyphPageTreeNode::getRootChild(realizeFontDataAt(description, 0), pageNumber);
if (variant != NormalVariant)
- return glyphDataAndPageForVariant(c, description, variant, pageNumber, node);
+ return glyphDataForVariant(c, description, variant, pageNumber, node);
while (true) {
if (GlyphPage* page = node->page()) {
@@ -372,24 +374,24 @@
if (data.fontData) {
if (data.fontData->platformData().orientation() == Vertical && !data.fontData->isTextOrientationFallback()) {
if (!Font::isCJKIdeographOrSymbol(c))
- return glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, page, pageNumber);
+ return glyphDataForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, pageNumber);
if (!data.fontData->hasVerticalGlyphs()) {
// Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs
// to make sure you get a square (even for broken glyphs like symbols used for punctuation).
- return glyphDataAndPageForVariant(c, description, BrokenIdeographVariant, pageNumber, node);
+ return glyphDataForVariant(c, description, BrokenIdeographVariant, pageNumber, node);
}
#if PLATFORM(COCOA)
if (data.fontData->platformData().syntheticOblique())
- return glyphDataAndPageForCJKCharacterWithoutSyntheticItalic(c, data, page, pageNumber);
+ return glyphDataForCJKCharacterWithoutSyntheticItalic(c, data, pageNumber);
#endif
}
- return std::make_pair(data, page);
+ return data;
}
if (node->isSystemFallback())
- return glyphDataAndPageForSystemFallback(c, description, variant, pageNumber, *node);
+ return glyphDataForSystemFallback(c, description, variant, pageNumber, *node);
}
node = node->getChild(realizeFontDataAt(description, node->level()), pageNumber);
Modified: trunk/Source/WebCore/platform/graphics/FontGlyphs.h (177489 => 177490)
--- trunk/Source/WebCore/platform/graphics/FontGlyphs.h 2014-12-18 09:55:48 UTC (rev 177489)
+++ trunk/Source/WebCore/platform/graphics/FontGlyphs.h 2014-12-18 12:16:12 UTC (rev 177490)
@@ -47,27 +47,6 @@
public:
typedef HashMap<int, GlyphPageTreeNode*, DefaultHash<int>::Hash> GlyphPages;
- class GlyphPagesStateSaver {
- public:
- GlyphPagesStateSaver(FontGlyphs& glyphs)
- : m_glyphs(glyphs)
- , m_pages(glyphs.m_pages)
- , m_pageZero(glyphs.m_pageZero)
- {
- }
-
- ~GlyphPagesStateSaver()
- {
- m_glyphs.m_pages = m_pages;
- m_glyphs.m_pageZero = m_pageZero;
- }
-
- private:
- FontGlyphs& m_glyphs;
- GlyphPages& m_pages;
- GlyphPageTreeNode* m_pageZero;
- };
-
static Ref<FontGlyphs> create(PassRefPtr<FontSelector> fontSelector) { return adoptRef(*new FontGlyphs(fontSelector)); }
static Ref<FontGlyphs> createForPlatformFont(const FontPlatformData& platformData) { return adoptRef(*new FontGlyphs(platformData)); }
@@ -75,7 +54,7 @@
bool isForPlatformFont() const { return m_isForPlatformFont; }
- std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(const FontDescription&, UChar32, bool mirror, FontDataVariant);
+ GlyphData glyphDataForCharacter(const FontDescription&, UChar32, bool mirror, FontDataVariant);
bool isFixedPitch(const FontDescription&);
void determinePitch(const FontDescription&);
@@ -98,8 +77,8 @@
FontGlyphs(PassRefPtr<FontSelector>);
FontGlyphs(const FontPlatformData&);
- std::pair<GlyphData, GlyphPage*> glyphDataAndPageForSystemFallback(UChar32, const FontDescription&, FontDataVariant, unsigned pageNumber, GlyphPageTreeNode&);
- std::pair<GlyphData, GlyphPage*> glyphDataAndPageForVariant(UChar32, const FontDescription&, FontDataVariant, unsigned pageNumber, GlyphPageTreeNode*&);
+ GlyphData glyphDataForSystemFallback(UChar32, const FontDescription&, FontDataVariant, unsigned pageNumber, GlyphPageTreeNode&);
+ GlyphData glyphDataForVariant(UChar32, const FontDescription&, FontDataVariant, unsigned pageNumber, GlyphPageTreeNode*&);
WEBCORE_EXPORT void releaseFontData();
Modified: trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp (177489 => 177490)
--- trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp 2014-12-18 09:55:48 UTC (rev 177489)
+++ trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp 2014-12-18 12:16:12 UTC (rev 177490)
@@ -295,8 +295,7 @@
const SimpleFontData* primaryFont = font.primaryFont();
ASSERT(primaryFont);
- std::pair<GlyphData, GlyphPage*> pair = font.glyphDataAndPageForCharacter(character, mirror, AutoVariant);
- GlyphData glyphData = pair.first;
+ GlyphData glyphData = font.glyphDataForCharacter(character, mirror, AutoVariant);
// Check if we have the missing glyph data, in which case we can just return.
GlyphData missingGlyphData = primaryFont->missingGlyphData();
@@ -305,14 +304,7 @@
return glyphData;
}
- // Save data from the font fallback list because we may modify it later. Do this before the
- // potential change to glyphData.fontData below.
- FontGlyphs* glyph = font.glyphs();
- ASSERT(glyph);
- FontGlyphs::GlyphPagesStateSaver glyphPagesSaver(*glyph);
-
// Characters enclosed by an <altGlyph> element, may not be registered in the GlyphPage.
- const SimpleFontData* originalFontData = glyphData.fontData;
if (glyphData.fontData && !glyphData.fontData->isSVGFont()) {
auto& elementRenderer = is<RenderElement>(renderer()) ? downcast<RenderElement>(renderer()) : *renderer().parent();
if (Element* parentRendererElement = elementRenderer.element()) {
@@ -322,42 +314,32 @@
}
const SimpleFontData* fontData = glyphData.fontData;
- if (fontData) {
- if (!fontData->isSVGFont())
- return glyphData;
+ if (!fontData || !fontData->isSVGFont())
+ return glyphData;
- SVGFontElement* fontElement = nullptr;
- SVGFontFaceElement* fontFaceElement = nullptr;
+ SVGFontElement* fontElement = nullptr;
+ SVGFontFaceElement* fontFaceElement = nullptr;
+ const SVGFontData* svgFontData = svgFontAndFontFaceElementForFontData(fontData, fontFaceElement, fontElement);
+ if (!svgFontData)
+ return glyphData;
- const SVGFontData* svgFontData = svgFontAndFontFaceElementForFontData(fontData, fontFaceElement, fontElement);
- if (!fontElement || !fontFaceElement)
- return glyphData;
+ // If we got here, we're dealing with a glyph defined in a SVG Font.
+ // The returned glyph by glyphDataForCharacter() is a glyph stored in the SVG Font glyph table.
+ // This doesn't necessarily mean the glyph is suitable for rendering/measuring in this context, its
+ // arabic-form/orientation/... may not match, we have to apply SVG Glyph selection to discover that.
+ if (svgFontData->applySVGGlyphSelection(iterator, glyphData, mirror, currentCharacter, advanceLength, normalizedSpacesStringCache))
+ return glyphData;
+ if (missingGlyphData.glyph)
+ return missingGlyphData;
- // If we got here, we're dealing with a glyph defined in a SVG Font.
- // The returned glyph by glyphDataAndPageForCharacter() is a glyph stored in the SVG Font glyph table.
- // This doesn't necessarily mean the glyph is suitable for rendering/measuring in this context, its
- // arabic-form/orientation/... may not match, we have to apply SVG Glyph selection to discover that.
- if (svgFontData->applySVGGlyphSelection(iterator, glyphData, mirror, currentCharacter, advanceLength, normalizedSpacesStringCache))
- return glyphData;
- }
+ // SVG font context sensitive selection failed and there is no defined missing glyph. Drop down to a default font.
+ // The behavior does not seem to be specified. For simplicity we don't try to resolve font fallbacks context-sensitively.
+ FontDescription fallbackDescription = font.fontDescription();
+ fallbackDescription.setFamilies(Vector<AtomicString> { sansSerifFamily });
+ Font fallbackFont(fallbackDescription, font.letterSpacing(), font.wordSpacing());
+ fallbackFont.update(font.fontSelector());
- GlyphPage* page = pair.second;
- ASSERT(page);
-
- // No suitable glyph found that is compatible with the requirments (same language, arabic-form, orientation etc.)
- // Even though our GlyphPage contains an entry for eg. glyph "a", it's not compatible. So we have to temporarily
- // remove the glyph data information from the GlyphPage, and retry the lookup, which handles font fallbacks correctly.
- page->setGlyphDataForCharacter(character, 0, nullptr);
-
- // Assure that the font fallback glyph selection worked, aka. the fallbackGlyphData font data is not the same as before.
- GlyphData fallbackGlyphData = font.glyphDataForCharacter(character, mirror);
- ASSERT(fallbackGlyphData.fontData != fontData);
-
- // Restore original state of the SVG Font glyph table and the current font fallback list,
- // to assure the next lookup of the same glyph won't immediately return the fallback glyph.
- page->setGlyphDataForCharacter(character, glyphData.glyph, originalFontData);
- ASSERT(fallbackGlyphData.fontData);
- return fallbackGlyphData;
+ return fallbackFont.glyphDataForCharacter(character, mirror, AutoVariant);
}
}