File: font-weight-matching-installed-fonts.html

package info (click to toggle)
firefox-esr 68.10.0esr-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,143,932 kB
  • sloc: cpp: 5,227,879; javascript: 4,315,531; ansic: 2,467,042; python: 794,975; java: 349,993; asm: 232,034; xml: 228,320; sh: 82,008; lisp: 41,202; makefile: 22,347; perl: 15,555; objc: 5,277; cs: 4,725; yacc: 1,778; ada: 1,681; pascal: 1,673; lex: 1,417; exp: 527; php: 436; ruby: 225; awk: 162; sed: 53; csh: 44
file content (115 lines) | stat: -rw-r--r-- 3,960 bytes parent folder | download | duplicates (10)
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
115
<!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 -->
    <meta name="flags" content="font" />
    <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>