canvas: Move font selection and text shaping to script (#38979)

Instead of doing font selection and text shaping in `canvas`, move this
to `script`. This allows canvas to use the shared `Document`
`FontContext`, which has access to web fonts. In addition, ensure that
there is a font style accessible for `OffscreenCanvas` in workers.

Testing: This causes a number of WPT tests to start to pass as web fonts
are
supported on canvas again. In addition, some start to fail as they
expose other
issues:
 - The lack of support for the `Context2D.fontStretch` property
 - Issues with zerosize gradient interpolation.
- Differences between quoted and unquoted font family names. This seems
like
a timing issue with the way we are handling web fonts. The test seems to
be
expecting Local fonts to be available immediately (without waiting for
them
to load). This isn't how Servo works ATM. Seems like an issue with the
test.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-08-28 03:30:34 -07:00 committed by GitHub
parent 91b27d98a2
commit cb64def7e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 604 additions and 809 deletions

View file

@ -0,0 +1,42 @@
[generic-family-keywords-003.html]
[@font-face matching for quoted and unquoted math (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted ui-serif (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted ui-sans-serif (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted ui-monospace (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted ui-rounded (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted sans-serif (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted cursive (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted fantasy (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted monospace (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted system-ui (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted generic(fangsong) (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted generic(kai) (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted generic(khmer-mul) (drawing text in a canvas)]
expected: FAIL
[@font-face matching for quoted and unquoted generic(nastaliq) (drawing text in a canvas)]
expected: FAIL