Skip to content

Commit a023194

Browse files
authored
Add font metric override descriptors
1 parent de7e973 commit a023194

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

css-fonts-4/Overview.bs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,6 +2908,68 @@ Initial: normal
29082908

29092909
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.
29102910

2911+
<h3 id="font-metrics-override-desc">
2912+
Default font metrics overriding:
2913+
the 'ascent-override', 'descent-override' and 'line-gap-override' descriptors</h3>
2914+
2915+
<pre class='descdef'>
2916+
Name: ascent-override
2917+
Value: normal | <<percentage>>
2918+
For: @font-face
2919+
Initial: normal
2920+
</pre>
2921+
2922+
<pre class='descdef'>
2923+
Name: descent-override
2924+
Value: normal | <<percentage>>
2925+
For: @font-face
2926+
Initial: normal
2927+
</pre>
2928+
2929+
<pre class='descdef'>
2930+
Name: line-gap-override
2931+
Value: normal | <<percentage>>
2932+
For: @font-face
2933+
Initial: normal
2934+
</pre>
2935+
2936+
These 'ascent-override', 'descent-override' and 'line-gap-override' descriptors define the values
2937+
of the ascent, descent and line gap metrics of the font.
2938+
2939+
When the descriptor value is 'normal', the metric value is obtained from the font file directly.
2940+
2941+
Note: User agents may choose different pieces of data from the font file as the metric value,
2942+
leading to different layouts. For example, Chrome on Windows uses sTypoAscender, sTypoDescender
2943+
and sTypoLineGap from the font's OS/2 table, while on Mac, it uses those in the HHEA table if available.
2944+
2945+
When the descriptor value is a percentage, the metric value is set to the given percentage of the
2946+
em size of the font.
2947+
2948+
<div class="example">
2949+
We may override the metrics of Arial as follows:
2950+
2951+
<pre>@font-face {
2952+
font-family: arial;
2953+
src: local(Arial), url("http://example.com/arial.woff");
2954+
ascent-override: 60%;
2955+
descent-override: 40%;
2956+
line-gap-override: 0%;
2957+
}
2958+
</pre>
2959+
2960+
Then for an element with the following style:
2961+
2962+
<pre>
2963+
font-family: arial;
2964+
font-size: 20px;
2965+
line-height: normal;
2966+
</pre>
2967+
2968+
Each line box will be exactly 20px high. Text baseline will be positioned at 12px
2969+
below line box top.
2970+
2971+
</div>
2972+
29112973
<h2 id="font-matching-algorithm">Font Matching Algorithm</h2>
29122974

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

0 commit comments

Comments
 (0)