summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-font-loading/fontface-descriptor-updates.html
blob: 038b96da1e54654e1739e7034e1790c11c75a538 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html class=reftest-wait>
<meta charset=utf-8>
<title>CSS Font Loading test: modification of descriptors</title>
<link rel="author" title="Jonathan Kew" href="jkew@mozilla.com">
<link rel="help" href="https://drafts.csswg.org/css-font-loading/#fontface-interface">
<meta name="assert" content="If descriptors of a FontFace are modified, the new values should take effect">
<link rel="match" href="fontface-descriptor-updates-ref.html">
<style>
body { font-family: sans-serif; }
#test1 { font-family: test1, sans-serif; }
#test2 { font-family: test2, monospace; }
#test3 { font-family: test3, sans-serif; }
#test4 { font-family: test4, monospace; }
</style>
<script>
function run() {
  let f1 = new FontFace("test1", "url(resources/GenR102.woff2)");
  document.fonts.add(f1);
  let f2 = new FontFace("to_be_updated", "url(resources/GenR102.woff2)");
  document.fonts.add(f2);
  let f3 = new FontFace("test3", "url(resources/GenR102.woff2)", { weight: 700 });
  document.fonts.add(f3);
  let f4 = new FontFace("test3", "url(resources/GenI102.woff2)");
  document.fonts.add(f4);
  let f5 = new FontFace("test4", "url(resources/GenR102.woff2)", { unicodeRange: "U+002?" });
  document.fonts.add(f5);
  let f6 = new FontFace("test4", "url(resources/GenI102.woff2)", { unicodeRange: "U+00??" });
  document.fonts.add(f6);

  // Change family name to make f2 match #test2
  f2.family = "test2";

  // Swap weight descriptors so that f3 is regular and f4 (italic face) is regarded as bold
  f3.weight = 400;
  f4.weight = 700;

  // Update unicode-range so that f5 will be used for all characters in #test4
  f5.unicodeRange = "U+00??";
  f6.unicodeRange = "U+0000";

  document.fonts.ready.then(function() {
    document.documentElement.classList.remove("reftest-wait");
  })
}
</script>
<body onload="run()">
<div>
All lines below should use the same serif font, with the word "weight" in italics:
<p id=test1>Using original family name of a FontFace</p>
<p id=test2>Using updated family name of a FontFace</p>
<p id=test3>Using updated <b>weight</b> descriptors</p>
<p id=test4>Using updated unicode-range descriptors</p>
</div>
</body>
</html>