Skip to content

Commit 195e439

Browse files
committed
[css-fonts-4] Refactor @font-feature-values grammar, improve autolinking, add more examples #9311
1 parent 05768ca commit 195e439

File tree

1 file changed

+50
-18
lines changed

1 file changed

+50
-18
lines changed

css-fonts-4/Overview.bs

+50-18
Original file line numberDiff line numberDiff line change
@@ -5629,20 +5629,29 @@ and be sure they're not accidentally turning on unrelated features
56295629

56305630
An ''@font-feature-values'' rule's prelude
56315631
contains a list of font family names,
5632-
followed by a block containing multiple <<feature-value-block>>s,
5632+
followed by a block containing multiple ''feature-value-block''s,
56335633
a special type of subsidiary at-rule.
5634-
Each <<feature-value-block>> contains declarations
5634+
Each ''feature-value-block''' contains declarations
56355635
mapping author-chosen human-friendly names
56365636
(such as "flowing")
56375637
to feature indexes for the associated feature.
56385638

5639-
<pre class=prod>
5640-
@font-feature-values <<family-name>># { <<declaration-rule-list>> }
5639+
Each <<font-feature-value>> has the same meaning
5640+
as the corresponding value of the 'font-variant-alternates' property.
56415641

5642-
<<feature-value-block>> = <<font-feature-value-type>> { <<declaration-list>> }
5642+
<pre class=prod export>
5643+
@font-feature-values = <<family-name>># { <<declaration-rule-list>> }
56435644
5644-
<<font-feature-value-type>> = @stylistic | @historical-forms | @styleset | @character-variant
5645-
| @swash | @ornaments | @annotation
5645+
<dfn for="@font-feature-values">font-feature-value-type</dfn> = <<@stylistic>> | <<@historical-forms>> | <<@styleset>> | <<@character-variant>>
5646+
| <<@swash>> | <<@ornaments>> | <<@annotation>>
5647+
5648+
<dfn for="@font-feature-values">@stylistic</dfn> = @stylistic { <<declaration-list>> }
5649+
<dfn for="@font-feature-values">@historical-forms</dfn> = @historical-forms { <<declaration-list>> }
5650+
<dfn for="@font-feature-values">@styleset</dfn> = @styleset { <<declaration-list>> }
5651+
<dfn for="@font-feature-values">@character-variant</dfn> = @character-variant { <<declaration-list>> }
5652+
<dfn for="@font-feature-values">@swash</dfn> = @swash { <<declaration-list>> }
5653+
<dfn for="@font-feature-values">@ornaments</dfn> = @ornaments { <<declaration-list>> }
5654+
<dfn for="@font-feature-values">@annotation</dfn> = @annotation { <<declaration-list>> }
56465655
</pre>
56475656

56485657
<wpt>
@@ -5664,9 +5673,11 @@ and must be ignored.
56645673
The ''@font-feature-values'' block accepts <<declaration-rule-list>> as its contents;
56655674
these list items are either:
56665675

5667-
[=at-rules=] named by one of the <<font-feature-value-type>> at-keyword tokens,
5676+
- [=at-rules=] named by one of the <<font-feature-value-type>> at-keyword tokens
5677+
56685678
or
5669-
the '@font-feature-values/font-display' descriptor.
5679+
5680+
- the '@font-feature-values/font-display' descriptor.
56705681

56715682
<!-- TODO: tab says "The OM needs to make sure it exposes both .style and .childRules or whatever." -->
56725683

@@ -5803,11 +5814,29 @@ specific additions made per-page.
58035814
Multi-valued feature value definitions</h4>
58045815

58055816
Most <em>font specific</em> functional values of the 'font-variant-alternates' property
5806-
take a single value (e.g. ''swash()'').
5807-
The ''character-variant()'' property value allows two values
5808-
and ''styleset()'' allows an unlimited number.
5817+
take a single value (e.g. ''swash()'') which enables the feature.
5818+
5819+
<pre class="example" id="ex-single-valued-feature" highlight=css>@font-feature-values Jupiter Serif {
5820+
5821+
@swash {
5822+
swishy: 5; /* implies ss05 = 1 */
5823+
swirly: 2; /* implies ss02 = 1 */
5824+
}
5825+
}
5826+
</pre>
58095827

5810-
For the styleset property value, multiple values indicate the style
5828+
The ''character-variant()'' property value and the ''@character-variant'' descriptor allow two values,
5829+
which enables a feature (from ther first value) and sets it to a given (second) value.
5830+
5831+
<pre class="example" id="ex-two-valued-feature" highlight=css>@font-feature-values MM Greek {
5832+
5833+
@character-variant { alpha-2: 1 2; } /* implies cv01 = 2 */
5834+
@character-variant { beta-3: 2 3; } /* implies cv02 = 3 */
5835+
}
5836+
</pre>
5837+
5838+
For the ''styleset()'' property value and ''@styleset'' rule,
5839+
multiple values indicate the style
58115840
sets to be enabled. Values between 1 and 99 enable OpenType features
58125841
<span class="tag">ss01</span> through <span class="tag">ss99</span>.
58135842
However, the OpenType standard only officially defines
@@ -5816,7 +5845,8 @@ Multi-valued feature value definitions</h4>
58165845
generate a syntax error when parsed but enable no OpenType features.
58175846

58185847

5819-
<pre class="example" id="ex-multi-valued-feature">@font-feature-values Mars Serif {
5848+
<pre class="example" id="ex-multi-valued-feature" highlight=css>@font-feature-values Mars Serif {
5849+
58205850
@styleset {
58215851
alt-g: 1; /* implies ss01 = 1 */
58225852
curly-quotes: 3; /* implies ss03 = 1 */
@@ -5837,7 +5867,7 @@ p.codeblock {
58375867
font-variant-alternates: styleset(curly-quotes, code);
58385868
}</pre>
58395869

5840-
For character-variant, a single value between 1 and 99 indicates
5870+
For <<@character-variant>>, a single value between 1 and 99 indicates
58415871
the enabling of OpenType feature <span class="tag">cv01</span> through
58425872
<span class="tag">cv99</span>. For OpenType fonts, values greater than
58435873
99 or equal to 0 are ignored but do not generate a syntax error when parsed
@@ -5848,7 +5878,8 @@ p.codeblock {
58485878
feature value definition</i> is
58495879
ignored.
58505880

5851-
<pre class="example" id="ex-greek-variant-features">@font-feature-values MM Greek {
5881+
<pre class="example" id="ex-greek-variant-features" highlight=css>@font-feature-values MM Greek {
5882+
58525883
@character-variant { alpha-2: 1 2; } /* implies cv01 = 2 */
58535884
@character-variant { beta-3: 2 3; } /* implies cv02 = 3 */
58545885
@character-variant { epsilon: 5 3 6; } /* more than 2 values, syntax error, definition ignored */
@@ -5883,7 +5914,8 @@ p {
58835914
a font without variants. Note the two variants for U and N used on the
58845915
seal.</p>
58855916

5886-
<pre>@font-feature-values Athena Ruby {
5917+
<pre highlight=css>@font-feature-values Athena Ruby {
5918+
58875919
@character-variant {
58885920
leo-B: 2 1;
58895921
leo-M: 13 3;
@@ -5897,7 +5929,7 @@ p {
58975929

58985930
p {
58995931
font-variant: discretionary-ligatures
5900-
character-variant(leo-B, leo-M, leo-N, leo-T, leo-U);
5932+
character-variant(leo-B, leo-M, leo-N, leo-T, leo-U);
59015933
}
59025934

59035935
span.alt-N {

0 commit comments

Comments
 (0)