Skip to content

Commit 309c5a4

Browse files
committed
[css-fonts-4] Add the font-named-instance descriptor
w3c#525
1 parent d08e4ee commit 309c5a4

1 file changed

Lines changed: 122 additions & 72 deletions

File tree

css-fonts-4/Overview.bs

Lines changed: 122 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -211,29 +211,8 @@ Relationship Between Faces and Families
211211
font families with a variety of weights, widths, and slopes
212212
(see [[#platform-props-to-css]] for more details).
213213

214-
Some font file formats allow
215-
font faces to carry multiple localizations
216-
of the family name.
217-
User agents must recognize and correctly match all of these names
218-
independent of the underlying platform localization,
219-
system API used, or document encoding.
220-
221-
<div class="example">
222-
For example,
223-
for each of the fonts listed below,
224-
the author can use either the Latin name
225-
or the localized name
226-
in the 'font-family!!property' property,
227-
and the results will be identical on all systems:
228-
<figure>
229-
<img alt="examples of localized family names" src="images/localizedfamilynames.png" >
230-
<figcaption>Localized family names</figcaption>
231-
</figure>
232-
</div>
233-
234-
The details of localized font family name matching
235-
and the corresponding issues of case sensitivity
236-
are described below in [[#font-family-casing]].
214+
See [[#localized-name-matching]] below for information on how
215+
font-family names are matched.
237216

238217
<h4 id="generic-font-families">
239218
Generic font families</h4>
@@ -2130,7 +2109,7 @@ by the underlying font.
21302109

21312110
<h4 id="composite-fonts">Using character ranges to define composite fonts</h4>
21322111

2133-
Multiple <code>@font-face</code> rules with different unicode ranges for the same
2112+
Multiple ''@font-face'' rules with different unicode ranges for the same
21342113
family and style descriptor values can be used to create composite fonts
21352114
that mix the glyphs from different fonts for different scripts. This
21362115
can be used to combine fonts that only contain glyphs for a single
@@ -2139,7 +2118,7 @@ way of segmenting a font into fonts for commonly used characters and
21392118
less frequently used characters. Since the user agent will only pull
21402119
down the fonts it needs this helps reduce page bandwidth.
21412120

2142-
If the unicode ranges overlap for a set of <code>@font-face</code> rules with the
2121+
If the unicode ranges overlap for a set of ''@font-face'' rules with the
21432122
same family and style descriptor values, the rules are ordered in the
21442123
reverse order they were defined; the last rule defined is the first to
21452124
be checked for a given character.
@@ -2162,7 +2141,7 @@ Example ranges for specific languages or characters:
21622141

21632142
<div class="example">
21642143
The BBC provides news services in a wide variety of languages, many
2165-
that are not well supported across all platforms. Using an <code>@font-face</code>
2144+
that are not well supported across all platforms. Using an ''@font-face''
21662145
rule, the BBC could provide a font for any of these languages, as it
21672146
already does via a manual font download.</p>
21682147
<pre>
@@ -2266,7 +2245,7 @@ body { font-family: DroidSans; }
22662245
Next, the user agent evaluates the Japanese font. The unicode-range for
22672246
the Japanese font, U+3000-9FFF and U+ff??, does not include U+21E8, so
22682247
the user agent does not download the Japanese font.
2269-
Next the fallback font is considered. The <code>@font-face</code> rule for the
2248+
Next the fallback font is considered. The ''@font-face'' rule for the
22702249
fallback font does not define unicode-range so its value defaults to
22712250
the range of all Unicode code points. The fallback font is downloaded and
22722251
used to render the arrow character.
@@ -2308,28 +2287,80 @@ For: @font-face
23082287
</pre>
23092288

23102289
These descriptors define initial settings that apply when the font defined by
2311-
an <code>@font-face</code> rule is rendered. They do not affect font selection.
2290+
an ''@font-face'' rule is rendered. They do not affect font selection.
23122291
Values are identical to those defined for the corresponding
23132292
'font-variant!!property', 'font-feature-settings!!property', and
23142293
'font-variation-settings!!property' properties defined below
2315-
except that the <a>CSS-wide keywords</a> are omitted. When multiple font
2316-
feature descriptors, properties, or variations are used, the cumulative effect on
2294+
except that the <a>CSS-wide keywords</a> are omitted. When multiple font
2295+
feature descriptors, properties, or variations are used, optionally along with a named instance,
2296+
the cumulative effect on
23172297
text rendering is detailed in the section
2318-
<a href="#font-feature-variation-resolution">Font Feature and Variation Resolution</a> below.
2298+
[[#font-feature-variation-resolution]] below.
23192299
In cases where specific values define synthesized fallback for certain
23202300
'font-variant!!property' subproperties, the same synthesized fallback
23212301
applies when used within those values are used with the
23222302
'font-variant!!descriptor' descriptor.
23232303

2304+
These descriptors set features and variation values
2305+
on the font object which the ''@font-face'' rule represents,
2306+
rather than on an entire element.
2307+
Therefore, when using these descriptors,
2308+
only some glyphs in an element may be rendered with that feature,
2309+
due to [[#cluster-matching]].
2310+
2311+
<h3 id="font-named-instance">Using named instances from variable fonts: the 'font-named-instance!!descriptor' descriptor</h3>
2312+
2313+
<pre class='descdef'>
2314+
Name: font-named-instance
2315+
Value: auto | <string>
2316+
Initial: auto
2317+
For: @font-face
2318+
</pre>
2319+
2320+
If the 'font-named-instance!!descriptor' descriptor is set
2321+
to a value other than 'font-named-instance/auto',
2322+
then the appropriate stage in the [[#font-feature-variation-resolution]]
2323+
will inspect the font file to find the first named instance in
2324+
the font which has a localized name equal to the given <string>
2325+
according to the rules given in [[#localized-name-matching]].
2326+
If no such named instance exists,
2327+
this descriptor is treated as if it has a value of 'font-named-instance/auto'.
2328+
Otherwise, this named instance's variation axis values
2329+
are applied a this position in the [[#font-feature-variation-resolution]].
2330+
2331+
<div class="example">
2332+
For example, the following ''@font-face'' block will
2333+
apply the instance named "Grotesque"
2334+
but will override the "XHGT" axis to have a value of 0.7.
2335+
2336+
<pre>
2337+
@font-face {
2338+
font-family: "AccuroVar";
2339+
src: url("accurovar.otf") format("opentype");
2340+
font-named-instance: "Grotesque";
2341+
font-variation-settings: "XHGT" 0.7;
2342+
}
2343+
</pre>
2344+
</div>
2345+
2346+
Note: Because the variation axis values supplied in the
2347+
'font-weight!!property', 'font-stretch!!property', and 'font-style!!property' properties
2348+
are applied before
2349+
the value in the 'font-named-instance!!descriptor' descriptor,
2350+
there is no need to change the value of those properties
2351+
when a named instance is desired.
2352+
2353+
<h3 id="font-requests">Font request guidelines</h3>
2354+
23242355
<h4 id="font-face-loading">Font loading guidelines</h4>
23252356

2326-
The <code>@font-face</code> rule is designed to allow lazy loading
2357+
The ''@font-face'' rule is designed to allow lazy loading
23272358
of font resources that are only downloaded when used within a
2328-
document. A stylesheet can include <code>@font-face</code> rules for
2359+
document. A stylesheet can include ''@font-face'' rules for
23292360
a library of fonts of which only a select set are used; user agents
23302361
must only download those fonts that are referred to within the style
2331-
rules applicable to a given page. User agents that download all fonts
2332-
defined in <code>@font-face</code> rules without considering whether
2362+
rules applicable to a given page. User agents that download all fonts
2363+
defined in ''@font-face'' rules without considering whether
23332364
those fonts are in fact used within a page are considered
23342365
non-conformant. In cases where a font might be downloaded in character
23352366
fallback cases, user agents may download a font if it's contained within
@@ -2353,13 +2384,10 @@ h2 {
23532384
}
23542385
</pre>
23552386

2356-
In cases where textual content is loaded before downloadable fonts
2357-
are available, user agents may render text as it would be rendered if
2358-
downloadable font resources are not available or they may render text
2359-
transparently with fallback fonts to avoid a flash of text using a
2360-
fallback font. In cases where the font download fails user agents must
2361-
display text, simply leaving transparent text is considered
2362-
non-conformant behavior. Authors are advised to use fallback fonts in
2387+
In cases where textual content is loaded before downloadable fonts are available,
2388+
user agents must render text according to the 'font-display!!descriptor' descriptor of that ''@font-face'' block.
2389+
In cases where the font download fails, user agents must
2390+
display the text visibly. Authors are advised to use fallback fonts in
23632391
their font lists that closely match the metrics of the
23642392
downloadable fonts to avoid large page reflows where possible.
23652393

@@ -2597,7 +2625,7 @@ For: @font-face
25972625
Initial: normal
25982626
</pre>
25992627

2600-
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 and Variation Resolution below.
2628+
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.
26012629

26022630
<h2 id="font-matching-algorithm">Font Matching Algorithm</h2>
26032631

@@ -2607,12 +2635,29 @@ a font family is chosen
26072635
and a particular font face is selected
26082636
containing a glyph for that character.
26092637

2610-
<h3 id="font-family-casing">Case sensitivity of font family names</h3>
2638+
<h3 id="localized-name-matching">Localized name matching</h3>
2639+
2640+
Some font file formats allow
2641+
font faces to carry multiple localizations
2642+
of a particular string
2643+
(e.g. family name or named instance).
2644+
User agents must recognize and correctly match all of these names
2645+
independent of the underlying platform localization,
2646+
system API used, or document encoding.
2647+
2648+
<div class="example">
2649+
For example,
2650+
for each of the fonts listed below,
2651+
the author can use either the Latin name
2652+
or the localized name
2653+
in the 'font-family!!property' property,
2654+
and the results will be identical on all systems:
2655+
<figure>
2656+
<img alt="examples of localized family names" src="images/localizedfamilynames.png" >
2657+
<figcaption>Localized family names</figcaption>
2658+
</figure>
2659+
</div>
26112660

2612-
As part of the font matching algorithm outlined below,
2613-
user agents must match font family names used in style rules
2614-
with actual font family names contained in fonts available in a given environment
2615-
or with font family names defined in ''@font-face'' rules.
26162661
User agents must match these names case insensitively,
26172662
using the "Default Caseless Matching" algorithm outlined in the Unicode specification [[!UNICODE]].
26182663
This algorithm is detailed in section 3.13 entitled "Default Case Algorithms".
@@ -2685,11 +2730,9 @@ if all font style properties were set to their initial value.
26852730
3. For other family names, the user agent attempts to find the
26862731
family name among fonts defined via ''@font-face'' rules and then
26872732
among available installed fonts, matching names with a
2688-
<a href="#font-family-casing">case-insensitive comparison</a> as outlined
2733+
[[#localized-name-matching]] as outlined
26892734
in the section above.
2690-
On systems containing fonts with multiple localized font family
2691-
names, user agents must match any of these names independent of the
2692-
underlying system locale or platform API used. If the font
2735+
If the font
26932736
resources defined for a given face in an ''@font-face'' rule are either
26942737
not available or contain invalid font data, then the face should be
26952738
treated as not present in the family. If no faces are present for a
@@ -2709,8 +2752,7 @@ if all font style properties were set to their initial value.
27092752
before any layout or rendering occurs. The application of these values
27102753
must be applied in the <a href="#apply-font-matching-variations">Apply
27112754
font matching variations</a> step detailed in
2712-
<a href="#font-feature-variation-resolution">Font Feature and Variation
2713-
Resolution</a>.
2755+
[[#font-feature-variation-resolution]].
27142756
A group
27152757
of faces defined via ''@font-face'' rules with identical font
27162758
descriptor values but differing 'unicode-range' values are considered to be
@@ -3860,16 +3902,16 @@ resolved in the order below, in ascending order of precedence. This ordering is
38603902
used to construct a combined list of font features that affect a given
38613903
text run.
38623904

3863-
1. Font features enabled by default, including features required for a given script.
3905+
1. Font features enabled by default are applied, including features required for a given script.
38643906

38653907
2. <span id="apply-font-matching-variations">Font variations as enabled by the 'font-weight!!property',
3866-
'font-stretch!!property', and 'font-style!!property' properties.</span>
3908+
'font-stretch!!property', and 'font-style!!property' properties are applied.</span>
38673909

38683910
The application of the value enabled by
38693911
'font-style!!property' is affected by font selection, because this property might select an
38703912
italic or an oblique font. The value applied is the closest matching value as determined
38713913
by the <a href="#font-style-matching">font matching algorithm</a>. User Agents must apply
3872-
at most one value due to the 'font-style!!property' property; both "ital" and "slnt" values should
3914+
at most one value due to the 'font-style!!property' property; both "ital" and "slnt" values must
38733915
not be set together.
38743916

38753917
If the selected font is defined in an ''@font-face'' rule, then the values applied at this step
@@ -3880,40 +3922,48 @@ text run.
38803922
Then, the values applied in this step should be clamped (possibly again) to the values
38813923
that are supported by the font.
38823924

3883-
3. The language specified by the inherited value of lang/xml:lang
3925+
3. The language specified by the inherited value of lang/xml:lang is applied.
38843926

38853927
4. If the font is defined via an ''@font-face'' rule, the font language override
3886-
implied by the 'font-language-override!!descriptor' descriptor in the ''@font-face'' rule.
3928+
implied by the 'font-language-override!!descriptor' descriptor in the ''@font-face'' rule are applied.
3929+
3930+
5. If the font is defined via an ''@font-face'' rule, that ''@font-face'' rule includes
3931+
at least one valid 'font-named-instance' descriptor
3932+
with a value other than 'font-named-instance/none',
3933+
and the loaded font resource includes a named instance with that name
3934+
according to the [[#localized-name-matching]] rules,
3935+
then all the variation values represented by that named instance are applied.
3936+
These values are clamped to the values that are supported by the font.
38873937

3888-
5. If the font is defined via an ''@font-face'' rule, the font variations
3889-
implied by the 'font-variation-settings!!descriptor' descriptor in the ''@font-face'' rule.
3938+
6. If the font is defined via an ''@font-face'' rule, the font variations
3939+
implied by the 'font-variation-settings!!descriptor' descriptor in the ''@font-face'' rule are applied.
38903940

3891-
6. If the font is defined via an ''@font-face'' rule, the font features
3892-
implied by the 'font-feature-settings!!descriptor' descriptor in the ''@font-face'' rule.
3941+
7. If the font is defined via an ''@font-face'' rule, the font features
3942+
implied by the 'font-feature-settings!!descriptor' descriptor in the ''@font-face'' rule are applied.
38933943

3894-
7. The font language override implied by the value of the 'font-language-override!!property' property.
3944+
8. The font language override implied by the value of the 'font-language-override!!property' property is applied.
38953945

3896-
8. Font variations implied by the value of the 'font-optical-sizing!!property' property.
3946+
9. Font variations implied by the value of the 'font-optical-sizing!!property' property are applied.
38973947

3898-
9. Font features implied by the value of the 'font-variant!!property' property,
3948+
10. Font features implied by the value of the 'font-variant!!property' property,
38993949
the related 'font-variant!!property' subproperties and any other CSS property
3900-
that uses OpenType features (e.g. the 'font-kerning!!property' property).
3950+
that uses OpenType features (e.g. the 'font-kerning!!property' property) are applied.
39013951

39023952
<!-- other CSS props override 'font-variant' but not 'font-feature-settings' -->
39033953
<!-- http://lists.w3.org/Archives/Public/www-style/2013Aug/0110.html -->
39043954

3905-
10. Feature settings determined by properties other than 'font-variant!!property' or
3906-
'font-feature-settings!!property'. For example, setting a
3955+
11. Feature settings determined by properties other than 'font-variant!!property' or
3956+
'font-feature-settings!!property' are applied. For example, setting a
39073957
non-default value for the 'letter-spacing' property disables common ligatures.
39083958

3909-
11. Font variations implied by the value of the 'font-variation-settings!!property' property.
3959+
12. Font variations implied by the value of the 'font-variation-settings!!property' property are applied.
39103960
These values should be clamped to the values that are supported by the font.
39113961

3912-
12. Font features implied by the value of 'font-feature-settings!!property' property.
3962+
13. Font features implied by the value of 'font-feature-settings!!property' property are applied.
39133963

39143964
This ordering allows authors to set up a general set of defaults
39153965
for fonts within their ''@font-face'' rules, then override them with
3916-
property settings for specific elements. General property settings
3966+
property settings for specific elements. General property settings
39173967
override the settings in ''@font-face'' rules and low-level font feature
39183968
settings override 'font-variant!!property' property settings.
39193969

0 commit comments

Comments
 (0)