Open jpamental opened 5 years ago
Agreed, ty for reporting
Hi Jason, thanks for reporting this. Could you share a link to the relevant section of the spec?
Hi Nathan,
This seems to link to it closest: https://www.w3.org/TR/css-fonts-4/#font-face-src-requirement-types
Pardon my density but I don't see where that suggests format('woff2-variations')
. I thought I'd seen the -variations
suffix specified somewhere but I now can't seem to find it.
It feels like it's harder to see than it should be, but it's in this section (this is as close as I could find for a bookmark) https://www.w3.org/TR/css-fonts-4/#font-face-src-parsing
(so whatever the file format, it would be format('[format]-variations')
)
I read that as saying it should be format(woff2 supports variations)
similar to the example format(opentype supports color(COLR))
example 17.
I see woff2-variations
used in examples, including from Mozilla, but so far I don't see where it's specified.
It feels like it's harder to see than it should be, but it's in this section (this is as close as I could find for a bookmark) https://www.w3.org/TR/css-fonts-4/#font-face-src-parsing
(so whatever the file format, it would be format('[format]-variations')
) But I'm still digging. It looks like it was updated, but I'm not clear on exactly how to write it (or who supports writing it that way)
So the best I can piece together from various github issues, you're right @rsheeter - I'll test that out tomorrow and see where that actually works :) I missed that the syntax structure was changed at some point.
I did a bit of digging around in previous versions of the spec, and tested things out a bit.
I found the previous version that used to stipulate format('[format]-variations')
: https://www.w3.org/TR/2018/WD-css-fonts-4-20180410/#src-desc
This works in all browsers that support VFs, and matches up with what should result in a parse error if the browser doesn't support them (so avoiding a browser thinking it can load a font when it can't). That's why I think it's important to distinguish somehow between a variable and non-variable font in the declaration itself.
I did some testing and verified that the new syntax is indeed unsupported in every browser I tested (Safari, Chrome, and FF on Mac). I also checked with Myles to confirm that he had the same understanding regarding what the new syntax is supposed to be, and he concurred with your reading.
So here's what I tested out this morning, and think might be a good solution in order to support current and future syntaxes while still maintaining differentiation for browsers that don't support them (tested out on CodePen using Plex Sans):
@font-face {
font-family: "Plex Sans VF";
src:
url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/57225/IBMPlexSansVar-Roman.woff2")
format("woff2 supports variations"),
url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/57225/IBMPlexSansVar-Roman.woff2")
format("woff2-variations");
font-weight: 100 700;
font-stretch: 85% 100%;
font-style: normal;
font-display: swap;
}
This does work in all three, and once support for the new syntax starts rolling out (and that's something worth lobbying for since it's already in the spec) it will just start working.
Good catch re old spec rev. I don't particularly want to issue woff2-variations
given the current spec. I also don't want to issue a format that doesn't work. I fear that probably leads us to format("woff2")
pending browser support for the new syntax.
I get that. My reservation about it is mainly around education of developers using the service. They'll look at that as 'how it should be done', and that's the only version that was never in the spec. It just happens to work. If the solution were to include the 'new spec'/'past spec' version suggested above, that would be more in keeping with intent and progressive enhancement.
I know I'm being a bit pedantic—but I see so much outdated info coming out even now about how to use VFs, how well they're supported, etc that I'm perhaps a bit oversensitive. But I think it's important to make sure that anything put out by an authoritative source is as accurate and up-to-date as possible.
(but I also recognize that it's not my platform, so offering this just as a suggestion & opinion)
Cheers
Is this issue still relevant?
Hi there,
In digging in to the new API (announcement here for those who might not have seen it: https://codepen.io/nlwilliams/full/JjPJewp), I noticed that the
@font-face
syntax is a little out of sync with the spec. Not sure if there's a reason for this, so wanted to pose the question.When specifying the format, it should be
format('woff2-variations')
, but the CSS being served specificesformat('woff2')
. It would be good to make sure it's following the spec, as others will look to this implementation to learn how to use them.Example of current syntax:
should likely be: