Bug 1681691 - Adjust font-family names used in WPT metrics-override tests to avoid spurious failures due to antialiasing in Gecko. r=emilio

Many WPT reftests compare Ahem glyphs (squares) with a reference that uses simple shapes
such as a <div> with a solid background that is expected to have the exact same size.

If antialiasing is applied to the Ahem font, such tests will often fail because of
faint antialiasing pixels at the edges of the square glyphs, even though the test is
"passing" in terms of what it actually aims to check.

Rather than annotate all such tests as "fuzzy", Gecko has an option to disable antialiasing
for the Ahem font, despite it being enabled for font rendering in general, and we use this
when running the WPT reftests. However, this depends on the font-family name being exactly
"Ahem".

Therefore, in the tests which load Ahem via @font-face and override some descriptors,
we still want to use "Ahem" as the resulting family name (shadowing the standard Ahem,
if it is locally installed) so that the non-antialiased rendering will be used.

(In the case of metrics-override-normal-keyword, there are multiple "custom" versions
of Ahem loaded by the testcase, so we instead take the approach of also loading it with
a modified family name in the reference; then both testcase and reference will get
the default antialiased font rendering rather than special "Ahem" treatment.)

Differential Revision: https://phabricator.services.mozilla.com/D109290
This commit is contained in:
Jonathan Kew 2021-03-23 08:37:08 +00:00
Родитель 31e403716c
Коммит 6db7978dac
6 изменённых файлов: 19 добавлений и 10 удалений

Просмотреть файл

@ -5,7 +5,7 @@
<link rel="match" href="fontface-override-descriptors-ref.html">
<script>
const face = new FontFace(
'ahem-overridden',
'Ahem',
'local("Ahem"), url("/fonts/Ahem.ttf")',
{ascentOverride: '100%', descentOverride: '100%', lineGapOverride: '100%'});
document.fonts.add(face);
@ -18,7 +18,7 @@ document.fonts.add(face);
<style>
#target {
position: absolute;
font-family: ahem-overridden;
font-family: Ahem;
font-size: 20px;
}
</style>

Просмотреть файл

@ -6,7 +6,7 @@
<title>Tests the ascent-override and descent-override descriptors of @font-face</title>
<style>
@font-face {
font-family: custom-font;
font-family: Ahem;
src: local(Ahem), url(/fonts/Ahem.ttf);
/* The default ascent and descent are 80% and 20%, respectively. */
ascent-override: 100%;
@ -14,7 +14,7 @@
}
.target {
font: 20px custom-font;
font: 20px Ahem;
color: green;
position: absolute;
top: 10px;

Просмотреть файл

@ -1,6 +1,6 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Tests the ascent-override and descent-override descriptors of @font-face</title>
<title>Tests the line-gap-override descriptor of @font-face</title>
<style>
.target {
position: absolute;

Просмотреть файл

@ -6,13 +6,13 @@
<title>Tests the line-gap-override descriptor of @font-face</title>
<style>
@font-face {
font-family: custom-font;
font-family: Ahem;
src: local(Ahem), url(/fonts/Ahem.ttf);
line-gap-override: 100%;
}
.target {
font: 20px custom-font;
font: 20px Ahem;
color: green;
position: absolute;
top: 10px;

Просмотреть файл

@ -5,8 +5,15 @@
<link rel="stylesheet" href="/fonts/ahem.css">
<title>Tests the 'normal' keyword on descriptors ascent-override, descent-override and line-gap-override</title>
<div style="font-family: Ahem">Test<br>Test</div>
<style>
@font-face {
font-family: reference-font;
src: local(Ahem), url(/fonts/Ahem.ttf);
}
</style>
<div style="font-family: Ahem">Test<br>Test</div>
<div style="font-family: reference-font">Test<br>Test</div>
<div style="font-family: Ahem">Test<br>Test</div>
<div style="font-family: reference-font">Test<br>Test</div>
<div style="font-family: reference-font">Test<br>Test</div>

Просмотреть файл

@ -747,6 +747,8 @@ AHEM SYSTEM FONT: resource-timing/resources/all_resource_types.htm
AHEM SYSTEM FONT: resource-timing/resources/iframe-reload-TAO.sub.html
AHEM SYSTEM FONT: html/canvas/element/drawing-text-to-the-canvas/2d.text.measure.fontBoundingBox.ahem.html
AHEM SYSTEM FONT: css/css-font-loading/fontface-override-descriptors.html
AHEM SYSTEM FONT: css/css-fonts/ascent-descent-override.html
AHEM SYSTEM FONT: css/css-fonts/line-gap-override.html
# TODO: The following should be deleted along with the Ahem web font cleanup
# PR (https://github.com/web-platform-tests/wpt/pull/18702)