Skip to content

Commit 439f4d2

Browse files
authored
Update Overview.bs
1 parent 0e4d361 commit 439f4d2

1 file changed

Lines changed: 38 additions & 13 deletions

File tree

css-fonts-4/Overview.bs

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,27 +2947,52 @@ When the descriptor value is a percentage, the corresponding metric value is res
29472947
given percentage multiplied by the used font size. Negative values are invalid at parse time.
29482948

29492949
<div class="example">
2950-
We may override the metrics of Arial as follows:
2950+
The percentage is resolved against different font sizes for different elements.
29512951

2952-
<pre>@font-face {
2953-
font-family: arial;
2954-
src: local(Arial), url("http://example.com/arial.woff");
2955-
ascent-override: 80%;
2956-
descent-override: 20%;
2957-
line-gap-override: 0%;
2952+
<pre>
2953+
@font-face {
2954+
font-family: overridden-font;
2955+
ascent-override: 50%;
2956+
...
29582957
}
2958+
2959+
&lt;span style="font-family: overridden-font; font-size: 20px;"&gt;
2960+
Outer span content
2961+
&lt;span style="font-size: 150%;"&gt;Inner span content&lt;/span&gt;
2962+
&lt;/span&gt;
29592963
</pre>
29602964

2961-
Then for an element with the following style:
2965+
The outer span uses an <a spec="CSS-INLINE-3" lt="ascent metric">ascent</a> value of
2966+
10px, whereas the inner span uses 15px.
2967+
2968+
</div>
2969+
2970+
<div class="example">
2971+
We may override the metrics of a local fallback font to match the primary font, which
2972+
is a web font. This reduces layout shifting when switching from fallback to the
2973+
primary font.
29622974

29632975
<pre>
2964-
font-family: arial;
2965-
font-size: 20px;
2966-
line-height: normal;
2976+
@font-face {
2977+
font-family: cool-web-font;
2978+
src: url("https://example.com/font.woff");
2979+
}
2980+
2981+
@font-face {
2982+
font-family: fallback-to-local;
2983+
src: local(Some Local Font);
2984+
/* Override metric values to match cool-web-font */
2985+
ascent-override: 125%;
2986+
descent-override: 25%;
2987+
line-gap-override: 0%;
2988+
}
2989+
2990+
&lt;div style="font-family: cool-web-font, fallback-to-local"&gt;Title goes here&lt;/div&gt;
2991+
&lt;img src="https://example.com/largeimage" alt="A large image that you don't want to shift"&gt;
29672992
</pre>
29682993

2969-
Each line box will be exactly 20px high. Text baseline will be positioned at 16px
2970-
below line box top.
2994+
The image will not be vertically shifted when the user agent finishes loading and
2995+
switches to use the web font.
29712996

29722997
</div>
29732998

0 commit comments

Comments
 (0)