Skip to content

Commit c4464ce

Browse files
committed
[css-font-load-events] More definitionbikeshed
--HG-- extra : rebase_source : 00f6038a958e22af77b56d944b0b94fe7bc14156
1 parent 0300e20 commit c4464ce

2 files changed

Lines changed: 60 additions & 26 deletions

File tree

css-font-load-events/Overview.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
font-size: .9em;
6161
}
6262

63+
.idl-code .idl-code,
64+
pre .idl-code {
65+
font-size: 1em;
66+
}
67+
6368
pre.idl {
6469
white-space: pre-wrap;
6570
}
@@ -282,11 +287,11 @@ <h4 class="heading settled heading" data-level=2.2.1 id=font-face-constructor><s
282287

283288
<ol link-type=idl>
284289
<li>
285-
Create a fresh <a>FontFace</a> object, <var>font face.
290+
Let <var>font face</var> be a fresh <a>FontFace</a> object.
286291
Set <var>font face’s</var> <a href=#status0>status</a> argument to <code>"unloaded"</code>.
287292
Set its internal <a>[[FontStatusPromise]]</a> attribute to a fresh pending <a>Promise</a> object.
288293

289-
</var><li>
294+
<li>
290295
Parse the <a href=#family>family</a> argument,
291296
and the members of the <a>descriptors</a> argument,
292297
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>@font-face</a> rule.
@@ -413,7 +418,7 @@ <h3 class="heading settled heading" data-level=2.3 id=FontFaceSet-interface><spa
413418
readonly attribute DOMError? <dfn class=idl-code data-dfn-for=CSSFontFaceLoadEvent data-dfn-type=attribute data-export="" id=dom-cssfontfaceloadevent-error>error<a class=self-link href=#dom-cssfontfaceloadevent-error></a></dfn> = null;
414419
}
415420

416-
[SetClass(FontFace)]
421+
[SetClass(<a class=idl-code data-link-type=interface>FontFace</a>)]
417422
interface <dfn class=idl-code data-dfn-type=interface data-export="" id=dom-fontfaceset>FontFaceSet<a class=self-link href=#dom-fontfaceset></a></dfn> {
418423

419424
// -- events for when loading state changes

css-font-load-events/Overview.src.html

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ <h1>CSS Font Load Events Module Level 3</h1>
6767
font-size: .9em;
6868
}
6969

70+
.idl-code .idl-code,
71+
pre .idl-code {
72+
font-size: 1em;
73+
}
74+
7075
pre.idl {
7176
white-space: pre-wrap;
7277
}
@@ -135,7 +140,7 @@ <h3 id="fontface-interface">
135140
attribute DOMString variant;
136141
attribute DOMString featureSettings;
137142

138-
attribute FontFaceLoadStatus status;
143+
readonly attribute FontFaceLoadStatus status;
139144

140145
// If the font face's source is url-based and its status isn't
141146
// "loading" or "loaded", this kicks off the load.
@@ -182,6 +187,11 @@ <h3 id="fontface-interface">
182187
<dd>
183188
This attribute reflects the current status of the font face.
184189
It must be "unloaded" for a newly-created <a interface>FontFace</a>.
190+
191+
It can change due to an author explicitly requesting a font face to load,
192+
such as through the <a method for=FontFace>load()</a> method on <a interface>FontFace</a>,
193+
or implicitly by the user agent,
194+
due to it detecting that the font face is needed to draw some text on the screen.
185195
</dl>
186196

187197
All <a interface>FontFace</a> objects contain an internal <dfn attribute for=FontFace>[[FontStatusPromise]]</dfn> attribute,
@@ -190,8 +200,8 @@ <h3 id="fontface-interface">
190200
and fulfills or rejects when the font is successfully loaded and parsed, or hits an error.
191201

192202
All <a interface>FontFace</a> objects also contain
193-
internal <dfn attribute for=FontFace>[[Url]]</dfn> and <dfn attribute for=FontFace>[[Data]]</dfn> attributes,
194-
of which one is always <code>null</code> and the other is non-<code>null</code>.
203+
internal <dfn attribute for=FontFace>[[Url]]</dfn>, <dfn attribute for=FontFace>[[CSSUrl]]</dfn>, and <dfn attribute for=FontFace>[[Data]]</dfn> attributes,
204+
of which one is not <code>null</code> and the rest are <code>null</code>.
195205

196206
<h4 id='font-face-constructor'>
197207
The Constructor</h4>
@@ -205,7 +215,7 @@ <h4 id='font-face-constructor'>
205215

206216
<ol link-type=idl>
207217
<li>
208-
Create a fresh <a>FontFace</a> object, <var>font face</a>.
218+
Let <var>font face</var> be a fresh <a>FontFace</a> object.
209219
Set <var>font face's</var> <a>status</a> argument to <code>"unloaded"</code>.
210220
Set its internal <a>[[FontStatusPromise]]</a> attribute to a fresh pending <a>Promise</a> object.
211221

@@ -322,6 +332,23 @@ <h4 id='font-face-match'>
322332
<p class='issue'>
323333
Refer to Font's font matching algorithm somehow.
324334

335+
<h4 id='font-face-css-connection'>
336+
Connection to CSS's ''@font-face''</h4>
337+
338+
A CSS ''@font-face'' rule automatically defines a corresponding <a interface>FontFace</a> object,
339+
which is automatically placed in the document's <a attribute>fonts</a> attribute.
340+
341+
The <a interface>FontFace</a> object corresponding to a ''@font-face'' rule
342+
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.
343+
There is a two-way connection between the two:
344+
any change made to a ''@font-face'' descriptor is immediately reflected in the corresponding <a interface>FontFace</a> attribute,
345+
and vice versa.
346+
347+
The internal <a attribute>[[CSSUrl]]</a> attribute of the <a interface>FontFace</a> object is set to the value of the ''@font-face'' rule's 'src' descriptor,
348+
and reflects any changes made to the 'src' descriptor.
349+
350+
Otherwise, a <a interface>FontFace</a> object created by a CSS ''@font-face'' rule is identical to one created manually.
351+
325352
<h3 id="FontFaceSet-interface">
326353
The <code>FontFaceSet</code> Interface</h3>
327354

@@ -337,7 +364,9 @@ <h3 id="FontFaceSet-interface">
337364
readonly attribute DOMError? <dfn attribute for=CSSFontFaceLoadEvent>error</dfn> = null;
338365
}
339366

340-
[SetClass(FontFace)]
367+
enum FontFaceSetLoadStatus { "loading", "loaded" };
368+
369+
[SetClass(<a interface>FontFace</a>)]
341370
interface <dfn interface>FontFaceSet</dfn> {
342371

343372
// -- events for when loading state changes
@@ -346,11 +375,11 @@ <h3 id="FontFaceSet-interface">
346375

347376
// check and start load if appropriate
348377
// and fulfill promise when all loads complete
349-
Promise <a method for=FontFaceSet title="loadFont()">loadFont</a>(DOMString font, optional DOMString text = " ");
378+
Promise <a method for=FontFaceSet title="load()">load</a>(DOMString font, optional DOMString text = " ");
350379

351380
// return whether all fonts in the fontlist are loaded
352381
// (does not initiate load if not available)
353-
boolean <a method for=FontFaceSet title="checkFont()">checkFont</a>(DOMString font, optional DOMString text = " ");
382+
boolean <a method for=FontFaceSet title="check()">check</a>(DOMString font, optional DOMString text = " ");
354383

355384
// async notification that font loading and layout operations are done
356385
Promise <a method for=FontFaceSet title="ready()">ready</a>();
@@ -531,18 +560,18 @@ <h4 id='FontFaceSet-events'>
531560
load events (i.e. <a event>loading</a> and <a event>loadingdone</a>).
532561
This seems fine but need to confirm this.
533562

534-
<h4 id='loadfont-method'>
535-
The <code>loadFont()</code> method</h4>
563+
<h4 id='load-method'>
564+
The <code>load()</code> method</h4>
536565

537-
The <a>loadFont()</a> method of <a interface>FontFaceSet</a> will determine whether all fonts in the given font list
566+
The <a>load()</a> method of <a interface>FontFaceSet</a> will determine whether all fonts in the given font list
538567
have been loaded and are available.
539568
If any fonts are downloadable fonts and have not already been loaded,
540569
the user agent will initiate the load of each of these fonts.
541570
It returns a Promise,
542571
which is fulfilled when all of the fonts are loaded and ready to be used,
543572
or rejected if any font failed to load properly.
544573

545-
When the <dfn method for="FontFaceSet" title="loadFont()">loadFont(<dfn argument>font</dfn>, <dfn argument>text</dfn>)</dfn> method is called,
574+
When the <dfn method for="FontFaceSet" title="load()">load(<dfn argument>font</dfn>, <dfn argument>text</dfn>)</dfn> method is called,
546575
execute these steps:
547576

548577
<ol>
@@ -552,7 +581,7 @@ <h4 id='loadfont-method'>
552581
Run the remaining steps in this algorithm asynchronously.
553582

554583
<li>
555-
Parse the value of the <a argument for='loadFont()'>font</a> argument,
584+
Parse the value of the <a argument for='load()'>font</a> argument,
556585
using the CSS value syntax of the 'font' property.
557586

558587
<li>
@@ -571,7 +600,7 @@ <h4 id='loadfont-method'>
571600

572601
<li>
573602
Remove from the set of font faces all faces that have defined 'unicode-range'
574-
values that don't intersect the range of character values in the <a argument for='loadFont()'>text</a>
603+
values that don't intersect the range of character values in the <a argument for='load()'>text</a>
575604
argument and set this to be the <var>font load list</var>.
576605

577606
<li>
@@ -590,20 +619,20 @@ <h4 id='loadfont-method'>
590619
Resolve <var>font load promise</var> with the promise produced in the previous step.
591620
</ol>
592621

593-
<h4 id='checkfont-method'>
594-
The <code>checkFont()</code> method</h4>
622+
<h4 id='check-method'>
623+
The <code>check()</code> method</h4>
595624

596-
The <a>checkFont()</a> method of <a interface>FontFaceSet</a> will determine whether all fonts in the given font list
625+
The <a>check()</a> method of <a interface>FontFaceSet</a> will determine whether all fonts in the given font list
597626
have been loaded and are available.
598627
If all fonts are available,
599628
it returns true;
600629
otherwise, it returns false.
601630

602-
The <dfn method for="FontFaceSet" title="checkFont()">checkFont(<dfn argument>font</dfn>, <dfn argument>text</dfn>)</dfn> method must use these steps:
631+
The <dfn method for="FontFaceSet" title="check()">check(<dfn argument>font</dfn>, <dfn argument>text</dfn>)</dfn> method must use these steps:
603632

604633
<ol>
605634
<li>
606-
Parse the value of the <a argument for="checkFont()">font</a> parameter,
635+
Parse the value of the <a argument for="check()">font</a> parameter,
607636
using the CSS value syntax of the 'font' property.
608637

609638
<li>
@@ -621,7 +650,7 @@ <h4 id='checkfont-method'>
621650

622651
<li>
623652
Remove from the set of font faces all faces that have defined 'unicode-range'
624-
values that don't intersect the range of character values in the <a argument for="checkFont()">text</a>
653+
values that don't intersect the range of character values in the <a argument for="check()">text</a>
625654
parameter and set this to be the <var>font load list</var>.
626655

627656
<li>
@@ -632,8 +661,8 @@ <h4 id='checkfont-method'>
632661
return <code>true</code>. Otherwise, return <code>false</code>.
633662
</ol>
634663

635-
The <a argument for="checkFont()">font</a> parameter of <a>checkFont()</a>
636-
and <a>loadFont()</a> both specify the list of fonts to load.
664+
The <a argument for="check()">font</a> parameter of <a>check()</a>
665+
and <a>load()</a> both specify the list of fonts to load.
637666
These values must be parsed using the same syntax as values for the CSS 'font' property,
638667
the same way the <a attribute>font</a> attribute of the <a interface>CanvasRenderingContext2D</a> is interpreted. [[!HTML5]]
639668
This yields a list of font families along with font style attributes.
@@ -708,7 +737,7 @@ <h3 id="font-load-event-examples">
708737
ctx.fillText("Hello!", 100, 100);
709738
}
710739

711-
document.FontFaceSet.loadFont("50px MyDownloadableFont")
740+
document.FontFaceSet.load("50px MyDownloadableFont")
712741
.then(drawStuff, handleError);
713742
</pre>
714743
</div>
@@ -774,7 +803,7 @@ <h3 class="no-num" id="changes-since-20130212">
774803
<ul>
775804
<li>Add details of font load errors.
776805

777-
<li>Switched to a promise-based design for loadFont() and ready().
806+
<li>Switched to a promise-based design for load() and ready().
778807

779808
<li>Renamed notifyWhenFontsReady() to ready().
780809
</ul>

0 commit comments

Comments
 (0)