-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.html
More file actions
1149 lines (928 loc) · 92.3 KB
/
Overview.html
File metadata and controls
1149 lines (928 loc) · 92.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html><html lang=en><head>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Font Load Events Module Level 3</title>
<link href=../default.css rel=stylesheet type=text/css>
<link href=../csslogo.ico rel="shortcut icon" type=image/x-icon>
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
</head>
<body class=h-entry>
<div class=head>
<p data-fill-with=logo><a class=logo href=http://www.w3.org/>
<img alt=W3C height=48 src=http://www.w3.org/Icons/w3c_home width=72>
</a>
</p>
<h1 class="p-name no-ref" id=title>CSS Font Load Events Module Level 3</h1>
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
<span class=dt-updated><span class=value-title title=20131107>7 November 2013</span></span></span></h2>
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-font-load-events/>http://dev.w3.org/csswg/css-font-load-events/</a><dt>Latest version:<dd><a href=http://www.w3.org/TR/css-font-load-events-3/>http://www.w3.org/TR/css-font-load-events-3/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-font-load-events/>http://dev.w3.org/csswg/css-font-load-events/</a>
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-font-load-events%5D%20feedback">www-style@w3.org</a>
with subject line
“<kbd>[css-font-load-events] <var>… message topic …</var></kbd>”(<a href=http://lists.w3.org/Archives/Public/www-style/ rel=discussion>archives</a>)<dt>Test Suite:<dd>None Yet<dt>Editors:
<dd class="p-author h-card vcard"><a class="p-name fn u-url url" href=http://xanthir.com/contact/>Tab Atkins Jr.</a> (<span class="p-org org">Google</span>)<dt>Former Editors:
<dd class="p-author h-card vcard"><a class="p-name fn u-email email" href=mailto:jdaggett@mozilla.com>John Daggett</a> (<span class="p-org org">Mozilla</span>)</dl></div>
<div data-fill-with=warning></div>
<p class=copyright data-fill-with=copyright><a href=http://www.w3.org/Consortium/Legal/ipr-notice#Copyright>Copyright</a> © 2013 <a href=http://www.w3.org/><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href=http://www.csail.mit.edu/><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href=http://www.ercim.eu/><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href=http://www.keio.ac.jp/>Keio</a>, <a href=http://ev.buaa.edu.cn/>Beihang</a>), All Rights Reserved. W3C <a href=http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer>liability</a>, <a href=http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks>trademark</a> and <a href=http://www.w3.org/Consortium/Legal/copyright-documents>document use</a> rules apply.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled heading" id=abstract><span class=content>Abstract</span></h2>
<p class=p-summary data-fill-with=abstract>This CSS module describes events and interfaces used for dynamically loading font resources.
<a href=http://www.w3.org/TR/CSS/>CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, in speech, etc.</p>
<h2 class="no-num no-toc no-ref heading settled heading" id=status><span class=content>Status of this document</span></h2>
<div data-fill-with=status><p>
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
<p>
The (<a href=http://lists.w3.org/Archives/Public/www-style/>archived</a>) public mailing list
<a href="mailto:www-style@w3.org?Subject=%5Bcss-font-load-events%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a>
(see <a href=http://www.w3.org/Mail/Request>instructions</a>)
is preferred for discussion of this specification.
When sending e-mail,
please put the text “css-font-load-events” in the subject,
preferably like this:
“[css-font-load-events] <em>…summary of comment…</em>”
<p>
This document was produced by the <a href=http://www.w3.org/Style/CSS/members>CSS Working Group</a>
(part of the <a href=http://www.w3.org/Style/>Style Activity</a>).
<p>
This document was produced by a group operating under
the <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/>5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href=http://www.w3.org/2004/01/pp-impl/32061/status rel=disclosure>public list of any patent disclosures</a>
made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual believes contains <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential>Essential Claim(s)</a>
must disclose the information in accordance with <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure>section 6 of the W3C Patent Policy</a>.</div>
<div data-fill-with=at-risk></div>
<h2 class="no-num no-toc no-ref heading settled heading" id=contents><span class=content>Table of contents</span></h2>
<div data-fill-with=table-of-contents><ul class=toc><li><a href=#introduction><span class=secno>1</span>
Introduction</a><li><a href=#fontface-interface><span class=secno>2</span>
The <code>FontFace</code> Interface</a><ul class=toc><li><a href=#font-face-constructor><span class=secno>2.1</span>
The Constructor</a><li><a href=#font-face-load><span class=secno>2.2</span>
The <code>load()</code> method</a><li><a href=#font-face-ready><span class=secno>2.3</span>
The <code>ready()</code> method</a><li><a href=#font-face-css-connection><span class=secno>2.4</span>
Interaction with CSS’s <span class=css data-link-type=maybe title=@font-face>@font-face</span> Rule</a></ul><li><a href=#FontFaceSet-interface><span class=secno>3</span>
The <code>FontFaceSet</code> Interface</a><ul class=toc><li><a href=#set-modifications><span class=secno>3.1</span>
Modifications of normal Set methods</a><li><a href=#FontFaceSet-events><span class=secno>3.2</span>
Events</a><li><a href=#font-face-set-match><span class=secno>3.3</span>
The <code>match()</code> method</a><li><a href=#font-face-set-load><span class=secno>3.4</span>
The <code>load()</code> method</a><li><a href=#font-face-set-check><span class=secno>3.5</span>
The <code>check()</code> method</a><li><a href=#font-face-set-ready><span class=secno>3.6</span>
The <code>ready()</code> method</a><li><a href=#font-face-set-css><span class=secno>3.7</span>
Interaction with CSS Font Loading and Matching</a></ul><li><a href=#font-face-source><span class=secno>4</span>
The <code>FontFaceSource</code> interface</a><ul class=toc><li><a href=#document-font-face-set><span class=secno>4.1</span>
Interaction with CSS’s <span class=css data-link-type=maybe title=@font-face>@font-face</span> Rule</a></ul><li><a href=#font-load-event-examples><span class=secno>5</span>
API Examples</a><li><a href=#changes><span class=secno></span>Changes</a><ul class=toc><li><a href=#changes-since-20130212><span class=secno></span>
Changes from the <span>February 2013 CSS3 Fonts Working Draft</span></a></ul><li><a href=#acknowledgments><span class=secno></span>
Acknowledgments</a><li><a href=#conformance><span class=secno></span>
Conformance</a><ul class=toc><li><a href=#conventions><span class=secno></span>
Document conventions</a><li><a href=#conformance-classes><span class=secno></span>
Conformance classes</a><li><a href=#partial><span class=secno></span>
Partial implementations</a><li><a href=#experimental><span class=secno></span>
Experimental implementations</a><li><a href=#testing><span class=secno></span>
Non-experimental implementations</a></ul><li><a href=#references><span class=secno></span>
References</a><ul class=toc><li><a href=#normative><span class=secno></span>
Normative References</a><li><a href=#informative><span class=secno></span>
Informative References</a></ul><li><a href=#index><span class=secno></span>
Index</a><li><a href=#property-index><span class=secno></span>
Property index</a><li><a href=#issues-index><span class=secno></span>Issues Index</a></ul></div>
<h2 class="heading settled heading" data-level=1 id=introduction><span class=secno>1 </span><span class=content>
Introduction</span><a class=self-link href=#introduction></a></h2>
<p class=issue id=issue-c42e0891><a class=self-link href=#issue-c42e0891></a>
Fill in intro.
<h2 class="heading settled heading" data-level=2 id=fontface-interface><span class=secno>2 </span><span class=content>
The <code>FontFace</code> Interface</span><a class=self-link href=#fontface-interface></a></h2>
<p> The <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> interface represents a single usable font face.
CSS <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rules implicitly define FontFace objects,
or they can be constructed manually from a url or binary data.
<pre class=idl>typedef (<a data-link-type=idl href=http://www.khronos.org/registry/typedarray/specs/latest/#ArrayBuffer title=arraybuffer>ArrayBuffer</a> or <a data-link-type=idl href=http://www.khronos.org/registry/typedarray/specs/latest/#ArrayBufferView title=arraybufferview>ArrayBufferView</a>) <dfn class=idl-code data-dfn-type=typedef data-export="" data-global-name="" id=typedefdef-binarydata title=BinaryData>BinaryData<a class=self-link href=#typedefdef-binarydata></a></dfn>;
dictionary <dfn class=idl-code data-dfn-type=dictionary data-export="" data-global-name="" id=dictdef-fontfacedescriptors title=FontFaceDescriptors>FontFaceDescriptors<a class=self-link href=#dictdef-fontfacedescriptors></a></dfn> {
DOMString <dfn class=idl-code data-dfn-for=FontFaceDescriptors data-dfn-type=dict-member data-export="" data-global-name="FontFaceDescriptors<dictionary>/style<dict-member>" id=dom-fontfacedescriptors-style title=style>style<a class=self-link href=#dom-fontfacedescriptors-style></a></dfn> = "normal";
DOMString <dfn class=idl-code data-dfn-for=FontFaceDescriptors data-dfn-type=dict-member data-export="" data-global-name="FontFaceDescriptors<dictionary>/weight<dict-member>" id=dom-fontfacedescriptors-weight title=weight>weight<a class=self-link href=#dom-fontfacedescriptors-weight></a></dfn> = "normal";
DOMString <dfn class=idl-code data-dfn-for=FontFaceDescriptors data-dfn-type=dict-member data-export="" data-global-name="FontFaceDescriptors<dictionary>/stretch<dict-member>" id=dom-fontfacedescriptors-stretch title=stretch>stretch<a class=self-link href=#dom-fontfacedescriptors-stretch></a></dfn> = "normal";
DOMString <dfn class=idl-code data-dfn-for=FontFaceDescriptors data-dfn-type=dict-member data-export="" data-global-name="FontFaceDescriptors<dictionary>/unicoderange<dict-member>" id=dom-fontfacedescriptors-unicoderange title=unicodeRange>unicodeRange<a class=self-link href=#dom-fontfacedescriptors-unicoderange></a></dfn> = "U+0-10FFFF";
DOMString <dfn class=idl-code data-dfn-for=FontFaceDescriptors data-dfn-type=dict-member data-export="" data-global-name="FontFaceDescriptors<dictionary>/variant<dict-member>" id=dom-fontfacedescriptors-variant title=variant>variant<a class=self-link href=#dom-fontfacedescriptors-variant></a></dfn> = "normal";
DOMString <dfn class=idl-code data-dfn-for=FontFaceDescriptors data-dfn-type=dict-member data-export="" data-global-name="FontFaceDescriptors<dictionary>/featuresettings<dict-member>" id=dom-fontfacedescriptors-featuresettings title=featureSettings>featureSettings<a class=self-link href=#dom-fontfacedescriptors-featuresettings></a></dfn> = "normal";
};
enum <dfn class=idl-code data-dfn-type=enum data-export="" data-global-name="" id=enumdef-fontfaceloadstatus title=FontFaceLoadStatus>FontFaceLoadStatus<a class=self-link href=#enumdef-fontfaceloadstatus></a></dfn> { "unloaded", "loading", "loaded", "error" };
[Constructor(DOMString <a class=idl-code data-global-name="FontFace<interface>/FontFace()<method>/family<argument>" data-link-for=FontFace/FontFace() data-link-type=argument href=#dom-fontfacefontface-fontface-family title=family>family</a>, (DOMString or <a data-link-type=idl href=#typedefdef-binarydata title=binarydata>BinaryData</a>) <a class=idl-code data-global-name="FontFace<interface>/FontFace()<method>/source<argument>" data-link-for=FontFace/FontFace() data-link-type=argument href=#dom-fontfacefontface-fontface-source title=source>source</a>,
<a data-link-type=idl href=#dictdef-fontfacedescriptors title=fontfacedescriptors>FontFaceDescriptors</a> <a class=idl-code data-global-name="FontFace<interface>/FontFace()<method>/descriptors<argument>" data-link-for=FontFace/FontFace() data-link-type=argument href=#dom-fontfacefontface-fontface-descriptors title=descriptors>descriptors</a>)]
interface <dfn class=idl-code data-dfn-type=interface data-export="" data-global-name="" id=dom-fontface title=FontFace>FontFace<a class=self-link href=#dom-fontface></a></dfn> {
attribute DOMString <a class=idl-code data-global-name="FontFace<interface>/family<attribute>" data-link-for=FontFace data-link-type=attribute href=#dom-fontface-family title=family>family</a>;
attribute DOMString <a class=idl-code data-global-name="FontFace<interface>/style<attribute>" data-link-for=FontFace data-link-type=attribute href=#dom-fontface-style title=style>style</a>;
attribute DOMString <a class=idl-code data-global-name="FontFace<interface>/weight<attribute>" data-link-for=FontFace data-link-type=attribute href=#dom-fontface-weight title=weight>weight</a>;
attribute DOMString <a class=idl-code data-global-name="FontFace<interface>/stretch<attribute>" data-link-for=FontFace data-link-type=attribute href=#dom-fontface-stretch title=stretch>stretch</a>;
attribute DOMString <a class=idl-code data-global-name="FontFace<interface>/unicoderange<attribute>" data-link-for=FontFace data-link-type=attribute href=#dom-fontface-unicoderange title=unicoderange>unicodeRange</a>;
attribute DOMString <a class=idl-code data-global-name="FontFace<interface>/variant<attribute>" data-link-for=FontFace data-link-type=attribute href=#dom-fontface-variant title=variant>variant</a>;
attribute DOMString <a class=idl-code data-global-name="FontFace<interface>/featuresettings<attribute>" data-link-for=FontFace data-link-type=attribute href=#dom-fontface-featuresettings title=featuresettings>featureSettings</a>;
readonly attribute <a data-link-type=idl href=#enumdef-fontfaceloadstatus title=fontfaceloadstatus>FontFaceLoadStatus</a> <a class=idl-code data-global-name="FontFace<interface>/status<attribute>" data-link-for=FontFace data-link-type=attribute href=#dom-fontface-status title=status>status</a>;
// If the font face’s source is url-based and its status isn’t
// "loading" or "loaded", this kicks off the load.
void <a class=idl-code data-global-name="FontFace<interface>/load()<method>" data-link-for=FontFace data-link-type=method href=#dom-fontface-load title=load()>load</a>();
// Returns a promise that fulfills or rejects when the font face
// reached "loaded" or "error" status.
<a data-link-type=idl title=promise>Promise</a> <a class=idl-code data-global-name="FontFace<interface>/ready()<method>" data-link-for=FontFace data-link-type=method href=#dom-fontface-ready title=ready()>ready</a>();
};
</pre>
<dl data-dfn-for=FontFace data-dfn-type=attribute>
<dt><dfn class=idl-code data-dfn-for=FontFace data-dfn-type=attribute data-export="" id=dom-fontface-family>family<a class=self-link href=#dom-fontface-family></a></dfn>, of type <a class=idl-code data-link-type=interface title=domstring>DOMString</a>
<dt><dfn class=idl-code data-dfn-for=FontFace data-dfn-type=attribute data-export="" id=dom-fontface-style>style<a class=self-link href=#dom-fontface-style></a></dfn>, of type <a class=idl-code data-link-type=interface title=domstring>DOMString</a>
<dt><dfn class=idl-code data-dfn-for=FontFace data-dfn-type=attribute data-export="" id=dom-fontface-weight>weight<a class=self-link href=#dom-fontface-weight></a></dfn>, of type <a class=idl-code data-link-type=interface title=domstring>DOMString</a>
<dt><dfn class=idl-code data-dfn-for=FontFace data-dfn-type=attribute data-export="" id=dom-fontface-stretch>stretch<a class=self-link href=#dom-fontface-stretch></a></dfn>, of type <a class=idl-code data-link-type=interface title=domstring>DOMString</a>
<dt><dfn class=idl-code data-dfn-for=FontFace data-dfn-type=attribute data-export="" id=dom-fontface-unicoderange>unicodeRange<a class=self-link href=#dom-fontface-unicoderange></a></dfn>, of type <a class=idl-code data-link-type=interface title=domstring>DOMString</a>
<dd>
These attributes all represent the corresponding aspects of a font face,
as defined by the descriptors defined in the CSS <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rule.
They are parsed the same as the corresponding <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> descriptors.
They are used by the font matching algorithm,
but otherwise have no effect.
<p> For example, a <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> with a <a class=idl-code data-link-type=attribute href=#dom-fontface-style title=style>style</a> of <code>"italic"</code>
<em>represents</em> an italic font face;
it does not <strong>make</strong> the font face italic.
<dt><dfn class=idl-code data-dfn-for=FontFace data-dfn-type=attribute data-export="" id=dom-fontface-variant>variant<a class=self-link href=#dom-fontface-variant></a></dfn>, of type <a class=idl-code data-link-type=interface title=domstring>DOMString</a>
<dt><dfn class=idl-code data-dfn-for=FontFace data-dfn-type=attribute data-export="" id=dom-fontface-featuresettings>featureSettings<a class=self-link href=#dom-fontface-featuresettings></a></dfn>, of type <a class=idl-code data-link-type=interface title=domstring>DOMString</a>
<dd>
These attributes have the same meaning,
and are parsed the same as,
the corresponding descriptors in the CSS <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rules.
<p> They turn on or off specific features in fonts that support them.
Unlike the previous attributes,
these attributes actually affect the font face.
<dt><dfn class=idl-code data-dfn-for=FontFace data-dfn-type=attribute data-export="" id=dom-fontface-status>status<a class=self-link href=#dom-fontface-status></a></dfn>, of type <a class=idl-code data-link-type=enum href=#enumdef-fontfaceloadstatus title=fontfaceloadstatus>FontFaceLoadStatus</a>
<dd>
This attribute reflects the current status of the font face.
It must be "unloaded" for a newly-created <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a>.
<p> It can change due to an author explicitly requesting a font face to load,
such as through the <a class=idl-code data-link-for=FontFace data-link-type=method href=#dom-fontface-load title=load()>load()</a> method on <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a>,
or implicitly by the user agent,
due to it detecting that the font face is needed to draw some text on the screen.
</dl>
<p> All <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects contain an internal <dfn class=idl-code data-dfn-for=FontFace data-dfn-type=attribute data-export="" id=dom-fontface-fontstatuspromise>[FontStatusPromise]<a class=self-link href=#dom-fontface-fontstatuspromise></a></dfn> attribute,
which tracks the status of the font.
It starts out pending,
and fulfills or rejects when the font is successfully loaded and parsed, or hits an error.
<p> All <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects also contain
internal <dfn class=idl-code data-dfn-for=FontFace data-dfn-type=attribute data-export="" id=dom-fontface-urls>[Urls]<a class=self-link href=#dom-fontface-urls></a></dfn> and <dfn class=idl-code data-dfn-for=FontFace data-dfn-type=attribute data-export="" id=dom-fontface-data>[Data]<a class=self-link href=#dom-fontface-data></a></dfn> attributes,
of which one is not <code>null</code> and the rest are <code>null</code>.
<h3 class="heading settled heading" data-level=2.1 id=font-face-constructor><span class=secno>2.1 </span><span class=content>
The Constructor</span><a class=self-link href=#font-face-constructor></a></h3>
<p> A <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> can be constructed either
from a URL pointing to a font face file,
or from an ArrayBuffer (or ArrayBufferView) containing the binary representation of a font face.
<p> When the <dfn class=idl-code data-dfn-for=FontFace data-dfn-type=method data-export="" data-link-type=idl id=dom-fontface-fontface title=FontFace()>Constructor(DOMString <dfn class=idl-code data-dfn-for="FontFace/FontFace() FontFace()" data-dfn-type=argument data-export="" id=dom-fontfacefontface-fontface-family>family<a class=self-link href=#dom-fontfacefontface-fontface-family></a></dfn>, (DOMString or <a data-link-type=idl href=#typedefdef-binarydata title=binarydata>BinaryData</a>) <dfn class=idl-code data-dfn-for="FontFace/FontFace() FontFace()" data-dfn-type=argument data-export="" id=dom-fontfacefontface-fontface-source>source<a class=self-link href=#dom-fontfacefontface-fontface-source></a></dfn>, <a data-link-type=idl href=#dictdef-fontfacedescriptors title=fontfacedescriptors>FontFaceDescriptors</a> <dfn class=idl-code data-dfn-for="FontFace/FontFace() FontFace()" data-dfn-type=argument data-export="" id=dom-fontfacefontface-fontface-descriptors>descriptors<a class=self-link href=#dom-fontfacefontface-fontface-descriptors></a></dfn>)<a class=self-link href=#dom-fontface-fontface></a></dfn> method is called,
execute these steps:
<ol data-link-type=idl>
<li>
Let <var>font face</var> be a fresh <a data-link-type=idl href=#dom-fontface title=fontface>FontFace</a> object.
Set <var>font face’s</var> <a data-link-for=FontFace data-link-type=idl href=#dom-fontface-status title=status>status</a> argument to <code>"unloaded"</code>.
Set its internal <a data-link-type=idl href=#dom-fontface-fontstatuspromise title=[fontstatuspromise]>[FontStatusPromise]</a> attribute to a newly-created promise object.
Return <var>font face</var>,
and complete the rest of these steps asynchronously.
<li>
Parse the <a class=idl-code data-link-type=argument href=#dom-fontfacefontface-fontface-family title=family>family</a> argument,
and the members of the <a class=idl-code data-link-for=FontFace() data-link-type=argument href=#dom-fontfacefontface-fontface-descriptors title=descriptors>descriptors</a> argument,
according to the grammars of the corresponding descriptors of the CSS <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rule.
If any of them fail to parse correctly,
reject <var>font face’s</var> <a data-link-type=idl href=#dom-fontface-fontstatuspromise title=[fontstatuspromise]>[FontStatusPromise]</a> with a SyntaxError exception and abort these steps.
Otherwise, set <var>font face’s</var> corresponding attributes to the serialization of the parsed values.
<li>
If the <a data-link-type=idl href=#dom-fontfacefontface-fontface-source title=source>source</a> argument was a <a data-link-type=idl title=domstring>DOMString</a>,
parse it according to the grammar of the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-fonts-3/#descdef-src title=src>src</a> descriptor of the CSS <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rule.
If it fails to parse correctly,
reject <var>font face’s</var> <a data-link-type=idl href=#dom-fontface-fontstatuspromise title=[fontstatuspromise]>[FontStatusPromise]</a> with a SyntaxError exception and abort these steps;
otherwise, set <var>font face’s</var> internal <a data-link-type=idl href=#dom-fontface-urls title=[urls]>[Urls]</a> attribute to the string.
<p class=note> Note: Note that this means that passing a naked url as the source argument,
like <code>"http://example.com/myFont.woff"</code>,
won’t work - it needs to be at least wrapped in a <span class=css data-link-type=maybe title=url()>url()</span> function,
like <code>"url(http://example.com/myFont.woff)"</code>.
In return for this inconvenience,
you get to specify multiple fallbacks,
specify the type of font each fallback is,
and refer to local fonts easily.
<p> If the <a data-link-type=idl href=#dom-fontfacefontface-fontface-source title=source>source</a> argument was a <a data-link-type=idl href=#typedefdef-binarydata title=binarydata>BinaryData</a>,
set <var>font face’s</var> internal <a data-link-type=idl href=#dom-fontface-data title=[data]>[Data]</a> attribute to the passed argument.
<li>
If <var>font face’s</var> <a data-link-type=idl href=#dom-fontface-data title=[data]>[Data]</a> attribute is not <code>null</code>,
set <var>font face’s</var> <a data-link-for=FontFace data-link-type=idl href=#dom-fontface-status title=status>status</a> attribute to "loading",
and attempt to parse the data in it as a font.
If this is successful,
<var>font face</var> now represents the parsed font;
fulfill <var>font face’s</var> <a data-link-type=idl href=#dom-fontface-fontstatuspromise title=[fontstatuspromise]>[FontStatusPromise]</a> with <var>font face</var>,
and set its <a data-link-for=FontFace data-link-type=idl href=#dom-fontface-status title=status>status</a> attribute to "loaded".
If it is unsuccessful,
reject <var>font face’s</var> <a data-link-type=idl href=#dom-fontface-fontstatuspromise title=[fontstatuspromise]>[FontStatusPromise]</a> with a SyntaxError
and set <var>font face’s</var> <a data-link-for=FontFace data-link-type=idl href=#dom-fontface-status title=status>status</a> attribute to "error".
</ol>
<h3 class="heading settled heading" data-level=2.2 id=font-face-load><span class=secno>2.2 </span><span class=content>
The <code>load()</code> method</span><a class=self-link href=#font-face-load></a></h3>
<p> The <a class=idl-code data-link-for=FontFace data-link-type=method href=#dom-fontface-load title=load()>load()</a> method of <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a>
forces a url-based font face to request its font data and load.
For fonts constructed from binary data,
or fonts that are already loading or loaded,
it does nothing.
<p> When the <dfn class=idl-code data-dfn-for=FontFace data-dfn-type=method data-export="" id=dom-fontface-load title=load()>load()<a class=self-link href=#dom-fontface-load></a></dfn> method is called,
execute these steps:
<ol data-link-type=idl>
<li>
Let <var>font face</var> be the <a data-link-type=idl href=#dom-fontface title=fontface>FontFace</a> object on which this method was called.
<li>
If <var>font face’s</var> <a data-link-type=idl href=#dom-fontface-urls title=[urls]>[Urls]</a> attribute is <code>null</code>,
or its <a data-link-for=FontFace data-link-type=idl href=#dom-fontface-status title=status>status</a> attribute is anything other than <code>"unloaded"</code>,
abort this algorithm immediately.
<li>
Otherwise,
set <var>font face’s</var> <a data-link-for=FontFace data-link-type=idl href=#dom-fontface-status title=status>status</a> attribute to "loading",
return immediately,
and follow these steps asynchronously:
<li>
Using the value of <var>font face’s <a data-link-type=idl href=#dom-fontface-urls title=[urls]>[Urls]</a> attribute,
attempt to load a font as defined in <a data-biblio-type=normative data-link-type=biblio href=#css3-fonts title=css3-fonts>[CSS3-FONTS]</a>,
as if it was the value of a <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rule’s <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-fonts-3/#descdef-src title=src>src</a> descriptor.
</var><li>
If the attempt to load fails,
reject <var>font face’s</var> <a data-link-type=idl href=#dom-fontface-fontstatuspromise title=[fontstatuspromise]>[FontStatusPromise]</a> with a NetworkError
and set <var>font face’s</var> <a data-link-for=FontFace data-link-type=idl href=#dom-fontface-status title=status>status</a> attribute to "error".
<li>
Otherwise,
<var>font face</var> now represents the loaded font;
fulfill <var>font face’s</var> <a data-link-type=idl href=#dom-fontface-fontstatuspromise title=[fontstatuspromise]>[FontStatusPromise]</a> with <var>font face</var>
and set <var>font face’s</var> <a data-link-for=FontFace data-link-type=idl href=#dom-fontface-status title=status>status</a> attribute to "loaded".
</ol>
<p> User agents can initiate font loads on their own,
whenever they determine that a given font face is necessary to render something on the page.
When this happens,
they must act as if they had called the corresponding <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a>’s <a class=idl-code data-link-for=FontFace data-link-type=method href=#dom-fontface-load title=load()>load()</a> method described here.
<h3 class="heading settled heading" data-level=2.3 id=font-face-ready><span class=secno>2.3 </span><span class=content>
The <code>ready()</code> method</span><a class=self-link href=#font-face-ready></a></h3>
<p> The <a class=idl-code data-link-for=FontFace data-link-type=method href=#dom-fontface-ready title=ready()>ready()</a> method of <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a>
returns a Promise
which is fulfilled when the font face is successfully loaded,
or rejected when the font face fails to load or parse successfully.
<p> When the <dfn class=idl-code data-dfn-for=FontFace data-dfn-type=method data-export="" id=dom-fontface-ready title=ready()>ready()<a class=self-link href=#dom-fontface-ready></a></dfn> method is called,
execute these steps:
<ol data-link-type=idl>
<li>
Let <var>font face</var> be the <a data-link-type=idl href=#dom-fontface title=fontface>FontFace</a> object on which this method was called.
<li>
Let <var>ready promise</var> be a newly-created promise object.
<li>
Resolve <var>ready promise</var> with <var>font face’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontface-fontstatuspromise title=[fontstatuspromise]>[FontStatusPromise]</a>.
<li>
Return <var>ready promise</var>.
</ol>
<h3 class="heading settled heading" data-level=2.4 id=font-face-css-connection><span class=secno>2.4 </span><span class=content>
Interaction with CSS’s <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> Rule</span><a class=self-link href=#font-face-css-connection></a></h3>
<p> A CSS <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rule automatically defines a corresponding <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> object,
which is automatically placed in the document’s <a data-link-type=dfn href=#font-source title="font source">font source</a>.
This <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> object is <dfn data-dfn-type=dfn data-noexport="" id=css-connected>CSS-connected<a class=self-link href=#css-connected></a></dfn>.
<p> The <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> object corresponding to a <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rule
has its <a class=idl-code data-link-type=attribute href=#dom-fontface-family title=family>family</a>, <a class=idl-code data-link-type=attribute href=#dom-fontface-style title=style>style</a>, <a class=idl-code data-link-type=attribute href=#dom-fontface-weight title=weight>weight</a>, <a class=idl-code data-link-type=attribute href=#dom-fontface-stretch title=stretch>stretch</a>, <a class=idl-code data-link-type=attribute href=#dom-fontface-unicoderange title=unicoderange>unicodeRange</a>, <a class=idl-code data-link-type=attribute href=#dom-fontface-variant title=variant>variant</a>, and <a class=idl-code data-link-type=attribute href=#dom-fontface-featuresettings title=featuresettings>featureSettings</a> attributes set to the same value as the corresponding descriptors in the <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rule.
There is a two-way connection between the two:
any change made to a <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> descriptor is immediately reflected in the corresponding <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> attribute,
and vice versa.
<p> The internal <a class=idl-code data-link-type=attribute href=#dom-fontface-urls title=[urls]>[Urls]</a> attribute of the <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> object is set to the value of the <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rule’s <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-fonts-3/#descdef-src title=src>src</a> descriptor,
and reflects any changes made to the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-fonts-3/#descdef-src title=src>src</a> descriptor.
<p> Otherwise, a <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> object created by a CSS <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rule is identical to one created manually.
<p> If a <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rule is removed from the document, its corresponding <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> object is no longer <a data-link-type=dfn href=#css-connected title=css-connected>CSS-connected</a>. The connection is not restorable by any means (but adding the <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> back to the stylesheet will create a brand new <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> object which <em>is</em> <a data-link-type=dfn href=#css-connected title=css-connected>CSS-connected</a>).
<h2 class="heading settled heading" data-level=3 id=FontFaceSet-interface><span class=secno>3 </span><span class=content>
The <code>FontFaceSet</code> Interface</span><a class=self-link href=#FontFaceSet-interface></a></h2>
<pre class=idl>dictionary <dfn class=idl-code data-dfn-type=dictionary data-export="" data-global-name="" id=dictdef-cssfontfaceloadeventinit title=CSSFontFaceLoadEventInit>CSSFontFaceLoadEventInit<a class=self-link href=#dictdef-cssfontfaceloadeventinit></a></dfn> : <a data-link-type=idl title=eventinit>EventInit</a> {
sequence<<a data-link-type=idl title=cssfontfacerule>CSSFontFaceRule</a>> <dfn class=idl-code data-dfn-for=CSSFontFaceLoadEventInit data-dfn-type=dict-member data-export="" data-global-name="CSSFontFaceLoadEventInit<dictionary>/fontfaces<dict-member>" id=dom-cssfontfaceloadeventinit-fontfaces title=fontfaces>fontfaces<a class=self-link href=#dom-cssfontfaceloadeventinit-fontfaces></a></dfn> = null;
};
[Constructor(DOMString <dfn class=idl-code data-dfn-for=CSSFontFaceLoadEvent/CSSFontFaceLoadEvent() data-dfn-type=argument data-export="" data-global-name="CSSFontFaceLoadEvent<interface>/CSSFontFaceLoadEvent()<method>/type<argument>" id=dom-cssfontfaceloadeventcssfontfaceloadevent-type title=type>type<a class=self-link href=#dom-cssfontfaceloadeventcssfontfaceloadevent-type></a></dfn>, optional <a data-link-type=idl href=#dictdef-cssfontfaceloadeventinit title=cssfontfaceloadeventinit>CSSFontFaceLoadEventInit</a> <dfn class=idl-code data-dfn-for=CSSFontFaceLoadEvent/CSSFontFaceLoadEvent() data-dfn-type=argument data-export="" data-global-name="CSSFontFaceLoadEvent<interface>/CSSFontFaceLoadEvent()<method>/eventinitdict<argument>" id=dom-cssfontfaceloadeventcssfontfaceloadevent-eventinitdict title=eventInitDict>eventInitDict<a class=self-link href=#dom-cssfontfaceloadeventcssfontfaceloadevent-eventinitdict></a></dfn>)]
interface <dfn class=idl-code data-dfn-type=interface data-export="" data-global-name="" id=dom-cssfontfaceloadevent title=CSSFontFaceLoadEvent>CSSFontFaceLoadEvent<a class=self-link href=#dom-cssfontfaceloadevent></a></dfn> : <a data-link-type=idl title=event>Event</a> {
readonly attribute sequence<<a data-link-type=idl title=cssfontfacerule>CSSFontFaceRule</a>> <dfn class=idl-code data-dfn-for=CSSFontFaceLoadEvent data-dfn-type=attribute data-export="" data-global-name="CSSFontFaceLoadEvent<interface>/fontfaces<attribute>" id=dom-cssfontfaceloadevent-fontfaces title=fontfaces>fontfaces<a class=self-link href=#dom-cssfontfaceloadevent-fontfaces></a></dfn>;
};
enum <dfn class=idl-code data-dfn-type=enum data-export="" data-global-name="" id=enumdef-fontfacesetloadstatus title=FontFaceSetLoadStatus>FontFaceSetLoadStatus<a class=self-link href=#enumdef-fontfacesetloadstatus></a></dfn> { "loading", "loaded" };
[SetClass(FontFace)]
interface <dfn class=idl-code data-dfn-type=interface data-export="" data-global-name="" id=dom-fontfaceset title=FontFaceSet>FontFaceSet<a class=self-link href=#dom-fontfaceset></a></dfn> {
// -- events for when loading state changes
attribute <a data-link-type=idl href=http://www.w3.org/html/wg/drafts/html/CR/webappapis.html#eventhandler title=eventhandler>EventHandler</a> <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=attribute data-export="" data-global-name="FontFaceSet<interface>/onloading<attribute>" id=dom-fontfaceset-onloading title=onloading>onloading<a class=self-link href=#dom-fontfaceset-onloading></a></dfn>;
attribute <a data-link-type=idl href=http://www.w3.org/html/wg/drafts/html/CR/webappapis.html#eventhandler title=eventhandler>EventHandler</a> <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=attribute data-export="" data-global-name="FontFaceSet<interface>/onloadingdone<attribute>" id=dom-fontfaceset-onloadingdone title=onloadingdone>onloadingdone<a class=self-link href=#dom-fontfaceset-onloadingdone></a></dfn>;
attribute <a data-link-type=idl href=http://www.w3.org/html/wg/drafts/html/CR/webappapis.html#eventhandler title=eventhandler>EventHandler</a> <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=attribute data-export="" data-global-name="FontFaceSet<interface>/onloadingerror<attribute>" id=dom-fontfaceset-onloadingerror title=onloadingerror>onloadingerror<a class=self-link href=#dom-fontfaceset-onloadingerror></a></dfn>;
// Return the fonts that match the given "font" argument
// and can render the given characters.
sequence<<a data-link-type=idl href=#dom-fontface title=fontface>FontFace</a>> <a class=idl-code data-global-name="FontFaceSet<interface>/match()<method>" data-link-for=FontFaceSet data-link-type=method href=#dom-fontfaceset-match title=match()>match</a>(DOMString <a class=idl-code data-global-name="FontFaceSet<interface>/match()<method>/font<argument>" data-link-for=FontFaceSet/match() data-link-type=argument href=#dom-fontfacesetmatch-match-font title=font>font</a>, optional DOMString <a class=idl-code data-global-name="FontFaceSet<interface>/match()<method>/text<argument>" data-link-for=FontFaceSet/match() data-link-type=argument href=#dom-fontfacesetmatch-match-text title=text>text</a> = " ");
// check and start loads if appropriate
// and fulfill promise when all loads complete
<a data-link-type=idl title=promise>Promise</a> <a class=idl-code data-global-name="FontFaceSet<interface>/load()<method>" data-link-for=FontFaceSet data-link-type=method href=#dom-fontfaceset-load title=load()>load</a>(DOMString <a class=idl-code data-global-name="FontFaceSet<interface>/load()<method>/font<argument>" data-link-for=FontFaceSet/load() data-link-type=argument href=#dom-fontfacesetload-load-font title=font>font</a>, optional DOMString <a class=idl-code data-global-name="FontFaceSet<interface>/load()<method>/text<argument>" data-link-for=FontFaceSet/load() data-link-type=argument href=#dom-fontfacesetload-load-text title=text>text</a> = " ");
// return whether all fonts in the fontlist are loaded
// (does not initiate load if not available)
boolean <a class=idl-code data-global-name="FontFaceSet<interface>/check()<method>" data-link-for=FontFaceSet data-link-type=method href=#dom-fontfaceset-check title=check()>check</a>(DOMString <a class=idl-code data-global-name="FontFaceSet<interface>/check()<method>/font<argument>" data-link-for=FontFaceSet/check() data-link-type=argument href=#dom-fontfacesetcheck-check-font title=font>font</a>, optional DOMString <a class=idl-code data-global-name="FontFaceSet<interface>/check()<method>/text<argument>" data-link-for=FontFaceSet/check() data-link-type=argument href=#dom-fontfacesetcheck-check-text title=text>text</a> = " ");
// async notification that font loading and layout operations are done
<a data-link-type=idl title=promise>Promise</a> <a class=idl-code data-global-name="FontFaceSet<interface>/ready()<method>" data-link-for=FontFaceSet data-link-type=method href=#dom-fontfaceset-ready title=ready()>ready</a>();
// loading state, true while one or more fonts loading, false otherwise
readonly attribute <a data-link-type=idl href=#enumdef-fontfaceloadstatus title=fontfaceloadstatus>FontFaceLoadStatus</a> <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=attribute data-export="" data-global-name="FontFaceSet<interface>/status<attribute>" id=dom-fontfaceset-status title=status>status<a class=self-link href=#dom-fontfaceset-status></a></dfn>;
};
<a data-link-type=idl href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> implements <a data-link-type=idl title=eventtarget>EventTarget</a>;
</pre>
<p> The set entries for a <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> is initially an empty list.
A <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> attached to a document may have some initial <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects prefilled in it;
see the section on <a href=#document-font-face-set>Interactions with CSS’s @font-face Rule</a> for details.
<p> Because font families are loaded only when they are used,
content sometimes needs to understand when the loading of fonts occurs.
Authors can use the events and methods defined here to allow greater control over actions
that are dependent upon the availability of specific fonts.
<p> The term <dfn data-dfn-type=dfn data-noexport="" id=font-load>font load<a class=self-link href=#font-load></a></dfn> indicates when the
loading of content for a given <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> object completes.
A <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> object may list multiple alternate resources
within its <a class=idl-code data-link-type=attribute href=#dom-fontface-urls title=[urls]>[Urls]</a> attribute,
including references to local fonts,
but the term font load only refers to the loading of the finally selected resource for a given <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a>,
not to the loading of each individual resource.
<p> There are <dfn data-dfn-type=dfn data-noexport="" id=no-pending-font-loads>no pending font loads<a class=self-link href=#no-pending-font-loads></a></dfn> whenever all of the following are true:
<p> <ul>
<li>
The document has finished loading.
<li>
There are no pending stylesheet requests.
<li>
There are no <a data-link-type=dfn href=#available-font-faces title="available font faces">available font faces</a>
with a <a class=idl-code data-link-for=FontFace data-link-type=attribute href=#dom-fontface-status title=status>status</a> of "loading".
<li>
There are no pending layout operations which might cause the user agent to request a font.
</ul>
<p> If any of the above conditions are false,
there are <dfn data-dfn-type=dfn data-noexport="" id=possibly-pending-font-loads>possibly pending font loads<a class=self-link href=#possibly-pending-font-loads></a></dfn>.
<p> <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> objects also have internal
<dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=attribute data-export="" id=dom-fontfaceset-loadingfonts>[LoadingFonts]<a class=self-link href=#dom-fontfaceset-loadingfonts></a></dfn>,
<dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=attribute data-export="" id=dom-fontfaceset-loadedfonts>[LoadedFonts]<a class=self-link href=#dom-fontfaceset-loadedfonts></a></dfn>,
<dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=attribute data-export="" id=dom-fontfaceset-failedfonts>[FailedFonts]<a class=self-link href=#dom-fontfaceset-failedfonts></a></dfn>,
and <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=attribute data-export="" id=dom-fontfaceset-pendingreadypromises>[PendingReadyPromises]<a class=self-link href=#dom-fontfaceset-pendingreadypromises></a></dfn> attributes,
all of which are initialized to the empty list.
<p class=issue id=issue-30993915><a class=self-link href=#issue-30993915></a>
Document the FontFaceSet behavior for Workers.
(They start out empty, but can construct fonts or be sent them via postMessage.)
<h3 class="heading settled heading" data-level=3.1 id=set-modifications><span class=secno>3.1 </span><span class=content>
Modifications of normal Set methods</span><a class=self-link href=#set-modifications></a></h3>
<p> The <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> methods <code>add()</code> and <code>delete()</code>
must throw an InvalidModificationError exception
if their argument is a <a data-link-type=dfn href=#css-connected title=css-connected>CSS-connected</a> <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> object.
<p> The <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> method <code>clear()</code>
must only remove the manually-added <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects;
the <a data-link-type=dfn href=#css-connected title=css-connected>CSS-connected</a> <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects are unaffected.
<h3 class="heading settled heading" data-level=3.2 id=FontFaceSet-events><span class=secno>3.2 </span><span class=content>
Events</span><a class=self-link href=#FontFaceSet-events></a></h3>
<p> Font load events make it easy to respond to the font-loading behavior of the entire document,
rather than having to listen to each font specifically.
The <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=event data-export="" id=dom-fontfaceset-loading>loading<a class=self-link href=#dom-fontfaceset-loading></a></dfn> event
fires when the document begins loading fonts,
while the <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=event data-export="" id=dom-fontfaceset-loadingdone>loadingdone<a class=self-link href=#dom-fontfaceset-loadingdone></a></dfn>
and <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=event data-export="" id=dom-fontfaceset-loadingerror>loadingerror<a class=self-link href=#dom-fontfaceset-loadingerror></a></dfn> events
fire when the document is done loading fonts,
containing the fonts that successfully loaded
or failed to load,
respectively.
<p> The following are the event handlers (and their corresponding event handler event types)
that must be supported by <code>FontFaceSet</code> objects as IDL attributes:
<table class=data id=eventhandlers>
<thead>
<tr>
<th>Event handler
<th>Event handler event type
<tbody>
<tr>
<th><a class=idl-code data-link-type=attribute href=#dom-fontfaceset-onloading title=onloading>onloading</a>
<td><a class=idl-code data-link-type=event href=#dom-fontfaceset-loading title=loading>loading</a>
<tr>
<th><a class=idl-code data-link-type=attribute href=#dom-fontfaceset-onloadingdone title=onloadingdone>onloadingdone</a>
<td><a class=idl-code data-link-type=event href=#dom-fontfaceset-loadingdone title=loadingdone>loadingdone</a>
<tr>
<th><a class=idl-code data-link-type=attribute href=#dom-fontfaceset-onloadingerror title=onloadingerror>onloadingerror</a>
<td><a class=idl-code data-link-type=event href=#dom-fontfaceset-loadingerror title=loadingerror>loadingerror</a>
</table>
<p> To <dfn data-dfn-type=dfn data-noexport="" id=fire-a-font-load-event>fire a font load event<a class=self-link href=#fire-a-font-load-event></a></dfn> named <var>e</var>
at a <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> <var>target</var>
with optional <var>font faces</var>
means to
<a href=http://www.w3.org/TR/html5/webappapis.html#event-firing>fire a simple event</a> named <var>e</var>
using the <a class=idl-code data-link-type=interface href=#dom-cssfontfaceloadevent title=cssfontfaceloadevent>CSSFontFaceLoadEvent</a> interface that also meets these conditions:
<ol>
<li>
The <a class=idl-code data-link-type=attribute href=#dom-cssfontfaceloadevent-fontfaces title=fontfaces>fontfaces</a> attribute is initialized to the given list of <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects.
</ol>
<p> Whenever a <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> in a given <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> <var>font face set</var>
changes its <a class=idl-code data-link-for=FontFace data-link-type=attribute href=#dom-fontface-status title=status>status</a> attribute to
<p> Whenever one or more <a data-link-type=dfn href=#available-font-faces title="available font faces">available font faces</a> for a given <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a>
change their <a class=idl-code data-link-for=FontFace data-link-type=attribute href=#dom-fontface-status title=status>status</a> attribute to "loading",
the user agent must run the following steps:
<ol>
<li>
Let <var>font face set</var> be the given <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a>,
and <var>loading fonts</var> be the <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects
that have newly switched to "loading" status,
in the same order as they appear in <var>font face set</var>.
<li>
Set the <a class=idl-code data-link-for=FontFaceSet data-link-type=attribute href=#dom-fontfaceset-status title=status>status</a> attribute of <var>font face set</var> to "loading".
<li>
If <var>font face set’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-loadingfonts title=[loadingfonts]>[LoadingFonts]</a> attribute is currently empty,
<a data-link-type=dfn href=#fire-a-font-load-event title="fire a font load event">fire a font load event</a> named <a class=idl-code data-link-type=event href=#dom-fontfaceset-loading title=loading>loading</a> at <var>font face set</var>.
<li>
Append the <var>loading fonts</var> to <var>font face set’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-loadingfonts title=[loadingfonts]>[LoadingFonts]</a> attribute.
</ol>
<p> Whenever one or more <a data-link-type=dfn href=#available-font-faces title="available font faces">available font faces</a> for a given <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a>
change their <a class=idl-code data-link-for=FontFace data-link-type=attribute href=#dom-fontface-status title=status>status</a> attribute to "loaded" or "error",
the user agent must run the following steps:
<ol>
<li>
Let <var>font face set</var> be the given <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a>,
and <var>loaded fonts</var> be the <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects
that have newly switched to "loaded" or "error" status,
in the same order as they appear in <var>font face set</var>.
<li>
For each font in the <var>loaded fonts</var>,
if their <a class=idl-code data-link-for=FontFace data-link-type=attribute href=#dom-fontface-status title=status>status</a> attribute is "loaded",
append them to <var>font face set’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-loadedfonts title=[loadedfonts]>[LoadedFonts]</a> attribute;
if it’s "error",
append them to <var>font face set’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-failedfonts title=[failedfonts]>[FailedFonts]</a> attribute.
</ol>
<p> If there are ever <a data-link-type=dfn href=#no-pending-font-loads title="no pending font loads">no pending font loads</a>
and either of <var>font face set’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-loadedfonts title=[loadedfonts]>[LoadedFonts]</a> or <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-failedfonts title=[failedfonts]>[FailedFonts]</a> attributes are not empty,
user agents must run these steps:
<ol>
<li>
Set <var>font face set’s</var> <a class=idl-code data-link-for=FontFaceSet data-link-type=attribute href=#dom-fontfaceset-status title=status>status</a> attribute to "loaded".
<li>
<a data-link-type=dfn href=#fire-a-font-load-event title="fire a font load event">Fire a font load event</a> named <a class=idl-code data-link-type=event href=#dom-fontfaceset-loadingdone title=loadingdone>loadingdone</a> at <var>font face set</var>
with the contents of <var>font face set’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-loadedfonts title=[loadedfonts]>[LoadedFonts]</a> attribute, if any.
<li>
If <var>font face set’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-failedfonts title=[failedfonts]>[FailedFonts]</a> attribute is non-empty,
<a data-link-type=dfn href=#fire-a-font-load-event title="fire a font load event">fire a font load event</a> named <a class=idl-code data-link-type=event href=#dom-fontfaceset-loadingerror title=loadingerror>loadingerror</a> at <var>font face set</var>
with the contents of <var>font face set’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-failedfonts title=[failedfonts]>[FailedFonts]</a> attribute.
<li>
If <var>font face set’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-pendingreadypromises title=[pendingreadypromises]>[PendingReadyPromises]</a> attribute is non-empty,
fulfill each promise in the attribute’s value with <var>font face set</var>.
<li>
Empty <var>font face set’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-loadingfonts title=[loadingfonts]>[LoadingFonts]</a>, <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-loadedfonts title=[loadedfonts]>[LoadedFonts]</a>, <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-failedfonts title=[failedfonts]>[FailedFonts]</a>, and <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-pendingreadypromises title=[pendingreadypromises]>[PendingReadyPromises]</a> attributes.
</ol>
<h3 class="heading settled heading" data-level=3.3 id=font-face-set-match><span class=secno>3.3 </span><span class=content>
The <code>match()</code> method</span><a class=self-link href=#font-face-set-match></a></h3>
<p> The <a data-link-for=FontFaceSet data-link-type=functionish href=#dom-fontfaceset-match title=match()>match()</a> method of <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> returns
the subset of <a data-link-type=dfn href=#available-font-faces title="available font faces">available font faces</a>
that match a given <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-fonts-3/#propdef-font title=font>font</a> specifier
and can render the given characters.
<p> When the <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=method data-export="" id=dom-fontfaceset-match title=match()>match(<dfn class=idl-code data-dfn-for="FontFaceSet/match() match()" data-dfn-type=argument data-export="" id=dom-fontfacesetmatch-match-font>font<a class=self-link href=#dom-fontfacesetmatch-match-font></a></dfn>, <dfn class=idl-code data-dfn-for="FontFaceSet/match() match()" data-dfn-type=argument data-export="" id=dom-fontfacesetmatch-match-text>text<a class=self-link href=#dom-fontfacesetmatch-match-text></a></dfn>)<a class=self-link href=#dom-fontfaceset-match></a></dfn> method is called,
execute these steps:
<ol>
<li>
Parse the value of the <a class=idl-code data-link-for=load() data-link-type=argument href=#dom-fontfacesetload-load-font title=font>font</a> argument,
using the CSS value syntax of the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-fonts-3/#propdef-font title=font>font</a> property.
<li>
If a syntax error occurs,
throw a SyntaxError exception.
<li>
Otherwise, let <var>font family list</var> be the set of families and
<var>font style</var> be the other font style attributes.
<li>
For each family in <var>font family list</var>,
use the font matching rules to select the <a data-link-type=dfn href=#available-font-faces title="available font faces">available font faces</a> that match the <var>font style</var>.
The use of the <a class=idl-code data-link-type=attribute href=#dom-fontface-unicoderange title=unicoderange>unicodeRange</a> attribute means that this may be more than just a single font face.
<li>
Remove from the set of font faces all faces that have defined <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-fonts-3/#descdef-unicode-range title=unicode-range>unicode-range</a>
values that don’t intersect the range of character values in the <a class=idl-code data-link-for=load() data-link-type=argument href=#dom-fontfacesetload-load-text title=text>text</a>
argument and set this to be the <var>font load list</var>.
<li>
Return the <var>font load list</var>.
</ol>
<h3 class="heading settled heading" data-level=3.4 id=font-face-set-load><span class=secno>3.4 </span><span class=content>
The <code>load()</code> method</span><a class=self-link href=#font-face-set-load></a></h3>
<p> The <a data-link-for=FontFaceSet data-link-type=functionish href=#dom-fontfaceset-load title=load()>load()</a> method of <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> will determine whether all fonts in the given font list
have been loaded and are available.
If any fonts are downloadable fonts and have not already been loaded,
the user agent will initiate the load of each of these fonts.
It returns a Promise,
which is fulfilled when all of the fonts are loaded and ready to be used,
or rejected if any font failed to load properly.
<p> When the <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=method data-export="" id=dom-fontfaceset-load title=load()>load(<dfn class=idl-code data-dfn-for="FontFaceSet/load() load()" data-dfn-type=argument data-export="" id=dom-fontfacesetload-load-font>font<a class=self-link href=#dom-fontfacesetload-load-font></a></dfn>, <dfn class=idl-code data-dfn-for="FontFaceSet/load() load()" data-dfn-type=argument data-export="" id=dom-fontfacesetload-load-text>text<a class=self-link href=#dom-fontfacesetload-load-text></a></dfn>)<a class=self-link href=#dom-fontfaceset-load></a></dfn> method is called,
execute these steps:
<ol data-link-type=idl>
<li>
Let <var>font face set</var> be the <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> object this method was called on.
Let <var>promise</var> be a newly-created promise object.
<li>
Return <var>promise</var>.
Complete the rest of these steps asynchronously.
<li>
Call <var>font face set’s</var> <a class=idl-code data-link-for=FontFaceSet data-link-type=method href=#dom-fontfaceset-match title=match()>match()</a> method
with the same arguments as this method,
and let <var>font face list</var> be the return value.
If <a class=idl-code data-link-for=FontFaceSet data-link-type=method href=#dom-fontfaceset-match title=match()>match()</a> threw an exception,
reject <var>promise</var> with that same exception and terminate these steps.
<li>
For all of the font faces in the <var>font face list</var>,
call their <a class=idl-code data-link-for=FontFace data-link-type=method href=#dom-fontface-load title=load()>load()</a> method.
<li>
Resolve <var>promise</var> with the result of
waiting for all of the <a data-link-type=idl href=#dom-fontface-fontstatuspromise title=[fontstatuspromise]>[FontStatusPromise]</a>s of each font face in the <var>font face list</var>, in order.
</ol>
<h3 class="heading settled heading" data-level=3.5 id=font-face-set-check><span class=secno>3.5 </span><span class=content>
The <code>check()</code> method</span><a class=self-link href=#font-face-set-check></a></h3>
<p> The <a data-link-type=functionish href=#dom-fontfaceset-check title=check()>check()</a> method of <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> will determine whether all fonts in the given font list
have been loaded and are available.
If all fonts are available,
it returns true;
otherwise, it returns false.
<p> When the <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=method data-export="" id=dom-fontfaceset-check title=check()>check(<dfn class=idl-code data-dfn-for="FontFaceSet/check() check()" data-dfn-type=argument data-export="" id=dom-fontfacesetcheck-check-font>font<a class=self-link href=#dom-fontfacesetcheck-check-font></a></dfn>, <dfn class=idl-code data-dfn-for="FontFaceSet/check() check()" data-dfn-type=argument data-export="" id=dom-fontfacesetcheck-check-text>text<a class=self-link href=#dom-fontfacesetcheck-check-text></a></dfn>)<a class=self-link href=#dom-fontfaceset-check></a></dfn> method is called,
execute these steps:
<ol>
<li>
Let <var>font face set</var> be the <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> object this method was called on.
<li>
Call <var>font face set’s</var> <a class=idl-code data-link-for=FontFaceSet data-link-type=method href=#dom-fontfaceset-match title=match()>match()</a> method
with the same arguments as this method,
and let <var>font face list</var> be the return value.
If <a class=idl-code data-link-for=FontFaceSet data-link-type=method href=#dom-fontfaceset-match title=match()>match()</a> threw an exception,
throw that same exception and terminate these steps.
<li>
If the <var>font face list</var> contains no font faces,
return <code class=idl-code>false</code>.
<li>
If all fonts in the <var>font face list</var> have a <a class=idl-code data-link-for=FontFace data-link-type=attribute href=#dom-fontface-status title=status>status</a> attribute of "loaded",
return <code>true</code>.
Otherwise, return <code>false</code>.
</ol>
<h3 class="heading settled heading" data-level=3.6 id=font-face-set-ready><span class=secno>3.6 </span><span class=content>
The <code>ready()</code> method</span><a class=self-link href=#font-face-set-ready></a></h3>
<p> Because the number of fonts loaded depends on the how many fonts are used for a given piece of text,
in some cases whether fonts need to be loaded or not may not be known.
The <a data-link-for=FontFaceSet data-link-type=functionish href=#dom-fontfaceset-ready title=ready()>ready()</a> method returns a Promise which is resolved when the document is done loading fonts,
which provides a way for authors to avoid having to keep track of which fonts have or haven’t been loaded
before examining content which may be affected by loading fonts.
<p> When the <dfn class=idl-code data-dfn-for=FontFaceSet data-dfn-type=method data-export="" id=dom-fontfaceset-ready title=ready()>ready()<a class=self-link href=#dom-fontfaceset-ready></a></dfn> method is called,
execute these steps:
<ol>
<li>
Let <var>font face set</var> be the <a class=idl-code data-link-type=interface href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> object this method was called on.
Let <var>ready promise</var> be a fresh Promise which is initially pending.
<li>
If <var>font face set’s</var> <a class=idl-code data-link-for=FontFaceSet data-link-type=attribute href=#dom-fontfaceset-status title=status>status</a> attribute is "loaded",
fulfill <var>ready promise</var> with <var>font face set</var>.
Otherwise, append <var>ready promise</var>
to <var>font face set’s</var> <a class=idl-code data-link-type=attribute href=#dom-fontfaceset-pendingreadypromises title=[pendingreadypromises]>[PendingReadyPromises]</a> attribute.
<li>
Return <var>ready promise</var>.
</ol>
<p class=note> Note: Authors should note that a given <var>ready promise</var> is only fulfilled once,
but further fonts may be loaded after it fulfills.
This is similar to listening for a <a class=idl-code data-link-type=event href=#dom-fontfaceset-loadingdone title=loadingdone>loadingdone</a> event to fire,
but the callbacks passed to the <a class=idl-code data-link-for=FontFaceSet data-link-type=method href=#dom-fontfaceset-ready title=ready()>ready()</a> promise will <strong>always</strong> get called,
even when no font loads occur because the fonts in question are already loaded.
It’s a simple, easy way to synchronize code to font loads
without the need to keep track of what fonts are needed and precisely when they load.
<p class=note> Note: Note that the user agent may need to iterate over multiple font loads before the <var>ready promise</var> is fulfilled.
This can occur with font fallback situations,
where one font in the fontlist is loaded
but doesn’t contain a particular glyph
and other fonts in the fontlist need to be loaded.
The <var>ready promise</var> is only fulfilled after layout operations complete
and no additional font loads are necessary.
<p class=note> Note: Note that the Promise returned by this <a class=idl-code data-link-for=FontFaceSet data-link-type=method href=#dom-fontfaceset-ready title=ready()>ready()</a> method is only ever fulfilled,
never rejected,
unlike the Promise returned by the <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> <a class=idl-code data-link-for=FontFace data-link-type=method href=#dom-fontface-ready title=ready()>ready()</a> method.
<h3 class="heading settled heading" data-level=3.7 id=font-face-set-css><span class=secno>3.7 </span><span class=content>
Interaction with CSS Font Loading and Matching</span><a class=self-link href=#font-face-set-css></a></h3>
<p> When the font matching algorithm in <a data-biblio-type=informative data-link-type=biblio href=#css3-fonts title=css3-fonts>[CSS3-FONTS]</a> is run automatically by the user-agent,
the set of font faces it matches over must be precisely the set of fonts in the <a data-link-type=dfn href=#font-source title="font source">font source</a> for the document,
plus any local font faces.
<p> When a user-agent needs to load a font face,
it must do so by calling the <a class=idl-code data-link-for=FontFace data-link-type=method href=#dom-fontface-load title=load()>load()</a> method
of the corresponding <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> object.
<p> (This means it must run the same algorithm,
not literally call the value currently stored in the <code>load</code> property of the object.)
<h2 class="heading settled heading" data-level=4 id=font-face-source><span class=secno>4 </span><span class=content>
The <code>FontFaceSource</code> interface</span><a class=self-link href=#font-face-source></a></h2>
<pre class=idl>interface <dfn class=idl-code data-dfn-type=interface data-export="" data-global-name="" id=dom-fontfacesource title=FontFaceSource>FontFaceSource<a class=self-link href=#dom-fontfacesource></a></dfn> {
readonly attribute <a data-link-type=idl href=#dom-fontfaceset title=fontfaceset>FontFaceSet</a> <dfn class=idl-code data-dfn-for=FontFaceSource data-dfn-type=attribute data-export="" data-global-name="FontFaceSource<interface>/fonts<attribute>" id=dom-fontfacesource-fonts title=fonts>fonts<a class=self-link href=#dom-fontfacesource-fonts></a></dfn>;
};
<a data-link-type=idl href=http://www.w3.org/html/wg/drafts/html/CR/dom.html#document title=document>Document</a> implements <a data-link-type=idl href=#dom-fontfacesource title=fontfacesource>FontFaceSource</a>;
<a data-link-type=idl title=workerglobalscope>WorkerGlobalScope</a> implements <a data-link-type=idl href=#dom-fontfacesource title=fontfacesource>FontFaceSource</a>;
</pre>
<p> Any document, workers, or other context which can use fonts in some manner must implement the <a class=idl-code data-link-type=interface href=#dom-fontfacesource title=fontfacesource>FontFaceSource</a> interface.
The value of the context’s <a class=idl-code data-link-type=attribute href=#dom-fontfacesource-fonts title=fonts>fonts</a> attribute is its <dfn data-dfn-type=dfn data-noexport="" id=font-source>font source<a class=self-link href=#font-source></a></dfn>,
which provides all of the fonts used in font-related operations,
unless defined otherwise.
Operations referring to “the font source” must be interpreted as referring to the <a data-link-type=dfn href=#font-source title="font source">font source</a> of the relevant context in which the operation is taking place.
<p> For any font-related operation that takes place within one of these contexts,
the <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects within the <a data-link-type=dfn href=#font-source title="font source">font source</a> are its <dfn data-dfn-type=dfn data-noexport="" id=available-font-faces>available font faces<a class=self-link href=#available-font-faces></a></dfn>.
<h3 class="heading settled heading" data-level=4.1 id=document-font-face-set><span class=secno>4.1 </span><span class=content>
Interaction with CSS’s <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> Rule</span><a class=self-link href=#document-font-face-set></a></h3>
<p> The set entries for a document’s <a data-link-type=dfn href=#font-source title="font source">font source</a>
must be initially populated with all the <a data-link-type=dfn href=#css-connected title=css-connected>CSS-connected</a> <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects
from all of the CSS <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rules in the document’s stylesheets,
in document order.
As <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rules are added or removed from a stylesheet,
or stylesheets containing <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-fonts-3/#at-font-face-rule title=@font-face>@font-face</a> rules are added or removed,
the corresponding <a data-link-type=dfn href=#css-connected title=css-connected>CSS-connected</a> <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects
must be added or removed from the document’s <a data-link-type=dfn href=#font-source title="font source">font source</a>,
and maintain this ordering.
<p> All non-<a data-link-type=dfn href=#css-connected title=css-connected>CSS-connected</a> <a class=idl-code data-link-type=interface href=#dom-fontface title=fontface>FontFace</a> objects must be sorted after the <a data-link-type=dfn href=#css-connected title=css-connected>CSS-connected</a> ones,
in insertion order.
<p class=issue id=issue-86d79dbc><a class=self-link href=#issue-86d79dbc></a>
Can/should we include the local system fonts,
or is that a fingerprinting problem?
I think the set of local fonts is trivially discoverable anyway.
Alternately, define a specialized variant of FontFace which represents all the local fonts collectively,
and perhaps can be queried against?
This would make FontFaceSet fully explain the current behavior of fonts.
<h2 class="heading settled heading" data-level=5 id=font-load-event-examples><span class=secno>5 </span><span class=content>
API Examples</span><a class=self-link href=#font-load-event-examples></a></h2>
<div class=example>
To show content only after all font loads complete:
<pre> document.FontFaceSet.ready().then(function() {
var content = document.getElementById("content");
content.style.visibility = "visible";
});
</pre> </div>
<div class=example>
Drawing text in a canvas with a downloadable font, explicitly
initiating the font download and drawing upon completion:
<pre> function drawStuff() {
var ctx = document.getElementById("c").getContext("2d");
ctx.fillStyle = "red";
ctx.font = "50px MyDownloadableFont";
ctx.fillText("Hello!", 100, 100);
}
document.fonts.load("50px MyDownloadableFont")
.then(drawStuff, handleError);
</pre> </div>
<div class=example>
A rich text editing application may need to measure text elements
after editing operations have taken place. Since style changes may
or may not require additional fonts to be downloaded, or the fonts
may already have been downloaded, the measurement procedures need to
occur after those font loads complete:
<pre> function measureTextElements() {
// contents can now be measured using the metrics of
// the downloadable font(s)
}
function doEditing() {
// content/layout operations that may cause additional font loads
document.fonts.ready().then(measureTextElements);
}
</pre> </div>
<div class=example>
The <a class=idl-code data-link-type=event href=#dom-fontfaceset-loadingdone title=loadingdone>loadingdone</a> event only fires after all font related loads have completed
<strong>and</strong> text has been laid out without causing additional font loads:
<pre> @font-face {
font-family: latin-serif;
src: url(latinserif.woff) format("woff"); /* contains no kanji/kana */
}
@font-face {
font-family: jpn-mincho;
src: url(mincho.woff) format("woff");
}
body { font-family: latin-serif, jpn-mincho; }
<p>納豆はいかがでしょうか
</pre>
<p> In this situation, the user agent first downloads “latinserif.woff”
and then tries to use this to draw the Japanese text. But because no
Japanese glyphs are present in that font, fallback occurs and the font
“mincho.woff” is downloaded. Only after the second font is downloaded
and the Japanese text laid out does the <a class=idl-code data-link-type=event href=#dom-fontfaceset-loadingdone title=loadingdone>loadingdone</a>
event fire.
</div>
<h2 class="no-num heading settled heading" id=changes><span class=content>Changes</span><a class=self-link href=#changes></a></h2>
<h3 class="no-num heading settled heading" id=changes-since-20130212><span class=content>
Changes from the <a href=http://www.w3.org/TR/2013/WD-css3-fonts-20130212/>February 2013 CSS3 Fonts Working Draft</a></span><a class=self-link href=#changes-since-20130212></a></h3>
<p> Major changes include:
<p> <ul>
<li>Add details of font load errors.
<li>Switched to a promise-based design for load() and ready().
<li>Renamed notifyWhenFontsReady() to ready().
<li>Added a match() method, to directly expose the font matching algorithm.
<li>Added a FontFace interface, to directly represent the individual font faces, and allow manual construction of font faces without having to indirect through a @font-face rule.
<li>Dropped the per-font events, in favor of promise-based methods on FontFace.
</ul>
<h2 class="no-num heading settled heading" id=acknowledgments><span class=content>
Acknowledgments</span><a class=self-link href=#acknowledgments></a></h2>
<p> Several members of the Google Fonts team provided helpful feedback on font load events,
as did Boris Zbarsky, Jonas Sicking and ms2ger.
<h2 class="no-ref no-num heading settled heading" id=conformance><span class=content>
Conformance</span><a class=self-link href=#conformance></a></h2>
<h3 class="no-ref heading settled heading" id=conventions><span class=content>
Document conventions</span><a class=self-link href=#conventions></a></h3>
<p>Conformance requirements are expressed with a combination of
descriptive assertions and RFC 2119 terminology. The key words "MUST",
"MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT",
"RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this
document are to be interpreted as described in RFC 2119.
However, for readability, these words do not appear in all uppercase
letters in this specification.
<p>All of the text of this specification is normative except sections
explicitly marked as non-normative, examples, and notes. <a data-biblio-type=normative data-link-type=biblio href=#rfc2119 title=rfc2119>[RFC2119]</a></p>
<p>Examples in this specification are introduced with the words "for example"
or are set apart from the normative text with <code>class="example"</code>,
like this:
<div class=example>
<p>This is an example of an informative example.</p>
</div>
<p>Informative notes begin with the word "Note" and are set apart from the
normative text with <code>class="note"</code>, like this:
<p class=note>Note, this is an informative note.</p>
<h3 class="no-ref heading settled heading" id=conformance-classes><span class=content>
Conformance classes</span><a class=self-link href=#conformance-classes></a></h3>
<p>Conformance to this specification
is defined for three conformance classes:
<dl>
<dt>style sheet
<dd>A <a href=http://www.w3.org/TR/CSS21/conform.html#style-sheet>CSS
style sheet</a>.
<dt>renderer
<dd>A <a href=http://www.w3.org/TR/CSS21/conform.html#user-agent>UA</a>
that interprets the semantics of a style sheet and renders
documents that use them.
<dt>authoring tool
<dd>A <a href=http://www.w3.org/TR/CSS21/conform.html#user-agent>UA</a>
that writes a style sheet.
</dl>
<p>A style sheet is conformant to this specification
if all of its statements that use syntax defined in this module are valid
according to the generic CSS grammar and the individual grammars of each
feature defined in this module.
<p>A renderer is conformant to this specification
if, in addition to interpreting the style sheet as defined by the
appropriate specifications, it supports all the features defined
by this specification by parsing them correctly
and rendering the document accordingly. However, the inability of a
UA to correctly render a document due to limitations of the device
does not make the UA non-conformant. (For example, a UA is not
required to render color on a monochrome monitor.)
<p>An authoring tool is conformant to this specification
if it writes style sheets that are syntactically correct according to the
generic CSS grammar and the individual grammars of each feature in
this module, and meet all other conformance requirements of style sheets
as described in this module.
<h3 class="no-ref heading settled heading" id=partial><span class=content>
Partial implementations</span><a class=self-link href=#partial></a></h3>
<p>So that authors can exploit the forward-compatible parsing rules to
assign fallback values, CSS renderers <strong>must</strong>