Closed Bug 1840075 Opened 2 years ago Closed 2 years ago

Use the OpenType baseline table to implement textBaseline alignment and TextMetrics baseline attributes

Categories

(Core :: Graphics: Canvas2D, defect)

defect

Tracking

()

RESOLVED FIXED
116 Branch
Tracking Status
firefox116 --- fixed

People

(Reporter: jfkthame, Assigned: jfkthame)

References

Details

Attachments

(2 files)

Currently, we "fake" hanging and ideographic baselines for these canvas2d APIs by just using arbitrary factors of the font ascent and descent: https://searchfox.org/mozilla-central/rev/d307d4d9f06dab6d16e963a4318e5e8ff4899141/dom/canvas/CanvasRenderingContext2D.cpp#4400-4407

For accurate results, we should read baseline positions from the font (when provided), and use those rather than these ad hoc guesses.

These tests assume a TextMetrics.getBaselines() function, which does not exist in the current spec;
rather, it has specific attributes for alphabetic, hanging and ideographic baselines.
I think the test was based on an older proposal that didn't end up in the spec in that form.

(See https://html.spec.whatwg.org/multipage/canvas.html#textmetrics)

In addition, the values the tests expect don't correspond to what's in the CanvasTest font 'BASE'
table for the hanging and ideographic baselines (they seem to be the ascent and descent instead).
So fixing those, in preparation for actually implementing support.

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a908a6cc6603 Adjust WPT 2d.text.measure.baselines tests to match current spec for canvas TextMetrics. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/f27a6b03f043 Implement support for the OpenType BASE (baselines) table, and use it to back canvas2d TextMetrics attributes and textBaseline alignment. r=gfx-reviewers,lsalzman
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/40730 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 116 Branch
Upstream PR merged by moz-wptsync-bot
Regressions: 1840327
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: