074-font-variants.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>074 font-face variants</title>
  6. <style>
  7. /* The regular face lists WOFF2 first (unsupported, skipped) and a WOFF 1.0
  8. * copy of the built-in mono face second. */
  9. @font-face {
  10. font-family: "Ladder Var";
  11. src: local("Ladder Var"), url("ladder-mono.woff2") format("woff2"),
  12. url("ladder-mono.woff") format("woff");
  13. }
  14. /* The bold face of the same family is the built-in sans bold. */
  15. @font-face {
  16. font-family: "Ladder Var";
  17. font-weight: 700;
  18. src: url("ladder-sans-b.ttf") format("truetype");
  19. }
  20. /* A non-Latin subset with the same family/weight/style must not replace
  21. * the regular face (Google Fonts lists latin last). */
  22. @font-face {
  23. font-family: "Ladder Var";
  24. unicode-range: U+0400-045F, U+0490-0491;
  25. src: url("does-not-exist-cyrillic.ttf") format("truetype");
  26. }
  27. /* Never referenced: must not be fetched (check the [font] log). */
  28. @font-face {
  29. font-family: "Never Used";
  30. src: url("never-used.ttf") format("truetype");
  31. }
  32. html, body { margin: 0; padding: 0; background: #ffffff; color: #202020; }
  33. body { font-family: sans-serif; font-size: 13px; padding: 10px; }
  34. h1 { font-size: 20px; margin: 0 0 6px 0; }
  35. p { margin: 0 0 10px 0; }
  36. .pane { float: left; width: 440px; margin-left: 10px; }
  37. .label { background: #eeeeee; padding: 4px 6px; margin-bottom: 4px; }
  38. .box { width: 400px; background: #f4f4f4; border: 1px solid #999999; padding: 6px; margin-bottom: 8px; }
  39. .var { font-family: "Ladder Var", sans-serif; font-size: 15px; }
  40. .var-b { font-family: "Ladder Var", sans-serif; font-size: 15px; font-weight: bold; }
  41. .short { font: 15px "Ladder Var", sans-serif; }
  42. .mono { font-family: monospace; font-size: 15px; }
  43. .sans-b { font-family: sans-serif; font-size: 15px; font-weight: bold; }
  44. #result { clear: both; margin-top: 14px; padding: 8px; background: #eeeeee; color: #000000; font-family: monospace; font-weight: bold; }
  45. </style>
  46. </head>
  47. <body>
  48. <h1>074 &middot; @font-face variants</h1>
  49. <p>One family with a WOFF regular face and a TTF bold face; the font shorthand names the family too. Each A row must look like its B row.</p>
  50. <div class="pane">
  51. <div class="label">A &middot; "Ladder Var"</div>
  52. <div class="box"><span class="var">Regular: the quick brown fox 0123</span></div>
  53. <div class="box"><span class="var-b">Bold: the quick brown fox 0123</span></div>
  54. <div class="box"><span class="short">Shorthand: the quick brown fox 0123</span></div>
  55. </div>
  56. <div class="pane">
  57. <div class="label">B &middot; reference</div>
  58. <div class="box"><span class="mono">Regular: the quick brown fox 0123</span></div>
  59. <div class="box"><span class="sans-b">Bold: the quick brown fox 0123</span></div>
  60. <div class="box"><span class="mono">Shorthand: the quick brown fox 0123</span></div>
  61. </div>
  62. <div id="result">checking...</div>
  63. <script>
  64. /* The font rendering itself is the A/B comparison above (A must look like
  65. * B row by row). The script checks the CSS Font Loading API surface. */
  66. setTimeout(function () {
  67. var ok = typeof FontFace === 'function' &&
  68. new FontFace('X', 'url(x.ttf)').status === 'loaded' &&
  69. document.fonts.size === 0 &&
  70. document.fonts.check('15px "Ladder Var"') &&
  71. typeof document.fonts.ready.then === 'function';
  72. var out = document.getElementById('result');
  73. out.textContent = (ok ? 'PASS' : 'FAIL') + ': FontFace / document.fonts API';
  74. out.style.background = ok ? '#ccffcc' : '#ffcccc';
  75. }, 300);
  76. </script>
  77. </body>
  78. </html>