[csswg-drafts] [css-fonts-4] Support Font Collection File Formats

litherum has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-fonts-4] Support Font Collection File Formats ==
Now that WOFF2 supports font collections, we should be able to target specific items inside the collection. This should work not only for WOFF2 but also for TTC collections.

This was discussed at least [twice](https://lists.w3.org/Archives/Public/www-style/2013Oct/0604.html) [before](https://lists.w3.org/Archives/Public/www-style/2010Aug/0197.html).

One proposal I've heard is to use indices inside the fragment identifier of the URL, which refer to the order the fonts appear within the collection. So, your `@font-face` block would look like this:

```css
@font-face {
    font-family: "MyFont";
    src: url("path/to/font.ttc#4") format("truetype");
}
```

The numbers would be 1-indexed, so `#0` and `#1` refer to the same font inside the collection.

Another proposal is to use an additional descriptor inside the `@font-face` block, like so:
```css
@font-face {
    font-family: "MyFont";
    src: url("path/to/font.ttc") format("truetype");
    collection-index: 4;
}
```

There are some pros and cons to putting the information inside the URL vs in a separate descriptor. A benefit of putting it in a descriptor is that the CSSOM and CSS Font Loading API could change the descriptor at runtime, and the page would (should) update accordingly. A benefit of putting it in the URL is that the index is relevant only to a specific file, and may be different depending on which item in the `src:` list is chosen by the browser to download.

Alternatively, instead of using collection indices, we could identify each of these individual fonts by using some other nominal identifier (like PostScript name). However, I would hesitate to use these strings because of consensus between browsers about which strings inside the file to use would probably be difficult. We can certainly all agree on how indices work. In addition, cracking open the collection and parsing every font just to get a single identifier to determine which one matches a name could potentially be costly.

We also should consider adding a `format()` keyword for feature detection. How about `truetype-collection` and `woff2-collection`?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2205 using your GitHub account

Received on Friday, 19 January 2018 03:19:18 UTC