You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The src descriptor contains the url of the font to be downloaded, plus additional metadata so that unsuitable or unusable fonts are not wastefully downloaded.
17
+
The `src` descriptor contains the url of the font to be downloaded,
18
+
plus additional metadata so that unsuitable or
19
+
unusable fonts are not wastefully downloaded.
13
20
14
21
Other descriptors include the font family name,
15
22
the range of font weights supported,
@@ -150,6 +157,12 @@ and that combinatorial explosion would result
150
157
but "opentype-variation-SVG-Graphite" would become
151
158
unweildy and error-prone).
152
159
160
+
With the upcoming [COLRv1 color font format](https://github.com/googlefonts/colr-gradients-spec/),
161
+
selection of the right font resource and detectability are once again
162
+
important use cases which have been requested by early adopters of COLRv1,
163
+
similar to the need to detect availability and prefer such font resources at the time
164
+
when variable fonts where introduced.
165
+
153
166
## Use cases
154
167
155
168
1. I want to use color fonts,
@@ -170,8 +183,23 @@ For Chrome and Safari, I want to fall back to OpenType features.
170
183
Both fonts are in "opentype" format,
171
184
so again the font format by itself cannot be used to make the choice.
172
185
186
+
3. I want to know programmatically in my script code what level of font support is available.
187
+
188
+
Where 3. is in line in line with the TAG design principles, which recommend
189
+
[detectability of a feature](https://w3ctag.github.io/design-principles/#feature-detect).
190
+
191
+
## Non-Goals
192
+
193
+
This proposal is not-intended as a server-side content negotiation solution. In
194
+
many cases, third-party font providers currently choose based on User Agent
195
+
which resources they deliver to clients at the time of the request to the
196
+
included CSS. This is a different content negotiation mechanism from what is
197
+
discussed in this proposal.
198
+
173
199
## Design constraints & alternative solutions
174
200
201
+
### Backwards compatibility
202
+
175
203
The largest constraint is that older browsers must continue
176
204
to sucessfully parse the src descriptor,
177
205
and to end up ignoring links to fonts containg unsupported features,
@@ -199,33 +227,94 @@ and also a desire to avoid microsyntaxes which:
199
227
200
228
Thus, it was [resolved](https://github.com/w3c/csswg-drafts/issues/633#issuecomment-380469287) in 2018 to put the extra "supports" requirements inside the parentheses of the format hint, but without string concatenation.
201
229
230
+
### Strings vs. Keywords
231
+
202
232
There was also Issue 6340 [Drop bracket matching step from @font-face src: line parsing](https://github.com/w3c/csswg-drafts/issues/6340), resolved in June 2021,
203
233
about whether to do parenthesis matching before splitting the value of the src descriptor on commas.
204
234
205
-
The use cases mentioned above are then solved
206
-
using [the current syntax](https://drafts.csswg.org/css-fonts-4/#src-desc)
207
-
as follows:
208
-
209
-
/* 1. prefer COLRv1, then SVG-in-OpenType, then COLRv0 */
The original format hints were strings, although limited to a defined set.
227
236
In CSS Fonts 4, either strings or keywords may be used for the format.
228
237
The new font technology specifiers are keywords.
229
238
There is an open Issue 6328 [@font-face src: url() format() keywords vs. strings ambiguous in spec](https://github.com/w3c/csswg-drafts/issues/6328) regarding how to serialize this.
230
239
231
-
An alternative solution to putting supports inside format is proposed in Issue 6520 [Nesting of @supports inside @font-face](https://github.com/w3c/csswg-drafts/issues/6520).
240
+
An alternative solution to putting supports inside format is proposed in Issue 6520 [Nesting of @supports inside @font-face](https://github.com/w3c/csswg-drafts/issues/6520).
241
+
242
+
### Detectability
243
+
244
+
Detetecting font capabilities of the UA programmatically proves difficult due to
245
+
no direct mapping of font technologies to `CSS.supports()`.
246
+
247
+
Testing of font capabilities is possible through probing for rendered pixels on
248
+
a 2D canvas and testing for RGB color values, as done in @RoelN's
249
+
[Chromacheck](https://pixelambacht.nl/chromacheck/) tool. However, this is an
250
+
extremely wasteful approach, requiring canvas resources for something that can
251
+
be returned by the UA and detected more efficienlty.
252
+
253
+
## Proposed Syntax
254
+
255
+
See
256
+
[4.3.1 Parsing the src descriptor of the CSS Fonts Level 4 spec](https://drafts.csswg.org/css-fonts-4/#font-face-src-parsing)
257
+
258
+
## Examples
259
+
260
+
With the introduction of the `supports` part, the use cases 1 and 2 are then solved
261
+
using [the current syntax](https://drafts.csswg.org/css-fonts-4/#src-desc)
262
+
as follows:
263
+
264
+
### Use Case 1: Color Fonts
265
+
266
+
267
+
```CSS
268
+
/* 1. prefer COLRv1, then SVG-in-OpenType, then COLRv0 */
0 commit comments