| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>037 font-face</title>
- <style>
- @font-face {
- font-family: "Ladder Mono";
- src: url("/ramfs/fonts/mono.ttf") format("truetype");
- }
- @font-face {
- font-family: "Missing Face";
- src: url("/ramfs/fonts/does-not-exist.ttf") format("truetype");
- }
- html, body { margin: 0; padding: 0; background: #ffffff; color: #202020; }
- body { font-family: sans-serif; font-size: 13px; padding: 10px; }
- h1 { font-size: 20px; margin: 0 0 6px 0; }
- p { margin: 0 0 10px 0; }
- .pane { float: left; width: 440px; margin-left: 10px; }
- .label { background: #eeeeee; padding: 4px 6px; margin-bottom: 4px; }
- .box { width: 220px; background: #f4f4f4; border: 1px solid #999999; padding: 6px; }
- .custom { font-family: "Ladder Mono"; font-size: 15px; }
- .mono { font-family: monospace; font-size: 15px; }
- .missing { font-family: "Missing Face", sans-serif; font-size: 15px; }
- .plain { font-family: sans-serif; font-size: 15px; }
- #result { clear: both; margin-top: 14px; padding: 8px; background: #eeeeee; color: #000000; font-family: monospace; font-weight: bold; }
- </style>
- </head>
- <body>
- <h1>037 · @font-face</h1>
- <p>The custom face must load from the pack and measure like the built-in mono face; a missing URL must fall back to sans.</p>
- <div class="pane">
- <div class="label">A · @font-face</div>
- <div class="box"><span class="custom">The quick brown fox jumps over the lazy dog and the five boxing wizards jump quickly.</span></div>
- <div class="box" style="margin-top:8px"><span class="missing">Missing face falls back to the inherited sans text.</span></div>
- </div>
- <div class="pane">
- <div class="label">B · reference</div>
- <div class="box"><span class="mono">The quick brown fox jumps over the lazy dog and the five boxing wizards jump quickly.</span></div>
- <div class="box" style="margin-top:8px"><span class="plain">Missing face falls back to the inherited sans text.</span></div>
- </div>
- <p id="metrics" style="clear:both;margin-top:12px">checking...</p>
- <span id="custom-run" class="custom" style="display:inline-block">AVAVAVAVAV</span>
- <span id="mono-run" class="mono" style="display:inline-block">AVAVAVAVAV</span>
- <span id="missing-run" class="missing" style="display:inline-block">AVAVAVAVAV</span>
- <span id="plain-run" class="plain" style="display:inline-block">AVAVAVAVAV</span>
- <div id="result">checking...</div>
- <script>
- setTimeout(function () {
- var ca = document.getElementById('custom-run').getBoundingClientRect();
- var cb = document.getElementById('mono-run').getBoundingClientRect();
- var cm = document.getElementById('missing-run').getBoundingClientRect();
- var cp = document.getElementById('plain-run').getBoundingClientRect();
- var ok = Math.abs(ca.width - cb.width) <= 1 &&
- Math.abs(cm.width - cp.width) <= 1 &&
- ca.width > 0 && cb.width > 0;
- var msg = 'custom=' + Math.round(ca.width) + ' mono=' + Math.round(cb.width) +
- ' missing=' + Math.round(cm.width) + ' sans=' + Math.round(cp.width);
- var out = document.getElementById('result');
- out.textContent = ok ? 'PASS: @font-face metrics (' + msg + ')' :
- 'FAIL: @font-face metrics (' + msg + ')';
- out.style.background = ok ? '#ccffcc' : '#ffcccc';
- }, 600);
- </script>
- </body>
- </html>
|