first-available-font-001.html (1587B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS-fonts: first available font and the ex unit</title> 4 <link rel="author" title="Florian Rivoal" href="https://florian.rivoal.net"> 5 <link rel="help" href="https://drafts.csswg.org/css-fonts-3/#first-available-font"> 6 <link rel="help" href="https://drafts.csswg.org/css-fonts-4/#first-available-font"> 7 <link rel="match" href="first-available-font-001-ref.html"> 8 <meta name="assert" content="Fonts that do not include the U+0020 character are not considered the first available font (used to determine the ex unit), even when at the start of the font list."> 9 <style> 10 /* Two arbitrary fonts with different metrics */ 11 @font-face { 12 font-family: 'A-no-space'; 13 font-style: normal; 14 font-weight: 400; 15 src: url(/fonts/Revalia.woff) format('woff'); 16 unicode-range: U+0061; /* Not including U+0020, so it cannot be the first available font*/ 17 } 18 @font-face { 19 font-family: 'B'; 20 font-style: normal; 21 font-weight: 400; 22 src: url(/fonts/AD.woff) format('woff'); 23 } 24 25 div { 26 width: 1ex; 27 height: 0.5ex; 28 29 font-size: 200px; 30 background: blue; 31 position: absolute; 32 } 33 #t1 { font-family: 'B', sans-serif; margin-top: 0.5ex; } /* half a square, shifted down */ 34 #t2 { font-family: 'A-no-space', 'B', monospace; } /* Should use B as the first available font, and therefore be the same size as t1 */ 35 36 /* Both elements are using different generic fallback fonts, so that they end up being sized differently if web-fonts fail to load. */ 37 38 </style> 39 40 <p>Test passes if there is <strong>a blue square</strong> below. 41 42 <div id=t1></div> 43 <div id=t2></div>