fonts: Add support for more @font-face features (#32164)

There are a couple major changes here:

1. Support is added for the `weight`, `style`, `stretch` and
   `unicode-range` declarations in `@font-face`.
2. Font matching in the font cache can return templates and
   `FontGroupFamily` can own mulitple templates. This is due to needing
   support for "composite fonts". These are `@font-face` declarations
   that only differ in their `unicode-range` definition.

This fixes a lot of non-determinism in font selection especially when
dealing with pages that define "composite faces." A notable example of
such a page is servo.org, which now consistently displays the correct
web font.

One test starts to fail due to an uncovered bug, but this will be fixed
in a followup change.

Fixes #20686.
Fixes #20684.

Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson 2024-04-29 19:02:07 +02:00 committed by GitHub
parent 628e33bfa9
commit 4732da3477
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 613 additions and 593 deletions

View file

@ -0,0 +1,2 @@
[line-height-201.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[line-height-205.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[first-available-font-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[first-available-font-003.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[first-available-font-004.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[first-available-font-005.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[first-available-font-007.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-size-adjust-014.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-stretch-01.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-stretch-02.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-stretch-03.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-stretch-04.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-stretch-05.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-stretch-06.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-stretch-07.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-stretch-08.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-stretch-09.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-stretch-10.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[font-stretch-11.html]
expected: FAIL

View file

@ -8,27 +8,12 @@
[Descriptor matching priority: Style has higher priority than weight]
expected: FAIL
[Matching font-weight: '400' should prefer '450 460' over '500']
expected: FAIL
[Matching font-weight: '400' should prefer '350 399' over '351 398']
expected: FAIL
[Matching font-weight: '500' should prefer '351 398' over '501 550']
expected: FAIL
[Matching font-weight: '500' should prefer '501 550' over '502 560']
expected: FAIL
[Matching font-weight: '501' should prefer '390 410' over '300 350']
expected: FAIL
[Matching font-weight: '399' should prefer '340 360' over '200 300']
expected: FAIL
[Matching font-weight: '399' should prefer '450 460' over '500 501']
expected: FAIL
[Matching font-style: 'normal' should prefer 'oblique 0deg' over 'oblique 10deg 40deg']
expected: FAIL
@ -47,12 +32,6 @@
[Matching font-style: 'oblique 21deg' should prefer 'oblique 21deg' over 'oblique 30deg 60deg']
expected: FAIL
[Matching font-weight: '400' should prefer '400' over '450 460']
expected: FAIL
[Matching font-weight: '399' should prefer '500 501' over '502 510']
expected: FAIL
[Matching font-style: 'oblique 21deg' should prefer 'oblique 30deg 60deg' over 'oblique 40deg 50deg']
expected: FAIL
@ -74,9 +53,6 @@
[Matching font-style: 'oblique 21deg' should prefer 'oblique 0deg' over 'oblique -50deg -20deg']
expected: FAIL
[Matching font-weight: '399' should prefer '350 399' over '340 360']
expected: FAIL
[Matching font-stretch: '110%' should prefer '100%' over '50% 80%']
expected: FAIL
@ -95,9 +71,6 @@
[Matching font-style: 'oblique 10deg' should prefer 'oblique 40deg 50deg' over 'italic']
expected: FAIL
[Matching font-weight: '400' should prefer '501 550' over '502 560']
expected: FAIL
[Matching font-style: 'normal' should prefer 'normal' over 'oblique 0deg']
expected: FAIL
@ -125,9 +98,6 @@
[Matching font-style: 'oblique -20deg' should prefer 'oblique -60deg -40deg' over 'oblique -10deg']
expected: FAIL
[Matching font-weight: '501' should prefer '450 460' over '390 410']
expected: FAIL
[Matching font-stretch: '110%' should prefer '110% 120%' over '115% 116%']
expected: FAIL
@ -185,18 +155,9 @@
[Matching font-style: 'oblique -10deg' should prefer 'oblique 0deg 10deg' over 'oblique 40deg 50deg']
expected: FAIL
[Matching font-weight: '430' should prefer '400 425' over '350 399']
expected: FAIL
[Matching font-weight: '501' should prefer '501' over '502 510']
expected: FAIL
[Matching font-weight: '501' should prefer '503 520' over '500']
expected: FAIL
[Matching font-weight: '501' should prefer '500' over '450 460']
expected: FAIL
[Matching font-stretch: '110%' should prefer '115% 116%' over '105%']
expected: FAIL
@ -221,9 +182,6 @@
[Matching font-style: 'oblique -20deg' should prefer 'oblique -10deg' over 'italic']
expected: FAIL
[Matching font-weight: '430' should prefer '350 399' over '340 398']
expected: FAIL
[Matching font-stretch: '90%' should prefer '60% 70%' over '110% 140%']
expected: FAIL
@ -248,9 +206,6 @@
[Matching font-style: 'oblique -20deg' should prefer 'oblique -20deg' over 'oblique -60deg -40deg']
expected: FAIL
[Matching font-weight: '430' should prefer '420 440' over '450 460']
expected: FAIL
[Matching font-stretch: '100%' should prefer '110% 120%' over '115% 116%']
expected: FAIL
@ -263,9 +218,6 @@
[Matching font-weight: '430' should prefer '340 398' over '501 550']
expected: FAIL
[Matching font-weight: '501' should prefer '502 510' over '503 520']
expected: FAIL
[Matching font-style: 'oblique 20deg' should prefer 'oblique 30deg 60deg' over 'oblique 40deg 50deg']
expected: FAIL
@ -275,21 +227,6 @@
[Matching font-style: 'oblique -20deg' should prefer 'oblique 0deg' over 'oblique 30deg 60deg']
expected: FAIL
[Matching font-weight: '400' should prefer '351 398' over '501 550']
expected: FAIL
[Matching font-weight: '430' should prefer '501 550' over '502 560']
expected: FAIL
[Matching font-weight: '500' should prefer '500' over '450 460']
expected: FAIL
[Matching font-weight: '500' should prefer '450 460' over '400']
expected: FAIL
[Matching font-weight: '500' should prefer '400' over '350 399']
expected: FAIL
[Matching font-stretch: '100%' should prefer '100%' over '110% 120%']
expected: FAIL
@ -314,12 +251,6 @@
[Matching font-style: 'oblique -10deg' should prefer 'oblique -50deg -40deg' over 'italic']
expected: FAIL
[Matching font-weight: '430' should prefer '450 460' over '500']
expected: FAIL
[Matching font-weight: '399' should prefer '400' over '450 460']
expected: FAIL
[Matching font-style: 'oblique 10deg' should prefer 'oblique 10deg' over 'oblique 5deg']
expected: FAIL

View file

@ -14,15 +14,9 @@
[Test @font-face matching for weight 900]
expected: FAIL
[Test @font-face matching for weight 100]
expected: FAIL
[Test @font-face matching for weight 400]
expected: FAIL
[Test @font-face matching for weight 249]
expected: FAIL
[Test @font-face matching for weight 750]
expected: FAIL

View file

@ -1,2 +0,0 @@
[ex-unit-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[ex-unit-004.html]
expected: FAIL