diff --git a/css-fonts-4/Overview.bs b/css-fonts-4/Overview.bs index 647629823f9..2351cfffbcf 100644 --- a/css-fonts-4/Overview.bs +++ b/css-fonts-4/Overview.bs @@ -2908,6 +2908,94 @@ Initial: normal This descriptor defines initial settings that apply when the font defined by an @font-face rule is rendered. It does not affect font selection. Values are identical to those defined for the 'font-language-override!!property' property defined below except that the value inherit is omitted. When multiple font feature descriptors, properties, or variations are used, the cumulative effect on text rendering is detailed in the section [[#font-feature-variation-resolution]] below. +

+Default font metrics overriding: +the 'ascent-override', 'descent-override' and 'line-gap-override' descriptors

+ +
+Name: ascent-override
+Value: normal | <>
+For: @font-face
+Initial: normal
+
+ +
+Name: descent-override
+Value: normal | <>
+For: @font-face
+Initial: normal
+
+ +
+Name: line-gap-override
+Value: normal | <>
+For: @font-face
+Initial: normal
+
+ +The 'ascent-override', 'descent-override' and 'line-gap-override' descriptors define the +ascent metric, descent metric and +line gap metric of the font, respectively. + +When the descriptor value is 'normal', the corresponding metric value is obtained from the +font file directly. + +Note: User agents may draw data from different places from the font file as the metric values, +which results in different text layouts. + +When the descriptor value is a percentage, the corresponding metric value is resolved as the +given percentage multiplied by the used font size. Negative values are invalid at parse time. + +
+ The percentage is resolved against different font sizes for different elements. + +
+@font-face {
+  font-family: overridden-font;
+  ascent-override: 50%;
+  ...
+}
+
+<span style="font-family: overridden-font; font-size: 20px;">
+  Outer span content
+  <span style="font-size: 150%;">Inner span content</span>
+</span>
+
+ + The outer span uses an ascent value of + 10px, whereas the inner span uses 15px. + +
+ +
+ We may override the metrics of a local fallback font to match the primary font, which + is a web font. This reduces layout shifting when switching from fallback to the + primary font. + +
+@font-face {
+  font-family: cool-web-font;
+  src: url("https://example.com/font.woff");
+}
+
+@font-face {
+  font-family: fallback-to-local;
+  src: local(Some Local Font);
+  /* Override metric values to match cool-web-font */
+  ascent-override: 125%;
+  descent-override: 25%;
+  line-gap-override: 0%;
+}
+
+<div style="font-family: cool-web-font, fallback-to-local">Title goes here</div>
+<img src="https://example.com/largeimage" alt="A large image that you don't want to shift">
+
+ + The image will not be vertically shifted when the user agent finishes loading and + switches to use the web font. + +
+

Font Matching Algorithm

The algorithm below describes how fonts are associated with individual runs of text.