[wpt-sync] Sync PR 58386 - [Fonts] Fix canvas measureText() precision at small font sizes
Categories
(Core :: Graphics: Canvas2D, task, P4)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox150 | --- | fixed |
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 58386 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/58386
Details from upstream follow.
Sejal Anand <sejalanand@microsoft.com> wrote:
[Fonts] Fix canvas measureText() precision at small font sizes
Canvas
measureText()returns inaccurate bounding box values at small
font sizes because Skia stores glyph bounds as integers internally,
causing large relative errors.Fix this by adding PreciseBoundsForGlyph, which uses
SkFont::getPath()
to get float-precision bounds directly from the glyph outlines, and
using it in TextMetrics instead of BoundsForGlyph.Falls back to
SkFont::getBounds()for bitmap-only glyphs that have no
outlines.Bug: 479240778
Change-Id: I54cc13662114037f7e46010763d0ba45f8848caa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7564913
Reviewed-by: Dileep Maurya \<dileepmaurya@microsoft.com>
Reviewed-by: Koji Ishii \<kojii@chromium.org>
Commit-Queue: Sejal Anand \<sejalanand@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1596904}
| Assignee | ||
Updated•2 months ago
|
| Assignee | ||
Comment 1•2 months ago
|
||
| Assignee | ||
Comment 2•2 months ago
|
||
CI Results
Ran 7 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI
Total 126 tests and 2 subtests
Status Summary
Firefox
OK : 1[GitHub] 106[Gecko-windows11-64-24h2-debug] 107[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-64-24h2-opt]
PASS: 12[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview] 98[Gecko-windows11-64-24h2-debug] 99[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-64-24h2-opt]
FAIL: 1[GitHub] 7[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview] 107[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-64-24h2-debug, Gecko-windows11-64-24h2-opt]
Chrome
OK : 1
PASS: 1
Safari
OK : 1
PASS: 1
Links
Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base
Details
New Tests That Don't Pass
- /html/canvas/element/text/2d.text.measure.fillTextCluster-align.tentative.html [wpt.fyi]:
FAIL - /html/canvas/element/text/2d.text.measure.fillTextCluster-baseline.tentative.html [wpt.fyi]:
FAIL - /html/canvas/element/text/2d.text.measure.fillTextCluster-drawing-styles-change.tentative.html [wpt.fyi]:
FAIL - /html/canvas/element/text/2d.text.measure.strokeTextCluster-align.tentative.html [wpt.fyi]:
FAIL - /html/canvas/element/text/2d.text.measure.strokeTextCluster-baseline.tentative.html [wpt.fyi]:
FAIL - /html/canvas/element/text/2d.text.measure.strokeTextCluster-drawing-styles-change.tentative.html [wpt.fyi]:
FAIL - /html/canvas/element/text/2d.text.writingmode.html [wpt.fyi]:
FAIL - /html/canvas/element/text/2d.text.draw.fontface.repeat.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt,Gecko-windows11-64-24h2-opt],SKIP[Gecko-windows11-64-24h2-debug] - /html/canvas/element/text/2d.text.font.parse.system.html [wpt.fyi]
- System fonts must be computed to explicit values:
FAIL
- System fonts must be computed to explicit values:
- /html/canvas/element/text/2d.text.lang.default.html [wpt.fyi]
- Canvas test: 2d.text.lang.default:
FAIL
- Canvas test: 2d.text.lang.default:
- /html/canvas/element/text/2d.text.measure.actualBoundingBox.small-font.html [wpt.fyi]
- actualBoundingBox centers text correctly at small font sizes:
FAIL[GitHub],PASS[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt,Gecko-windows11-64-24h2-debug,Gecko-windows11-64-24h2-opt] (Chrome:PASS, Safari:PASS)
- actualBoundingBox centers text correctly at small font sizes:
- /html/canvas/element/text/2d.text.measure.fillTextCluster-options.tentative.html [wpt.fyi]
- Test that fillTextCluster() correctly applies the options passed as a dictionary.:
FAIL
- Test that fillTextCluster() correctly applies the options passed as a dictionary.:
- /html/canvas/element/text/2d.text.measure.fillTextCluster-range.tentative.html [wpt.fyi]
- Test that getTextClusters() and fillTextCluster() correctly render different ranges of the input text.:
FAIL
- Test that getTextClusters() and fillTextCluster() correctly render different ranges of the input text.:
- /html/canvas/element/text/2d.text.measure.getActualBoundingBox-exceptions.tentative.html [wpt.fyi]
- Check that TextMetrics::getActualBoundingBox() throws when using invalid indexes.:
FAIL
- Check that TextMetrics::getActualBoundingBox() throws when using invalid indexes.:
- /html/canvas/element/text/2d.text.measure.getActualBoundingBox-full-text.tentative.html [wpt.fyi]
- Test TextMetrics::getActualBoundingBox() for the full length of the string for some edge cases, with direction ltr and no-directional-override:
FAIL - Test TextMetrics::getActualBoundingBox() for the full length of the string for some edge cases, with direction rtl and no-directional-override:
FAIL - Test TextMetrics::getActualBoundingBox() for the full length of the string for some edge cases, with direction ltr and directional-override:
FAIL - Test TextMetrics::getActualBoundingBox() for the full length of the string for some edge cases, with direction rtl and directional-override:
FAIL
- Test TextMetrics::getActualBoundingBox() for the full length of the string for some edge cases, with direction ltr and no-directional-override:
- /html/canvas/element/text/2d.text.measure.getActualBoundingBox.tentative.html [wpt.fyi]
- Test TextMetrics::getActualBoundingBox(), with text align left , and 0px letter spacing.:
FAIL - Test TextMetrics::getActualBoundingBox(), with text align center , and 0px letter spacing.:
FAIL - Test TextMetrics::getActualBoundingBox(), with text align right , and 0px letter spacing.:
FAIL - Test TextMetrics::getActualBoundingBox(), with text align left , and 10px letter spacing.:
FAIL - Test TextMetrics::getActualBoundingBox(), with text align center , and 10px letter spacing.:
FAIL - Test TextMetrics::getActualBoundingBox(), with text align right , and 10px letter spacing.:
FAIL
- Test TextMetrics::getActualBoundingBox(), with text align left , and 0px letter spacing.:
- /html/canvas/element/text/2d.text.measure.index-from-offset-edge-cases.tentative.html [wpt.fyi]
- Test the edge cases for getIndexFromOffset, where the point is at the edge of glyph and at the midpoint.:
FAIL
- Test the edge cases for getIndexFromOffset, where the point is at the edge of glyph and at the midpoint.:
- /html/canvas/element/text/2d.text.measure.index-from-offset-edges.tentative.html [wpt.fyi]
- Check that TextMetrics::getIndexFromOffset() gives correct edges when the requested point is outside the range, with direction ltr and text align left.:
FAIL - Check that TextMetrics::getIndexFromOffset() gives correct edges when the requested point is outside the range, with direction rtl and text align left.:
FAIL - Check that TextMetrics::getIndexFromOffset() gives correct edges when the requested point is outside the range, with direction ltr and text align center.:
FAIL - Check that TextMetrics::getIndexFromOffset() gives correct edges when the requested point is outside the range, with direction rtl and text align center.:
FAIL - Check that TextMetrics::getIndexFromOffset() gives correct edges when the requested point is outside the range, with direction ltr and text align right.:
FAIL - Check that TextMetrics::getIndexFromOffset() gives correct edges when the requested point is outside the range, with direction rtl and text align right.:
FAIL - Check that TextMetrics::getIndexFromOffset() gives correct edges when the requested point is outside the range, with direction ltr and text align start.:
FAIL - Check that TextMetrics::getIndexFromOffset() gives correct edges when the requested point is outside the range, with direction rtl and text align start.:
FAIL - Check that TextMetrics::getIndexFromOffset() gives correct edges when the requested point is outside the range, with direction ltr and text align end.:
FAIL - Check that TextMetrics::getIndexFromOffset() gives correct edges when the requested point is outside the range, with direction rtl and text align end.:
FAIL
- Check that TextMetrics::getIndexFromOffset() gives correct edges when the requested point is outside the range, with direction ltr and text align left.:
- /html/canvas/element/text/2d.text.measure.index-from-offset.tentative.html [wpt.fyi]
- Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align left, 0px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align left, 0px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align center, 0px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align center, 0px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align right, 0px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align right, 0px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align start, 0px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align start, 0px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align end, 0px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align end, 0px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align left, 10px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align left, 10px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align center, 10px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align center, 10px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align right, 10px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align right, 10px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align start, 10px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align start, 10px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align end, 10px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align end, 10px letter spacing and no-directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align left, 0px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align left, 0px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align center, 0px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align center, 0px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align right, 0px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align right, 0px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align start, 0px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align start, 0px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align end, 0px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align end, 0px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align left, 10px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align left, 10px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align center, 10px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align center, 10px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align right, 10px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align right, 10px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align start, 10px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align start, 10px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align end, 10px letter spacing and directional-override.:
FAIL - Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction rtl, text align end, 10px letter spacing and directional-override.:
FAIL
- Check that TextMetrics::getIndexFromOffset() matches its DOM equivalent, where possible, with direction ltr, text align left, 0px letter spacing and no-directional-override.:
- /html/canvas/element/text/2d.text.measure.lang.html [wpt.fyi]
- Testing the lang attribute:
FAIL
- Testing the lang attribute:
- /html/canvas/element/text/2d.text.measure.lang.inherit.html [wpt.fyi]
- Testing the lang attribute:
FAIL
- Testing the lang attribute:
- /html/canvas/element/text/2d.text.measure.selection-rects-baselines.tentative.html [wpt.fyi]
- Check that TextMetrics::getSelectionRects() works correctly with textBaseline.:
FAIL
- Check that TextMetrics::getSelectionRects() works correctly with textBaseline.:
- /html/canvas/element/text/2d.text.measure.selection-rects-exceptions.tentative.html [wpt.fyi]
- Check that TextMetrics::getSelectionRects() throws when using invalid indexes.:
FAIL
- Check that TextMetrics::getSelectionRects() throws when using invalid indexes.:
- /html/canvas/element/text/2d.text.measure.selection-rects.tentative.html [wpt.fyi]
- Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 0px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 0px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 0px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 0px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 0px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 0px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 10px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 10px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 10px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 10px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 10px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 10px letter spacing, and no-directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 0px letter spacing, and directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 0px letter spacing, and directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 0px letter spacing, and directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 0px letter spacing, and directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 0px letter spacing, and directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 0px letter spacing, and directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 10px letter spacing, and directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align left, 10px letter spacing, and directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align center, 10px letter spacing, and directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align center, 10px letter spacing, and directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align right, 10px letter spacing, and directional-override.:
FAIL - Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction rtl, text align right, 10px letter spacing, and directional-override.:
FAIL
- Check that TextMetrics::getSelectionRects() matches its DOM equivalent, with direction ltr, text align left, 0px letter spacing, and no-directional-override.:
- /html/canvas/element/text/2d.text.measure.strokeTextCluster-options.tentative.html [wpt.fyi]
- Test that strokeTextCluster() correctly applies the options passed as a dictionary.:
FAIL
- Test that strokeTextCluster() correctly applies the options passed as a dictionary.:
- /html/canvas/element/text/2d.text.measure.strokeTextCluster-range.tentative.html [wpt.fyi]
- Test that getTextClusters() and strokeTextCluster() correctly render different ranges of the input text.:
FAIL
- Test that getTextClusters() and strokeTextCluster() correctly render different ranges of the input text.:
- /html/canvas/element/text/2d.text.measure.text-clusters-exceptions.tentative.html [wpt.fyi]
- Check that TextMetrics::getTextClusters() throws when using invalid indexes.:
FAIL
- Check that TextMetrics::getTextClusters() throws when using invalid indexes.:
- /html/canvas/element/text/2d.text.measure.text-clusters-position.tentative.html [wpt.fyi]
- Test that TextMetrics::getTextClusters() returns clusters that are positioned according to the target align and baseline passed as options.:
FAIL
- Test that TextMetrics::getTextClusters() returns clusters that are positioned according to the target align and baseline passed as options.:
- /html/canvas/element/text/2d.text.measure.text-clusters-split.tentative.html [wpt.fyi]
- Test that getTextClusters() splits the input correctly into the minimal clusters, keeping emojis together.:
FAIL
- Test that getTextClusters() splits the input correctly into the minimal clusters, keeping emojis together.:
- /html/canvas/element/text/2d.text.measure.width.nullCharacter.html [wpt.fyi]
- Null character does not take up space:
FAIL
- Null character does not take up space:
Tests Disabled in Gecko Infrastructure
- /html/canvas/element/text/2d.text.draw.fontface.repeat.html [wpt.fyi]:
OK[Gecko-linux2404-64-debug,Gecko-linux2404-64-opt,Gecko-windows11-64-24h2-opt],SKIP[Gecko-windows11-64-24h2-debug]
Description
•