Title: [284677] trunk
Revision
284677
Author
[email protected]
Date
2021-10-22 06:24:11 -0700 (Fri, 22 Oct 2021)

Log 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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (284676 => 284677)


--- trunk/LayoutTests/ChangeLog	2021-10-22 10:05:08 UTC (rev 284676)
+++ trunk/LayoutTests/ChangeLog	2021-10-22 13:24:11 UTC (rev 284677)
@@ -1,3 +1,13 @@
+2021-10-22  Alan Bujtas  <[email protected]>
+
+        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.
+
+        * platform/ios-wk2/TestExpectations:
+
 2021-10-21  Cathie Chen  <[email protected]>
 
         The intrisic size of picture image inside a template is always zero

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (284676 => 284677)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-10-22 10:05:08 UTC (rev 284676)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-10-22 13:24:11 UTC (rev 284677)
@@ -1205,8 +1205,6 @@
 
 webkit.org/b/163362 platform/ios/ios/plugin/youtube-flash-plugin-iframe.html [ Pass Failure ]
 
-webkit.org/b/231378 platform/ios/fast/text/system-monospaced-numbers.html [ Failure ]
-
 webkit.org/b/164960 http/tests/security/module-correct-mime-types.html [ Slow ]
 
 webkit.org/b/164961 [ Release ] http/tests/storage/callbacks-are-called-in-correct-context.html [ Timeout ]

Modified: trunk/Source/WebCore/ChangeLog (284676 => 284677)


--- trunk/Source/WebCore/ChangeLog	2021-10-22 10:05:08 UTC (rev 284676)
+++ trunk/Source/WebCore/ChangeLog	2021-10-22 13:24:11 UTC (rev 284677)
@@ -1,3 +1,20 @@
+2021-10-22  Alan Bujtas  <[email protected]>
+
+        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.
+
+        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):
+
 2021-10-22  Carlos Garcia Campos  <[email protected]>
 
         [GTK][a11y] Localized role name doesn't work with ATSPI enabled

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (284676 => 284677)


--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2021-10-22 10:05:08 UTC (rev 284676)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2021-10-22 13:24:11 UTC (rev 284677)
@@ -311,12 +311,12 @@
         return *cacheEntry;
 
     GlyphBuffer glyphBuffer;
-    float runWidth = 0;
+    float beforeWidth = 0;
     auto& font = primaryFont();
     for (unsigned i = 0; i < text.length(); ++i) {
         auto glyph = glyphDataForCharacter(text[i], false).glyph;
         auto glyphWidth = font.widthForGlyph(glyph);
-        runWidth += glyphWidth;
+        beforeWidth += glyphWidth;
         glyphBuffer.add(glyph, font, glyphWidth, i);
     }
 
@@ -323,16 +323,17 @@
     auto initialAdvance = font.applyTransforms(glyphBuffer, 0, 0, enableKerning(), requiresShaping(), fontDescription().computedLocale(), text, textDirection);
     // 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.
-    float runWidthDifferenceWithTransformApplied = -runWidth;
+    float afterWidth = 0;
     for (size_t i = 0; i < glyphBuffer.size(); ++i)
-        runWidthDifferenceWithTransformApplied += WebCore::width(glyphBuffer.advanceAt(i));
-    runWidth += runWidthDifferenceWithTransformApplied;
+        afterWidth += WebCore::width(glyphBuffer.advanceAt(i));
+    auto additionalAdvance = afterWidth - beforeWidth;
 
-    runWidth += WebCore::width(initialAdvance);
+    auto finalWidth = beforeWidth + additionalAdvance;
+    finalWidth += WebCore::width(initialAdvance);
 
     if (cacheEntry)
-        *cacheEntry = runWidth;
-    return runWidth;
+        *cacheEntry = finalWidth;
+    return finalWidth;
 }
 
 GlyphData FontCascade::glyphDataForCharacter(UChar32 c, bool mirror, FontVariant variant) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to