summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-fonts/variations/font-weight-matching-installed-fonts.html
blob: a290fb64fc40d576a89ee8bb68f540d10cfe5dd4 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html>
<head>
    <title>Testing new font-matching algorithm for font-weight values introduced in CSS Fonts level 4 (for system fonts)</title>
    <link rel="help" href="https://www.w3.org/TR/css-fonts-4/#font-matching-algorithm" />
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <!-- THIS TEST REQUIRES THAT YOU INSTALL THE [csstest-*.ttf] FONTS OF THE [resources] FOLDER -->
    <style>

        .testcase {
            float:left;
            margin: 5px;
            font-size:48pt;
            font-feature-settings: "kern" 1;
            color: rgba(0,0,0,0.5);
            background: linear-gradient(to left, lime 0%, lime 91px, red 91px);
        }

        @font-face {
            font-family: fontMatch;
            src: local('CSSTest Weights 900');
            font-weight: 100;
        }

        @font-face {
            font-family: fontMatch;
            src: local('CSSTest Weights 800');
            font-weight: 250;
        }

        @font-face {
            font-family: fontMatch;
            src: local('CSSTest Weights 700');
            font-weight: 400;
        }

        @font-face {
            font-family: fontMatch;
            src: local('CSSTest Weights 600');
            font-weight: 450;
        }

        @font-face {
            font-family: fontMatch;
            src: local('CSSTest Weights 300');
            font-weight: 500;
        }

        @font-face {
            font-family: fontMatch;
            src: local('CSSTest Weights 200');
            font-weight: 750;
        }

        @font-face {
            font-family: fontMatch;
            src: local('CSSTest Weights 100');
            font-weight: 900;
        }

    </style>
</head>
<body>

    <span style="position: absolute; top: -100vh;">
        <span style="font-family: fontMatch; font-weight: 100;">A</span>
        <span style="font-family: fontMatch; font-weight: 250;">A</span>
        <span style="font-family: fontMatch; font-weight: 400;">A</span>
        <span style="font-family: fontMatch; font-weight: 450;">A</span>
        <span style="font-family: fontMatch; font-weight: 500;">A</span>
        <span style="font-family: fontMatch; font-weight: 750;">A</span>
        <span style="font-family: fontMatch; font-weight: 900;">A</span>
    </span>

    <div id="testcases" style="overflow: hidden">
        <!--
            These testcases work using the new kerned CSSTest Weights fonts.
            The letter A and its corresponding numeric digit kern as one character.
        -->
        <div class="testcase" style="font-family:'CSSTest Weights W2569'; font-weight: 375;">
            A2
        </div>
        <div class="testcase" style="font-family:'CSSTest Weights Full'; font-weight: 375;">
            A3
        </div>
        <div class="testcase" style="font-family:'CSSTest Weights W1479'; font-weight: 475;">
            A4
        </div>
        <div class="testcase" style="font-family:'CSSTest Weights Full'; font-weight: 425;">
            A5
        </div>
        <div class="testcase" style="font-family:'CSSTest Weights Full'; font-weight: 525;">
            A6
        </div>
        <div class="testcase" style="font-family:'CSSTest Weights Full'; font-weight: 675;">
            A7
        </div>
        <br clear="all">
    </div>

    <script>

        var base_testcases = document.querySelectorAll('.testcase');
        for(var i = 0; i < base_testcases.length; i++) {
            test(
                assert => { assert_approx_equals(base_testcases[i].getBoundingClientRect().width, 90, 2, "@font-face should be mapped to " + base_testcases[i].style.fontFamily + "."); },
                "Test native font matching on " + base_testcases[i].style.fontFamily + " for weight " + base_testcases[i].style.fontWeight
            );
        }

    </script>
</body>
</html>