Changeset 177490 in webkit


Ignore:
Timestamp:
Dec 18, 2014 4:16:12 AM (9 years ago)
Author:
Antti Koivisto
Message:

Stop returning GlyphPage from various Font functions
https://bugs.webkit.org/show_bug.cgi?id=139627

Reviewed by Darin Adler.

Source/WebCore:

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.

LayoutTests:

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:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r177462 r177490  
     12014-12-18  Antti Koivisto  <antti@apple.com>
     2
     3        Stop returning GlyphPage from various Font functions
     4        https://bugs.webkit.org/show_bug.cgi?id=139627
     5
     6        Reviewed by Darin Adler.
     7
     8        These are progressions. We now correctly draw the specified missing glyph.
     9
     10        * platform/mac/svg/W3C-SVG-1.1/fonts-glyph-03-t-expected.png:
     11        * platform/mac/svg/W3C-SVG-1.1/fonts-glyph-03-t-expected.txt:
     12        * platform/mac/svg/custom/glyph-selection-lang-attribute-expected.png:
     13        * svg/custom/glyph-selection-lang-attribute-expected.txt:
     14
    1152014-12-17  Daniel Bates  <dabates@apple.com>
    216
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-glyph-03-t-expected.txt

    r103407 r177490  
    33layer at (0,0) size 480x360
    44  RenderSVGRoot {svg} at (0,0) size 480x360
    5     RenderSVGContainer {g} at (50,10) size 28x260
     5    RenderSVGContainer {g} at (50,10) size 25x260
    66      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    7       RenderSVGContainer {g} at (50,10) size 28x260
     7      RenderSVGContainer {g} at (50,10) size 25x260
    88        RenderSVGText {text} at (50,10) size 25x50 contains 1 chunk(s)
    99          RenderSVGInlineText {#text} at (0,0) size 25x50
     
    1515          RenderSVGInlineText {#text} at (0,0) size 25x50
    1616            chunk 1 text run 1 at (50.00,190.00) startOffset 0 endOffset 1 width 25.00: "a"
    17         RenderSVGText {text} at (50,220) size 28x50 contains 1 chunk(s)
    18           RenderSVGInlineText {#text} at (0,0) size 28x50
    19             chunk 1 text run 1 at (50.00,260.00) startOffset 0 endOffset 1 width 28.00: "a"
     17        RenderSVGText {text} at (50,220) size 25x50 contains 1 chunk(s)
     18          RenderSVGInlineText {#text} at (0,0) size 25x50
     19            chunk 1 text run 1 at (50.00,260.00) startOffset 0 endOffset 1 width 25.00: "a"
    2020    RenderSVGText {text} at (10,304) size 284x46 contains 1 chunk(s)
    2121      RenderSVGInlineText {#text} at (0,0) size 284x46
  • trunk/LayoutTests/svg/custom/glyph-selection-lang-attribute-expected.txt

    r149088 r177490  
    44  RenderSVGRoot {svg} at (0,0) size 800x600
    55    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    6     RenderSVGContainer {g} at (83,16) size 47x551
     6    RenderSVGContainer {g} at (83,16) size 42x551
    77      RenderSVGText {text} at (50,10) size 25x50 contains 1 chunk(s)
    88        RenderSVGInlineText {#text} at (0,0) size 25x50
     
    1111        RenderSVGInlineText {#text} at (0,0) size 25x50
    1212          chunk 1 text run 1 at (50.00,120.00) startOffset 0 endOffset 1 width 24.90: "a"
    13       RenderSVGText {text} at (50,150) size 28x50 contains 1 chunk(s)
    14         RenderSVGInlineText {#text} at (0,0) size 28x50
    15           chunk 1 text run 1 at (50.00,190.00) startOffset 0 endOffset 1 width 27.60: "a"
    16       RenderSVGText {text} at (50,220) size 28x50 contains 1 chunk(s)
    17         RenderSVGInlineText {#text} at (0,0) size 28x50
    18           chunk 1 text run 1 at (50.00,260.00) startOffset 0 endOffset 1 width 27.60: "a"
    19       RenderSVGText {text} at (50,290) size 28x50 contains 1 chunk(s)
    20         RenderSVGInlineText {#text} at (0,0) size 28x50
    21           chunk 1 text run 1 at (50.00,330.00) startOffset 0 endOffset 1 width 27.60: "a"
     13      RenderSVGText {text} at (50,150) size 25x50 contains 1 chunk(s)
     14        RenderSVGInlineText {#text} at (0,0) size 25x50
     15          chunk 1 text run 1 at (50.00,190.00) startOffset 0 endOffset 1 width 24.90: "a"
     16      RenderSVGText {text} at (50,220) size 25x50 contains 1 chunk(s)
     17        RenderSVGInlineText {#text} at (0,0) size 25x50
     18          chunk 1 text run 1 at (50.00,260.00) startOffset 0 endOffset 1 width 24.90: "a"
     19      RenderSVGText {text} at (50,290) size 25x50 contains 1 chunk(s)
     20        RenderSVGInlineText {#text} at (0,0) size 25x50
     21          chunk 1 text run 1 at (50.00,330.00) startOffset 0 endOffset 1 width 24.90: "a"
    2222    RenderSVGContainer {g} at (250,16) size 42x551 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,0.00)}]
    2323      RenderSVGText {text} at (50,10) size 25x50 contains 1 chunk(s)
  • trunk/Source/WebCore/ChangeLog

    r177489 r177490  
     12014-12-18  Antti Koivisto  <antti@apple.com>
     2
     3        Stop returning GlyphPage from various Font functions
     4        https://bugs.webkit.org/show_bug.cgi?id=139627
     5
     6        Reviewed by Darin Adler.
     7
     8        Make all
     9
     10            std::pair<GlyphData, GlyphPage*> glyphDataAndPage*(...)
     11
     12        style functions to just return GlyphData only. The GlyphPage value was only used for an obscure SVG fallback case.
     13
     14        * platform/graphics/Font.h:
     15        (WebCore::Font::glyphDataForCharacter):
     16        (WebCore::Font::glyphDataAndPageForCharacter): Deleted.
     17        * platform/graphics/FontGlyphs.cpp:
     18        (WebCore::glyphDataForCJKCharacterWithoutSyntheticItalic):
     19        (WebCore::glyphDataForNonCJKCharacterWithGlyphOrientation):
     20        (WebCore::FontGlyphs::glyphDataForSystemFallback):
     21        (WebCore::FontGlyphs::glyphDataForVariant):
     22        (WebCore::FontGlyphs::glyphDataForCharacter):
     23        (WebCore::glyphDataAndPageForCJKCharacterWithoutSyntheticItalic): Deleted.
     24        (WebCore::glyphDataAndPageForNonCJKCharacterWithGlyphOrientation): Deleted.
     25        (WebCore::FontGlyphs::glyphDataAndPageForSystemFallback): Deleted.
     26        (WebCore::FontGlyphs::glyphDataAndPageForVariant): Deleted.
     27        (WebCore::FontGlyphs::glyphDataAndPageForCharacter): Deleted.
     28        * platform/graphics/FontGlyphs.h:
     29        (WebCore::FontGlyphs::GlyphPagesStateSaver::GlyphPagesStateSaver): Deleted.
     30        (WebCore::FontGlyphs::GlyphPagesStateSaver::~GlyphPagesStateSaver): Deleted.
     31
     32            No longer needed.
     33
     34        * rendering/svg/SVGTextRunRenderingContext.cpp:
     35        (WebCore::SVGTextRunRenderingContext::glyphDataForCharacter):
     36
     37            Simplify by not trying to resolve fallbacks in case context sensitive (based on lang attribute etc)
     38            glyph selection fails. Instead just fall back to a default font. This behavior is not specified
     39            anywhere as far as I can see. (normal non-context sensitive fallbacks will still work fine).
     40            This removes the need to hackishly mutate glyph pages.
     41
     42            Also fix a bug where we didn't use the specified missing glyph when context sensitive selection failed.
     43
    1442014-12-18  Chris Dumez  <cdumez@apple.com>
    245
  • trunk/Source/WebCore/platform/graphics/Font.h

    r174489 r177490  
    188188    GlyphData glyphDataForCharacter(UChar32 c, bool mirror, FontDataVariant variant = AutoVariant) const
    189189    {
    190         return glyphDataAndPageForCharacter(c, mirror, variant).first;
     190        return m_glyphs->glyphDataForCharacter(m_fontDescription, c, mirror, variant);
    191191    }
    192192#if PLATFORM(COCOA)
    193193    const SimpleFontData* fontDataForCombiningCharacterSequence(const UChar*, size_t length, FontDataVariant) const;
    194194#endif
    195     std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(UChar32 c, bool mirror, FontDataVariant variant) const
    196     {
    197         return m_glyphs->glyphDataAndPageForCharacter(m_fontDescription, c, mirror, variant);
    198     }
    199195    bool primaryFontHasGlyphForCharacter(UChar32) const;
    200196
  • trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp

    r177229 r177490  
    210210}
    211211
    212 static inline std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCJKCharacterWithoutSyntheticItalic(UChar32 character, GlyphData& data, GlyphPage* page, unsigned pageNumber)
     212#if PLATFORM(COCOA)
     213static GlyphData glyphDataForCJKCharacterWithoutSyntheticItalic(UChar32 character, GlyphData& data, unsigned pageNumber)
    213214{
    214215    RefPtr<SimpleFontData> nonItalicFontData = data.fontData->nonSyntheticItalicFontData();
     
    218219        GlyphData nonItalicData = nonItalicPage->glyphDataForCharacter(character);
    219220        if (nonItalicData.fontData)
    220             return std::make_pair(nonItalicData, nonItalicPage);
    221     }
    222     return std::make_pair(data, page);
    223 }
     221            return nonItalicData;
     222    }
     223    return data;
     224}
     225#endif
    224226   
    225 static inline std::pair<GlyphData, GlyphPage*> glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(UChar32 character, NonCJKGlyphOrientation orientation, GlyphData& data, GlyphPage* page, unsigned pageNumber)
     227static GlyphData glyphDataForNonCJKCharacterWithGlyphOrientation(UChar32 character, NonCJKGlyphOrientation orientation, GlyphData& data, unsigned pageNumber)
    226228{
    227229    if (orientation == NonCJKGlyphOrientationUpright || shouldIgnoreRotation(character)) {
     
    233235            // If the glyphs are the same, then we know we can just use the horizontal glyph rotated vertically to be upright.
    234236            if (data.glyph == uprightData.glyph)
    235                 return std::make_pair(data, page);
     237                return data;
    236238            // The glyphs are distinct, meaning that the font has a vertical-right glyph baked into it. We can't use that
    237239            // glyph, so we fall back to the upright data and use the horizontal glyph.
    238240            if (uprightData.fontData)
    239                 return std::make_pair(uprightData, uprightPage);
     241                return uprightData;
    240242        }
    241243    } else if (orientation == NonCJKGlyphOrientationVerticalRight) {
     
    248250            // into it.
    249251            if (data.glyph != verticalRightData.glyph)
    250                 return std::make_pair(data, page);
     252                return data;
    251253            // The glyphs are identical, meaning that we should just use the horizontal glyph.
    252254            if (verticalRightData.fontData)
    253                 return std::make_pair(verticalRightData, verticalRightPage);
     255                return verticalRightData;
    254256        }
    255257    }
    256     return std::make_pair(data, page);
    257 }
    258 
    259 std::pair<GlyphData, GlyphPage*> FontGlyphs::glyphDataAndPageForSystemFallback(UChar32 c, const FontDescription& description, FontDataVariant variant, unsigned pageNumber, GlyphPageTreeNode& node)
     258    return data;
     259}
     260
     261GlyphData FontGlyphs::glyphDataForSystemFallback(UChar32 c, const FontDescription& description, FontDataVariant variant, unsigned pageNumber, GlyphPageTreeNode& node)
    260262{
    261263    ASSERT(node.page());
     
    291293            data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node.level()));
    292294            if (!Font::isCJKIdeographOrSymbol(c) && data.fontData->platformData().orientation() != Horizontal && !data.fontData->isTextOrientationFallback())
    293                 return glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, fallbackPage, pageNumber);
     295                return glyphDataForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, pageNumber);
    294296        }
    295         return std::make_pair(data, node.page());
     297        return data;
    296298    }
    297299
     
    303305        data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node.level()));
    304306    }
    305     return std::make_pair(data, node.page());
    306 }
    307 
    308 std::pair<GlyphData, GlyphPage*> FontGlyphs::glyphDataAndPageForVariant(UChar32 c, const FontDescription& description, FontDataVariant variant, unsigned pageNumber, GlyphPageTreeNode*& node)
     307    return data;
     308}
     309
     310GlyphData FontGlyphs::glyphDataForVariant(UChar32 c, const FontDescription& description, FontDataVariant variant, unsigned pageNumber, GlyphPageTreeNode*& node)
    309311{
    310312    while (true) {
     
    316318                RefPtr<SimpleFontData> variantFontData = data.fontData->variantFontData(description, variant);
    317319                if (!variantFontData)
    318                     return std::make_pair(data, page);
     320                    return data;
    319321
    320322                GlyphPageTreeNode* variantNode = GlyphPageTreeNode::getRootChild(variantFontData.get(), pageNumber);
     
    323325                    GlyphData data = variantPage->glyphDataForCharacter(c);
    324326                    if (data.fontData)
    325                         return std::make_pair(data, variantPage);
     327                        return data;
    326328                }
    327329
    328330                // Do not attempt system fallback off the variantFontData. This is the very unlikely case that
    329331                // a font has the lowercase character but the small caps font does not have its uppercase version.
    330                 return std::make_pair(variantFontData->missingGlyphData(), page);
     332                return variantFontData->missingGlyphData();
    331333            }
    332334
    333335            if (node->isSystemFallback())
    334                 return glyphDataAndPageForSystemFallback(c, description, variant, pageNumber, *node);
     336                return glyphDataForSystemFallback(c, description, variant, pageNumber, *node);
    335337        }
    336338
     
    339341}
    340342
    341 std::pair<GlyphData, GlyphPage*> FontGlyphs::glyphDataAndPageForCharacter(const FontDescription& description, UChar32 c, bool mirror, FontDataVariant variant)
     343GlyphData FontGlyphs::glyphDataForCharacter(const FontDescription& description, UChar32 c, bool mirror, FontDataVariant variant)
    342344{
    343345    ASSERT(isMainThread());
     
    365367
    366368    if (variant != NormalVariant)
    367         return glyphDataAndPageForVariant(c, description, variant, pageNumber, node);
     369        return glyphDataForVariant(c, description, variant, pageNumber, node);
    368370
    369371    while (true) {
     
    373375                if (data.fontData->platformData().orientation() == Vertical && !data.fontData->isTextOrientationFallback()) {
    374376                    if (!Font::isCJKIdeographOrSymbol(c))
    375                         return glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, page, pageNumber);
     377                        return glyphDataForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, pageNumber);
    376378
    377379                    if (!data.fontData->hasVerticalGlyphs()) {
    378380                        // Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs
    379381                        // to make sure you get a square (even for broken glyphs like symbols used for punctuation).
    380                         return glyphDataAndPageForVariant(c, description, BrokenIdeographVariant, pageNumber, node);
     382                        return glyphDataForVariant(c, description, BrokenIdeographVariant, pageNumber, node);
    381383                    }
    382384#if PLATFORM(COCOA)
    383385                    if (data.fontData->platformData().syntheticOblique())
    384                         return glyphDataAndPageForCJKCharacterWithoutSyntheticItalic(c, data, page, pageNumber);
     386                        return glyphDataForCJKCharacterWithoutSyntheticItalic(c, data, pageNumber);
    385387#endif
    386388                }
    387389
    388                 return std::make_pair(data, page);
     390                return data;
    389391            }
    390392
    391393            if (node->isSystemFallback())
    392                 return glyphDataAndPageForSystemFallback(c, description, variant, pageNumber, *node);
     394                return glyphDataForSystemFallback(c, description, variant, pageNumber, *node);
    393395        }
    394396
  • trunk/Source/WebCore/platform/graphics/FontGlyphs.h

    r177259 r177490  
    4848    typedef HashMap<int, GlyphPageTreeNode*, DefaultHash<int>::Hash> GlyphPages;
    4949
    50     class GlyphPagesStateSaver {
    51     public:
    52         GlyphPagesStateSaver(FontGlyphs& glyphs)
    53             : m_glyphs(glyphs)
    54             , m_pages(glyphs.m_pages)
    55             , m_pageZero(glyphs.m_pageZero)
    56         {
    57         }
    58 
    59         ~GlyphPagesStateSaver()
    60         {
    61             m_glyphs.m_pages = m_pages;
    62             m_glyphs.m_pageZero = m_pageZero;
    63         }
    64 
    65     private:
    66         FontGlyphs& m_glyphs;
    67         GlyphPages& m_pages;
    68         GlyphPageTreeNode* m_pageZero;
    69     };
    70 
    7150    static Ref<FontGlyphs> create(PassRefPtr<FontSelector> fontSelector) { return adoptRef(*new FontGlyphs(fontSelector)); }
    7251    static Ref<FontGlyphs> createForPlatformFont(const FontPlatformData& platformData) { return adoptRef(*new FontGlyphs(platformData)); }
     
    7655    bool isForPlatformFont() const { return m_isForPlatformFont; }
    7756
    78     std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(const FontDescription&, UChar32, bool mirror, FontDataVariant);
     57    GlyphData glyphDataForCharacter(const FontDescription&, UChar32, bool mirror, FontDataVariant);
    7958
    8059    bool isFixedPitch(const FontDescription&);
     
    9978    FontGlyphs(const FontPlatformData&);
    10079
    101     std::pair<GlyphData, GlyphPage*> glyphDataAndPageForSystemFallback(UChar32, const FontDescription&, FontDataVariant, unsigned pageNumber, GlyphPageTreeNode&);
    102     std::pair<GlyphData, GlyphPage*> glyphDataAndPageForVariant(UChar32, const FontDescription&, FontDataVariant, unsigned pageNumber, GlyphPageTreeNode*&);
     80    GlyphData glyphDataForSystemFallback(UChar32, const FontDescription&, FontDataVariant, unsigned pageNumber, GlyphPageTreeNode&);
     81    GlyphData glyphDataForVariant(UChar32, const FontDescription&, FontDataVariant, unsigned pageNumber, GlyphPageTreeNode*&);
    10382
    10483    WEBCORE_EXPORT void releaseFontData();
  • trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp

    r174619 r177490  
    296296    ASSERT(primaryFont);
    297297
    298     std::pair<GlyphData, GlyphPage*> pair = font.glyphDataAndPageForCharacter(character, mirror, AutoVariant);
    299     GlyphData glyphData = pair.first;
     298    GlyphData glyphData = font.glyphDataForCharacter(character, mirror, AutoVariant);
    300299
    301300    // Check if we have the missing glyph data, in which case we can just return.
     
    306305    }
    307306
    308     // Save data from the font fallback list because we may modify it later. Do this before the
    309     // potential change to glyphData.fontData below.
    310     FontGlyphs* glyph = font.glyphs();
    311     ASSERT(glyph);
    312     FontGlyphs::GlyphPagesStateSaver glyphPagesSaver(*glyph);
    313 
    314307    // Characters enclosed by an <altGlyph> element, may not be registered in the GlyphPage.
    315     const SimpleFontData* originalFontData = glyphData.fontData;
    316308    if (glyphData.fontData && !glyphData.fontData->isSVGFont()) {
    317309        auto& elementRenderer = is<RenderElement>(renderer()) ? downcast<RenderElement>(renderer()) : *renderer().parent();
     
    323315
    324316    const SimpleFontData* fontData = glyphData.fontData;
    325     if (fontData) {
    326         if (!fontData->isSVGFont())
    327             return glyphData;
    328 
    329         SVGFontElement* fontElement = nullptr;
    330         SVGFontFaceElement* fontFaceElement = nullptr;
    331 
    332         const SVGFontData* svgFontData = svgFontAndFontFaceElementForFontData(fontData, fontFaceElement, fontElement);
    333         if (!fontElement || !fontFaceElement)
    334             return glyphData;
    335 
    336         // If we got here, we're dealing with a glyph defined in a SVG Font.
    337         // The returned glyph by glyphDataAndPageForCharacter() is a glyph stored in the SVG Font glyph table.
    338         // This doesn't necessarily mean the glyph is suitable for rendering/measuring in this context, its
    339         // arabic-form/orientation/... may not match, we have to apply SVG Glyph selection to discover that.
    340         if (svgFontData->applySVGGlyphSelection(iterator, glyphData, mirror, currentCharacter, advanceLength, normalizedSpacesStringCache))
    341             return glyphData;
    342     }
    343 
    344     GlyphPage* page = pair.second;
    345     ASSERT(page);
    346 
    347     // No suitable glyph found that is compatible with the requirments (same language, arabic-form, orientation etc.)
    348     // Even though our GlyphPage contains an entry for eg. glyph "a", it's not compatible. So we have to temporarily
    349     // remove the glyph data information from the GlyphPage, and retry the lookup, which handles font fallbacks correctly.
    350     page->setGlyphDataForCharacter(character, 0, nullptr);
    351 
    352     // Assure that the font fallback glyph selection worked, aka. the fallbackGlyphData font data is not the same as before.
    353     GlyphData fallbackGlyphData = font.glyphDataForCharacter(character, mirror);
    354     ASSERT(fallbackGlyphData.fontData != fontData);
    355 
    356     // Restore original state of the SVG Font glyph table and the current font fallback list,
    357     // to assure the next lookup of the same glyph won't immediately return the fallback glyph.
    358     page->setGlyphDataForCharacter(character, glyphData.glyph, originalFontData);
    359     ASSERT(fallbackGlyphData.fontData);
    360     return fallbackGlyphData;
     317    if (!fontData || !fontData->isSVGFont())
     318        return glyphData;
     319
     320    SVGFontElement* fontElement = nullptr;
     321    SVGFontFaceElement* fontFaceElement = nullptr;
     322    const SVGFontData* svgFontData = svgFontAndFontFaceElementForFontData(fontData, fontFaceElement, fontElement);
     323    if (!svgFontData)
     324        return glyphData;
     325
     326    // If we got here, we're dealing with a glyph defined in a SVG Font.
     327    // The returned glyph by glyphDataForCharacter() is a glyph stored in the SVG Font glyph table.
     328    // This doesn't necessarily mean the glyph is suitable for rendering/measuring in this context, its
     329    // arabic-form/orientation/... may not match, we have to apply SVG Glyph selection to discover that.
     330    if (svgFontData->applySVGGlyphSelection(iterator, glyphData, mirror, currentCharacter, advanceLength, normalizedSpacesStringCache))
     331        return glyphData;
     332    if (missingGlyphData.glyph)
     333        return missingGlyphData;
     334
     335    // SVG font context sensitive selection failed and there is no defined missing glyph. Drop down to a default font.
     336    // The behavior does not seem to be specified. For simplicity we don't try to resolve font fallbacks context-sensitively.
     337    FontDescription fallbackDescription = font.fontDescription();
     338    fallbackDescription.setFamilies(Vector<AtomicString> { sansSerifFamily });
     339    Font fallbackFont(fallbackDescription, font.letterSpacing(), font.wordSpacing());
     340    fallbackFont.update(font.fontSelector());
     341
     342    return fallbackFont.glyphDataForCharacter(character, mirror, AutoVariant);
    361343}
    362344
Note: See TracChangeset for help on using the changeset viewer.