You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[css-fonts-4] Give clearer advice to authors about font-feature-settings and font-variation-settings (#7815)
This patch does a few things:
1. Fixes a small handful of whitespace / typo problems
2. Adds an example showing how the font-weight descriptor can accept a range
3. Advises authors to use high-level font-variant properties instead of font-feature-settings
4. Rewrites an example to follow the above advice
5. Advises authors to use high-level font properties instead of font-variation-settings
@@ -1063,7 +1063,7 @@ Font size: the 'font-size' property</h3>
1063
1063
Inherited: yes
1064
1064
Percentages: refer to parent element's font size
1065
1065
Computed value: an absolute length
1066
-
Animation type: by computed value type`
1066
+
Animation type: by computed value type
1067
1067
</pre>
1068
1068
1069
1069
<wpt>
@@ -2720,8 +2720,8 @@ Font property descriptors: the 'font-style!!descriptor', 'font-weight!!descripto
2720
2720
2721
2721
<pre>
2722
2722
@font-face {
2723
-
font-family: BaskervilleSimple;
2724
-
src: url(baskerville-regular.woff);
2723
+
font-family: BaskervilleSimple;
2724
+
src: url(baskerville-regular.woff2);
2725
2725
}
2726
2726
</pre>
2727
2727
@@ -2740,14 +2740,14 @@ Font property descriptors: the 'font-style!!descriptor', 'font-weight!!descripto
2740
2740
2741
2741
<pre>
2742
2742
@font-face {
2743
-
font-family: BaskervilleFull;
2744
-
src: url(baskerville-regular.woff);
2743
+
font-family: BaskervilleFull;
2744
+
src: url(baskerville-regular.woff2);
2745
2745
}
2746
2746
2747
2747
@font-face {
2748
-
font-family: BaskervilleFull;
2749
-
src: url(baskerville-italic.woff);
2750
-
font-style: italic;
2748
+
font-family: BaskervilleFull;
2749
+
src: url(baskerville-italic.woff2);
2750
+
font-style: italic;
2751
2751
}
2752
2752
</pre>
2753
2753
@@ -2767,6 +2767,40 @@ Font property descriptors: the 'font-style!!descriptor', 'font-weight!!descripto
2767
2767
to select a particular face within a font family.
2768
2768
</div>
2769
2769
2770
+
<div class="example" id="ex-descriptors-range">
2771
+
Fonts may advertise the range of 'font-weight!!property', 'font-stretch!!property', and 'font-style!!property' they are
2772
+
compatible with.
2773
+
<pre>
2774
+
@font-face {
2775
+
font-family: Lastima;
2776
+
src: url(lastima-varfont.woff2);
2777
+
font-weight: 100 399;
2778
+
}
2779
+
</pre>
2780
+
The above ''@font-face'' rule indicates that <code>lastima-varfont.woff</code> should be used when
2781
+
'font-weight!!property' is between 100 and 399. Depending on if there are any other ''@font-face'' rules which specify
2782
+
<code>font-family: Lastima</code>, <code>lastima-varfont.woff</code> might be used for values of 'font-weight!!property'
2783
+
outside of the 100 - 399 range. For more details, see the [[#font-matching-algorithm]].
2784
+
2785
+
As <a href="#ex-descriptors-matching">above</a>, multiple ''@font-face'' rules may be joined together into a single
2786
+
family, spanning multiple ranges of 'font-weight!!property', 'font-stretch!!property', and/or 'font-style!!property':
2787
+
<pre>
2788
+
@font-face {
2789
+
font-family: Lastima;
2790
+
src: url(lastima-varfont-lightrange.woff2);
2791
+
font-weight: 100 399;
2792
+
}
2793
+
@font-face {
2794
+
font-family: Lastima;
2795
+
src: url(lastima-varfont-heavyrange.woff2);
2796
+
font-weight: 400 700;
2797
+
}
2798
+
The above ''@font-face'' rules indicate that <code>lastima-varfont-lightrange.woff</code> should be used when
2799
+
'font-weight!!property' is between 100 and 399, whereas </code>lastima-varfont-heavyrange.woff</code> should be used when
2800
+
'font-weight!!property' is between 400 and 700.
2801
+
</pre>
2802
+
</div>
2803
+
2770
2804
<!--
2771
2805
██ ██ ████████ ███ ██ ██ ██████ ████████
2772
2806
██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██
@@ -5920,20 +5954,57 @@ to font features
5920
5954
that are not widely used
5921
5955
but are needed for a particular use case.
5922
5956
5923
-
<p class="advisement">Authors should generally
5924
-
use <span title="font-variant!!property">'font-variant!!property'</span>
5925
-
and its related subproperties
5926
-
whenever possible
5927
-
and only use this property
5928
-
for special cases
5929
-
where its use is the only way
5930
-
of accessing
5931
-
a particular infrequently used font feature.</p>
5932
-
5933
-
<div class="example" id="ex-small-caps-swash">
5934
-
<p>Enable small caps, and use second swash alternate</p>
5935
-
<pre>
5936
-
font-feature-settings: "smcp", "swsh" 2;</pre>
5957
+
<div class="advisement">Authors should <em>not</em> use
5958
+
<span title="font-feature-settings!!property">'font-feature-settings!!property'</span> to set any of the font features in
5959
+
the table below. Instead, please use the higher-level replacement properties, because:
5960
+
<ol>
5961
+
<li>The higher-level properties cascade individually. You can set one without setting the whole 'font-feature-settings!!property' list
5962
+
<li>Some higher-level properties can be synthesized for fonts that do not support the font feature.
5963
+
</ol>
5964
+
<table id="ffs-replacements" class="data">
5965
+
<thead>
5966
+
<tr>
5967
+
<th>If you want to set this font feature
5968
+
<th>then use this <em>instead of</em>'font-feature-settings!!property'
5969
+
<th>Notes
5970
+
<tbody>
5971
+
<tr><td>Kerning (<code>kern</code>) or Vertical Kerning (<code>vkrn</code>)<td>'font-kerning!!property': ''font-kerning/normal''<td>The 'font-kerning!!property' property will set the <code>kern</code> or <code>vkrn</code> feature depending on the 'writing-mode'.
5972
+
<tr><td>Standard Ligatures (<code>liga</code>) or Contextual Ligatures (<code>clig</code>)<td>'font-variant-ligatures!!property': ''font-variant-ligatures/common-ligatures''<td>
<tr><td>Slashed Zero (<code>zero</code>)<td>'font-variant-numeric!!property': ''font-variant-numeric/slashed-zero''<td>
5992
+
<tr><td>Historical Forms (<code>hist</code>)<td>'font-variant-alternates!!property': ''font-variant-alternates/historical-forms''<td>
5993
+
<tr><td>Stylistic Alternates (<code>salt</code>)<td>'font-variant-alternates!!property': ''font-variant-alternates/stylistic()''<td>Define which alternate gets used by making an ''@font-feature-values'' rule
5994
+
<tr><td>Character Variant 1 - Character Variant 99 (<code>cv01</code> - <code>cv99</code>)<td>'font-variant-alternates!!property': ''font-variant-alternates/character-variant()''<td>Define which character variant gets used by making an ''@font-feature-values'' rule
5995
+
<tr><td>Swash (<code>swsh</code>) or Contextual Swash (<code>cswh</code>)<td>'font-variant-alternates!!property': ''font-variant-alternates/swash()''<td>Define which swash gets used by making an ''@font-feature-values'' rule
5996
+
<tr><td>Ornaments (<code>ornm</code>)<td>'font-variant-alternates!!property': ''font-variant-alternates/ornaments()''<td>Define which ornament gets used by making an ''@font-feature-values'' rule
5997
+
<tr><td>Alternate Annotation Forms (<code>nalt</code>)<td>'font-variant-alternates!!property': ''font-variant-alternates/annotation()''<td>Define which annotation gets used by making an ''@font-feature-values'' rule
5998
+
<tr><td>JIS78 Forms (<code>jp78</code>)<td>'font-variant-east-asian!!property': ''font-variant-east-asian/jis78''<td>
5999
+
<tr><td>JIS83 Forms (<code>jp83</code>)<td>'font-variant-east-asian!!property': ''font-variant-east-asian/jis83''<td>
6000
+
<tr><td>JIS90 Forms (<code>jp90</code>)<td>'font-variant-east-asian!!property': ''font-variant-east-asian/jis90''<td>
6001
+
<tr><td>JIS2004 Forms (<code>jp04</code>)<td>'font-variant-east-asian!!property': ''font-variant-east-asian/jis04''<td>
6002
+
<tr><td>Simplified Forms (<code>smpl</code>)<td>'font-variant-east-asian!!property': ''font-variant-east-asian/simplified''<td>
6003
+
<tr><td>Traditional Forms (<code>trad</code>)<td>'font-variant-east-asian!!property': ''font-variant-east-asian/traditional''<td>
font-feature-settings: dlig; /* invalid, tag must be a string */
6109
+
font-feature-settings: sinf; /* invalid, tag must be a string */
6039
6110
</pre>
6040
6111
</div>
6041
6112
@@ -6578,6 +6649,27 @@ over OpenType or TrueType font variations.
6578
6649
It is intended as a way of providing access to font variations
6579
6650
that are not widely used but are needed for a particular use case.
6580
6651
6652
+
<div class="advisement">Authors should <em>not</em> use
6653
+
<span title="font-variation-settings!!property">'font-variation-settings!!property'</span> to set any of the variation axes in
6654
+
the table below. Instead, please use the higher-level replacement properties, because:
6655
+
<ol>
6656
+
<li>The higher-level properties cascade individually. You can set one without setting the whole 'font-variation-settings!!property' list
6657
+
<li>Some higher-level properties can be synthesized for fonts that do not support the font variation.
6658
+
</ol>
6659
+
<table id="fvs-replacements" class="data">
6660
+
<thead>
6661
+
<tr>
6662
+
<th>If you want to set this variation axis
6663
+
<th>then use this <em>instead of</em>'font-variation-settings!!property'
6664
+
<th>Notes
6665
+
<tbody>
6666
+
<tr><td>Weight (<code>wght</code>)<td>'font-weight!!property'<td>The 'font-weight!!property' property will set the <code>wght</code> axis if one is present.
6667
+
<tr><td>Width (<code>wdth</code>)<td>'font-stretch!!property'<td>The 'font-stretch!!property' property will set the <code>wdth</code> axis if one is present.
6668
+
<tr><td>Slant (<code>slnt</code>) or Italic (<code>ital</code>)<td>'font-style!!property'<td>The 'font-style!!property' property will set the <code>slnt</code> or <code>ital</code> axis, depending on its value.
6669
+
<tr><td>Optical size (<code>opsz</code>)<td>'font-optical-sizing!!property'<td>The 'font-optical-sizing!!property' property will set the <code>opsz</code> axis if one is present.
6670
+
</table>
6671
+
</div>
6672
+
6581
6673
The use of font variation settings
6582
6674
does not affect font selection
6583
6675
where a fallback font is to be used,
@@ -6986,7 +7078,7 @@ User-defined font color palettes: The ''@font-palette-values'' rule</h3>
6986
7078
6987
7079
Note: In the case where a family name is shared
6988
7080
between multiple physical fonts,
6989
-
(such as when a compound font is created, using `unicode-range`),
7081
+
(such as when a compound font is created, using 'unicode-range!!descriptor'),
0 commit comments