diff --git a/css-fonts-5/Overview.bs b/css-fonts-5/Overview.bs index 057512e97905..cef2b9895ebc 100644 --- a/css-fonts-5/Overview.bs +++ b/css-fonts-5/Overview.bs @@ -145,7 +145,7 @@ Issue(5892):

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

+the 'ascent-override', 'descent-override', 'line-gap-override', and 'advance-override' descriptors
 Name: ascent-override
@@ -168,9 +168,18 @@ For: @font-face
 Initial: normal
 
-The 'ascent-override', 'descent-override' and 'line-gap-override' descriptors define the +
+Name: advance-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. +line gap metric of the font, respectively. The 'advance-override' +descriptor adjusts the tracking between adjacent +typographic character units. When the descriptor value is 'normal', the corresponding metric value is obtained from the font file directly. @@ -178,9 +187,55 @@ 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 +For the 'ascent-override', 'descent-override' and 'line-gap-override' descriptors, 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. +For the 'advance-override' descriptor, when the descriptor value is a percentage, the +advance from one typographic character unit to the next is multiplied by the percentage. + +Note: Using the 'ascent-override', 'descent-override', and 'line-grap-override' descriptors can +achieve a similar effect as specifying a percentage for 'line-height' property. Also, using the +'advance-override' has a similar effect as using the 'letter-spacing' property. However, +contrary to 'letter-spacing', 'advance-override' scales the spacing, rather than adding a +constant to the spacing. + +Note: 'ascent-override', 'descent-override', 'line-gap-override', and 'advance-override' +are applied per-font rather than per-element. Multiple fonts may be used +within an individual element e.g. for characters not supported by the primary font. + +
+ Consider the following content: + + +@font-face { + font-family: "MyHelvetica"; + src: local("Helvetica"); +} +... +<div style="font: 96px 'MyHelvetica';">Ha</div> + + This image shows each glyph's local origin, and the natural advance between them: +
+ Natural advance of Helvetica glyphs +
+ In this example, the natural advance is 69.328125 pixels. + + However, if we modify the content as such: +
+@font-face {
+  font-family: "MyHelvetica";
+  src: local("Helvetica");
+  advance-override: 140%;
+}
+
+ The rendering will look like this: +
+ Overridden advance of Helvetica glyphs +
+ In this example, the used advance between the glyphs is 69.328125 pixels * 1.4 = 97.059375 pixels. +
+
The percentage is resolved against different font sizes for different elements. @@ -220,14 +275,16 @@ given percentage multiplied by the used font size. Negative values are invalid a ascent-override: 125%; descent-override: 25%; line-gap-override: 0%; + advance-override: 109%; } <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. + The image will not be shifted as much when the user agent finishes loading and + switches to use the web font (assuming the override values are similar to the web font's + natural metrics).
diff --git a/css-fonts-5/images/Helvetica Natural Advance.png b/css-fonts-5/images/Helvetica Natural Advance.png new file mode 100644 index 000000000000..89a2d81b0944 Binary files /dev/null and b/css-fonts-5/images/Helvetica Natural Advance.png differ diff --git a/css-fonts-5/images/Helvetica Overridden Advance.png b/css-fonts-5/images/Helvetica Overridden Advance.png new file mode 100644 index 000000000000..6598ac870c82 Binary files /dev/null and b/css-fonts-5/images/Helvetica Overridden Advance.png differ