Re: [css-fonts] ready attribute vs function

On Tue, Oct 6, 2015 at 1:20 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:

> On Mon, Oct 5, 2015 at 9:47 PM, Rik Cabanier <cabanier@gmail.com> wrote:
> > On Sun, Oct 4, 2015 at 7:15 PM, John Daggett <jdaggett@mozilla.com>
> wrote:
> >> Rik Cabanier wrote:
> >>
> >> > The CSS font loading spec defines 'ready' as a function [1] returning
> >> > a promise but in Chrome it's implemented as a read only attribute.
> >> >
> >> > Is the spec out of date or did chrome implement it incorrectly?
> >> >
> >> > 1: http://www.w3.org/TR/css-font-loading-3/#dom-fontfaceset-ready
> >>
> >> Old spec, both Firefox and Chrome implement it an attribute as defined
> in
> >> the latest editor's draft:
> >>
> >> https://drafts.csswg.org/css-font-loading/#font-face-set-ready
> >
> >
> > Thanks John! I mistakenly clicked on "latest version" and not "editor's
> > draft".
> >
> > I've experimented a bit with this API on Chrome. Although it helpfully
> tells
> > me when fonts are loaded, it actually fulfills the promise before the
> fonts
> > are applied.
> > So, if I look at the page during the 'ready' phase, the font is still not
> > there. I can work around it by doing a 'requestAnimationFrame' but it
> seems
> > like the callback should happen after content that uses the fonts is laid
> > out. Thoughts?
>
> FontFace.ready() should fulfill as soon as the font is loaded.
> FontFaceSet.ready() is required to wait until layout operations are
> done; if it's not doing so, it's a bug and shoudl be reported.
> (That's the *entire point* of FontFaceSet.ready() - letting you know
> when the font-related stuff is "settled" and you can start measuring
> things.)
>

I agree. The font loading spec does not call out that distinction though:

The ready <https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-ready>
attribute
contains a Promise <https://drafts.csswg.org/css-font-loading/#promise> which
is resolved when the document is done loading fonts


Before I file a bug, it would be good if that is clarified in the spec.

Received on Tuesday, 6 October 2015 21:01:07 UTC