W3C home > Mailing lists > Public > www-style@w3.org > October 2015

Re: [css-fonts] Shape of the CSSFontFaceRule interface

From: John Daggett <jdaggett@mozilla.com>
Date: Thu, 8 Oct 2015 10:34:55 +0900
Message-ID: <CALYZoVMy+G2SESoyFM2-xUQaug700YEgOzop6ov9B1nK_5Tx6Q@mail.gmail.com>
To: Greg Whitworth <gwhit@microsoft.com>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, www-style list <www-style@w3.org>
Greg Whitworth wrote:

> We currently don't expose any of this in our CSSOM for @font-face, but
> we don't think that any of the descriptors should reside under .style.
> We think that it should be in the FontFaceRule as described here with
> one little change, we think that it should be fontWeight, fontStyle,
> fontVariant, etc as just having style will be confusing with the
> .style which is a CSSStyleRuleDeclaration. Regarding that "it's fairly
> certain that sites depend on that shape" as an argument I can tell you
> that I have 0 bugs regarding this so you should feel safe to change :)

I agree, jamming things like unicodeRange into a CSSStyleDeclaration is
an unworkable hack.

But I don't really think the existence of 'style' as an attribute of
something called 'CSSFontFaceRule' is really all that confusing.

Current spec:

interface CSSFontFaceRule : CSSRule {
  attribute DOMString family;
  attribute DOMString src;
  attribute DOMString style;
  attribute DOMString weight;
  attribute DOMString stretch;
  attribute DOMString unicodeRange;
  attribute DOMString variant;
  attribute DOMString featureSettings;
}

What you're proposing is to use the same names for properties that exist
in a CSSStyleDeclaration:

interface CSSFontFaceRule : CSSRule {
  attribute DOMString fontFamily;
  attribute DOMString src;
  attribute DOMString fontStyle;
  attribute DOMString fontWeight;
  attribute DOMString fontStretch;
  attribute DOMString unicodeRange;
  attribute DOMString fontVariant;
  attribute DOMString fontFeatureSettings;
}

This doesn't seem like a great change to me. These values are
*descriptors* for an @font-face rule, not style properties. Prefixing
these with 'font' just makes code more unreadable and easy to confuse
with style properties. Authors reading script will quickly see the
difference for the 'style' attribute, since it's a string, not an object.

Altering an @font-face rule:

  rule.style = "italic";

Altering a style property:

  el.style.color = "red";

I think the existing spec definition is simpler and the chance of
confusion with a style declaration is minor.

Regards,

John Daggett


‚Äč
Received on Thursday, 8 October 2015 01:35:28 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:57 UTC