⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 284677 in webkit


Ignore:
Timestamp:
Oct 22, 2021, 6:24:11 AM (5 years ago)
Author:
Alan Bujtas
Message:

FontCascade::widthForSimpleText fails to produce matching measured width for monospace font
https://bugs.webkit.org/show_bug.cgi?id=232104
<rdar://83991027>

Reviewed by Antti Koivisto.

Source/WebCore:

Adjust widthForSimpleText to match WidthIterator's logic as the comment says:

"This is needed only to match the result of the slow path

Same glyph widths but different floating point arithmetic can produce different run width."

(see r213008)

  • platform/graphics/FontCascade.cpp:

(WebCore::FontCascade::widthForSimpleText const):

LayoutTests:

  • platform/ios-wk2/TestExpectations:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r284667 r284677  
     12021-10-22  Alan Bujtas  <zalan@apple.com>
     2
     3        FontCascade::widthForSimpleText fails to produce matching measured width for monospace font
     4        https://bugs.webkit.org/show_bug.cgi?id=232104
     5        <rdar://83991027>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        * platform/ios-wk2/TestExpectations:
     10
    1112021-10-21  Cathie Chen  <cathiechen@igalia.com>
    212
  • trunk/LayoutTests/platform/ios-wk2/TestExpectations

    r284659 r284677  
    12051205
    12061206webkit.org/b/163362 platform/ios/ios/plugin/youtube-flash-plugin-iframe.html [ Pass Failure ]
    1207 
    1208 webkit.org/b/231378 platform/ios/fast/text/system-monospaced-numbers.html [ Failure ]
    12091207
    12101208webkit.org/b/164960 http/tests/security/module-correct-mime-types.html [ Slow ]
  • trunk/Source/WebCore/ChangeLog

    r284676 r284677  
     12021-10-22  Alan Bujtas  <zalan@apple.com>
     2
     3        FontCascade::widthForSimpleText fails to produce matching measured width for monospace font
     4        https://bugs.webkit.org/show_bug.cgi?id=232104
     5        <rdar://83991027>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Adjust widthForSimpleText to match WidthIterator's logic as the comment says:
     10
     11          "This is needed only to match the result of the slow path
     12           Same glyph widths but different floating point arithmetic can produce different run width."
     13        (see r213008)
     14
     15        * platform/graphics/FontCascade.cpp:
     16        (WebCore::FontCascade::widthForSimpleText const):
     17
    1182021-10-22  Carlos Garcia Campos  <cgarcia@igalia.com>
    219
  • trunk/Source/WebCore/platform/graphics/FontCascade.cpp

    r283863 r284677  
    312312
    313313    GlyphBuffer glyphBuffer;
    314     float runWidth = 0;
     314    float beforeWidth = 0;
    315315    auto& font = primaryFont();
    316316    for (unsigned i = 0; i < text.length(); ++i) {
    317317        auto glyph = glyphDataForCharacter(text[i], false).glyph;
    318318        auto glyphWidth = font.widthForGlyph(glyph);
    319         runWidth += glyphWidth;
     319        beforeWidth += glyphWidth;
    320320        glyphBuffer.add(glyph, font, glyphWidth, i);
    321321    }
     
    324324    // This is needed only to match the result of the slow path.
    325325    // Same glyph widths but different floating point arithmetic can produce different run width.
    326     float runWidthDifferenceWithTransformApplied = -runWidth;
     326    float afterWidth = 0;
    327327    for (size_t i = 0; i < glyphBuffer.size(); ++i)
    328         runWidthDifferenceWithTransformApplied += WebCore::width(glyphBuffer.advanceAt(i));
    329     runWidth += runWidthDifferenceWithTransformApplied;
    330 
    331     runWidth += WebCore::width(initialAdvance);
     328        afterWidth += WebCore::width(glyphBuffer.advanceAt(i));
     329    auto additionalAdvance = afterWidth - beforeWidth;
     330
     331    auto finalWidth = beforeWidth + additionalAdvance;
     332    finalWidth += WebCore::width(initialAdvance);
    332333
    333334    if (cacheEntry)
    334         *cacheEntry = runWidth;
    335     return runWidth;
     335        *cacheEntry = finalWidth;
     336    return finalWidth;
    336337}
    337338
Note: See TracChangeset for help on using the changeset viewer.