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 allows authors to load custom fonts from the web via the ''@font-face'' rule.
20
+
While this is easy to use when authoring a stylesheet,
21
+
it's much more difficult to use dynamically via scripting.
22
+
23
+
Further, CSS allows the user agent to choose when to actually load a font;
24
+
if a font face isn't <em>currently</em> used by anything on a page,
25
+
most user agents will not download its associated file.
26
+
This means that later use of the font face will incur a delay
27
+
as the user agent finally notices a usage and begins downloading and parsing the font file.
28
+
29
+
This specification defines a scripting interface to font faces in CSS,
30
+
allowing font faces to be easily created and loaded from script.
31
+
It also provides methods to track the loading status of an individual font,
32
+
or of all the fonts on an entire page.
21
33
22
34
<h2 id="fontface-interface">
23
35
The <code>FontFace</code> Interface</h2>
@@ -251,7 +263,8 @@ Interaction with CSS’s ''@font-face'' Rule</h3>
251
263
This <a interface>FontFace</a> object is <dfn>CSS-connected</dfn>.
252
264
253
265
The <a interface>FontFace</a> object corresponding to a ''@font-face'' rule
254
-
has its <a attribute>family</a>, <a attribute>style</a>, <a attribute>weight</a>, <a attribute>stretch</a>, <a attribute>unicodeRange</a>, <a attribute>variant</a>, and <a attribute>featureSettings</a> attributes set to the same value as the corresponding descriptors in the ''@font-face'' rule.
266
+
has its <a attribute>family</a>, <a attribute>style</a>, <a attribute>weight</a>, <a attribute>stretch</a>, <a attribute>unicodeRange</a>, <a attribute>variant</a>, and <a attribute>featureSettings</a> attributes
267
+
set to the same value as the corresponding descriptors in the ''@font-face'' rule.
255
268
There is a two-way connection between the two:
256
269
any change made to a ''@font-face'' descriptor is immediately reflected in the corresponding <a interface>FontFace</a> attribute,
257
270
and vice versa.
@@ -261,7 +274,9 @@ Interaction with CSS’s ''@font-face'' Rule</h3>
261
274
262
275
Otherwise, a <a interface>FontFace</a> object created by a CSS ''@font-face'' rule is identical to one created manually.
263
276
264
-
If a ''@font-face'' rule is removed from the document, its corresponding <a interface>FontFace</a> object is no longer <a>CSS-connected</a>. The connection is not restorable by any means (but adding the ''@font-face'' back to the stylesheet will create a brand new <a interface>FontFace</a> object which <em>is</em><a>CSS-connected</a>).
277
+
If a ''@font-face'' rule is removed from the document, its corresponding <a interface>FontFace</a> object is no longer <a>CSS-connected</a>.
278
+
The connection is not restorable by any means
279
+
(but adding the ''@font-face'' back to the stylesheet will create a brand new <a interface>FontFace</a> object which <em>is</em><a>CSS-connected</a>).
<p> CSS allows authors to load custom fonts from the web via the <aclass=cssdata-link-type=maybehref=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-ruletitle=@font-face>@font-face</a> rule.
147
+
While this is easy to use when authoring a stylesheet,
148
+
it’s much more difficult to use dynamically via scripting.
149
+
150
+
<p> Further, CSS allows the user agent to choose when to actually load a font;
151
+
if a font face isn’t <em>currently</em> used by anything on a page,
152
+
most user agents will not download its associated file.
153
+
This means that later use of the font face will incur a delay
154
+
as the user agent finally notices a usage and begins downloading and parsing the font file.
155
+
156
+
<p> This specification defines a scripting interface to font faces in CSS,
157
+
allowing font faces to be easily created and loaded from script.
158
+
It also provides methods to track the loading status of an individual font,
This <aclass=idl-codedata-link-type=interfacehref=http://dev.w3.org/csswg/css-font-load-events-3/#dom-fontfacetitle=fontface>FontFace</a> object is <dfndata-dfn-type=dfndata-noexport="" id=css-connected>CSS-connected<aclass=self-linkhref=#css-connected></a></dfn>.
377
389
378
390
<p> The <aclass=idl-codedata-link-type=interfacehref=http://dev.w3.org/csswg/css-font-load-events-3/#dom-fontfacetitle=fontface>FontFace</a> object corresponding to a <aclass=cssdata-link-type=maybehref=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-ruletitle=@font-face>@font-face</a> rule
379
-
has its <aclass=idl-codedata-link-type=attributehref=#dom-fontface-familytitle=family>family</a>, <aclass=idl-codedata-link-type=attributehref=#dom-fontface-styletitle=style>style</a>, <aclass=idl-codedata-link-type=attributehref=#dom-fontface-weighttitle=weight>weight</a>, <aclass=idl-codedata-link-type=attributehref=#dom-fontface-stretchtitle=stretch>stretch</a>, <aclass=idl-codedata-link-type=attributehref=#dom-fontface-unicoderangetitle=unicoderange>unicodeRange</a>, <aclass=idl-codedata-link-type=attributehref=#dom-fontface-varianttitle=variant>variant</a>, and <aclass=idl-codedata-link-type=attributehref=#dom-fontface-featuresettingstitle=featuresettings>featureSettings</a> attributes set to the same value as the corresponding descriptors in the <aclass=cssdata-link-type=maybehref=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-ruletitle=@font-face>@font-face</a> rule.
391
+
has its <aclass=idl-codedata-link-type=attributehref=#dom-fontface-familytitle=family>family</a>, <aclass=idl-codedata-link-type=attributehref=#dom-fontface-styletitle=style>style</a>, <aclass=idl-codedata-link-type=attributehref=#dom-fontface-weighttitle=weight>weight</a>, <aclass=idl-codedata-link-type=attributehref=#dom-fontface-stretchtitle=stretch>stretch</a>, <aclass=idl-codedata-link-type=attributehref=#dom-fontface-unicoderangetitle=unicoderange>unicodeRange</a>, <aclass=idl-codedata-link-type=attributehref=#dom-fontface-varianttitle=variant>variant</a>, and <aclass=idl-codedata-link-type=attributehref=#dom-fontface-featuresettingstitle=featuresettings>featureSettings</a> attributes
392
+
set to the same value as the corresponding descriptors in the <aclass=cssdata-link-type=maybehref=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-ruletitle=@font-face>@font-face</a> rule.
380
393
There is a two-way connection between the two:
381
394
any change made to a <aclass=cssdata-link-type=maybehref=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-ruletitle=@font-face>@font-face</a> descriptor is immediately reflected in the corresponding <aclass=idl-codedata-link-type=interfacehref=http://dev.w3.org/csswg/css-font-load-events-3/#dom-fontfacetitle=fontface>FontFace</a> attribute,
<p> Otherwise, a <aclass=idl-codedata-link-type=interfacehref=http://dev.w3.org/csswg/css-font-load-events-3/#dom-fontfacetitle=fontface>FontFace</a> object created by a CSS <aclass=cssdata-link-type=maybehref=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-ruletitle=@font-face>@font-face</a> rule is identical to one created manually.
388
401
389
-
<p> If a <aclass=cssdata-link-type=maybehref=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-ruletitle=@font-face>@font-face</a> rule is removed from the document, its corresponding <aclass=idl-codedata-link-type=interfacehref=http://dev.w3.org/csswg/css-font-load-events-3/#dom-fontfacetitle=fontface>FontFace</a> object is no longer <adata-link-type=dfnhref=#css-connectedtitle=css-connected>CSS-connected</a>. The connection is not restorable by any means (but adding the <aclass=cssdata-link-type=maybehref=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-ruletitle=@font-face>@font-face</a> back to the stylesheet will create a brand new <aclass=idl-codedata-link-type=interfacehref=http://dev.w3.org/csswg/css-font-load-events-3/#dom-fontfacetitle=fontface>FontFace</a> object which <em>is</em><adata-link-type=dfnhref=#css-connectedtitle=css-connected>CSS-connected</a>).
402
+
<p> If a <aclass=cssdata-link-type=maybehref=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-ruletitle=@font-face>@font-face</a> rule is removed from the document, its corresponding <aclass=idl-codedata-link-type=interfacehref=http://dev.w3.org/csswg/css-font-load-events-3/#dom-fontfacetitle=fontface>FontFace</a> object is no longer <adata-link-type=dfnhref=#css-connectedtitle=css-connected>CSS-connected</a>.
403
+
The connection is not restorable by any means
404
+
(but adding the <aclass=cssdata-link-type=maybehref=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-ruletitle=@font-face>@font-face</a> back to the stylesheet will create a brand new <aclass=idl-codedata-link-type=interfacehref=http://dev.w3.org/csswg/css-font-load-events-3/#dom-fontfacetitle=fontface>FontFace</a> object which <em>is</em><adata-link-type=dfnhref=#css-connectedtitle=css-connected>CSS-connected</a>).
0 commit comments