Re: [css-font-loading] what happens when you modify a FontFace descriptor?

On Fri, Jul 4, 2014 at 6:36 PM, Cameron McCormack <cam@mcc.id.au> wrote:
> The spec say that when you assign to one of the descriptor attributes on a
> FontFace that you parse the value, and if it parsed correctly, set the
> attribute to that value.  But what is the result of doing that if the
> FontFace is in the FontFaceSet?  Presumably it causes the UA to re-run the
> font matching algorithm referred to in section 3.5, although it's not clear
> that that is actually required.

Yes, that's intended.

> What happens when you initially construct a FontFace with an invalid set of
> descriptor values, but then later you assign valid values to those
> attributes?  I think according to what the spec currently says, it should be
> loadable now -- despite the fact that its [[FontStatusPromise]] has already
> been rejected.  If it should be loadable now, then maybe
> [[FontStatusPromise]] should be replaced by a fresh pending Promise.
>
> Alternatively the FontFace should be a forever invalid object that you can't
> load.  Setting the status to "error" as suggested in my previous mail would
> have the effect of making the FontFace forever invalid, due to step 2 of the
> load() algorithm.

Hm, okay, giving it more thought I'm now unsure of what I want to do.

The current behavior (throwing errors on setting and rejecting the
FontFace during construction) are not friendly for back-compat when we
add new things to @font-face; older UAs won't understand the new stuff
and will error out.  You could get around this by setting *no*
descriptors during construction, and then using try/catch to set the
descriptors afterward, but that's super ugly.

Maybe I should just ignore invalid descriptors?  That way I'd only
reject a font if its src descriptor was invalid during construction
(because I don't expose it for setting afterward).  You could check if
anything failed after parsing finished by probing the values to see if
they're the initial value or not.  If you set descriptors *after*
construction, you could just do what CSS does and set them multiple
times, starting with the oldest and ending with the newest; anything
too new to be understood will be ignored and leave you with the last
older one it understood.

Thoughts?

~TJ

Received on Monday, 7 July 2014 20:49:08 UTC