Re: [csswg-drafts] [css-fonts-4] font-feature-settings don’t cascade

I didn’t see this discussion before, but if other people find it 
looking for a solution in the meantime, this one of the reasons I made
 [Utility 
OpenType](https://github.com/kennethormandy/utility-opentype) which 
mitigates this somewhat with CSS feature qeuries:

```css
.liga {

  /* Gracefully degrade to `font-feature-settings` to
   * avoid disrupting the OpenType feature cascade
   * when possible. */
  @supports not (font-variant-ligatures: common-ligatures) {
    font-feature-settings: "liga";
  }

  /* IE doesn’t support @supports; explicitly use
   * the prefixed version. */
  -ms-font-feature-settings: "liga";

  /* Best case scenario, just use `font-variant-*`. */
  font-variant-ligatures: common-ligatures;
}
```

This example is a bit contrived since ideally `liga` is already on, 
but I applied the same idea to the other OpenType features that have 
lower level properties. As Nick mentioned in the first comment, there 
are still some issues that this can’t get around, and mixing these 
class names and Stylistic Sets is one of them.

***

One other cascade-related issue I haven’t been able to get around is 
mixing `span`s and the Contextual Alternates feature.

A basic example:

```html
<style>
.calt { font-feature-settings: "liga", "calt"; }
</style>
<p class="calt">
  
<span>g</span><span>l</span><span>o</span><span>v</span><span>e</span><span>s</span>
</p>
```

Even though the Contextual Alternates feature is applied to the 
paragraph, each letter in the `span` will act as though it’s the first
 in the phrase, even if there is a `calt` feature that should swap to 
an alternate glyph. This can be a problem for script fonts in 
particular.

For a weird but real-world example, I recently designed a sketch-y 
emoji/icon set for a magazine, and I made alternates for the icons. 
So, when they use it, if they use the same icon in a row, it uses a 
different alternate drawing so it looks more like a sketch:

![sad-randomisation-illustrator](https://cloud.githubusercontent.com/assets/1581276/19459840/0d00f52c-948b-11e6-8ab9-09bee022af10.gif)

This is using the Contextual Alternates feature (which I turn off and 
then on again when I highlight the text in that gif) and works great. 
The other designer I was working with designed a layout that changed 
the colour of each of these glyphs.

This isn’t a problem if they are all the same:

<img width="701" alt="screenshot 2016-10-17 17 03 12" 
src="https://cloud.githubusercontent.com/assets/1581276/19459927/c9284ffc-948b-11e6-9041-e02af2389416.png">

…but once you wrap each in a `span` they are each treated as their own
 phrase, even though the Contextual Alternates feature is applied to 
the parent (or even not applied at all, since it should be a browser 
default):

![sad-randomisation-browser](https://cloud.githubusercontent.com/assets/1581276/19459936/d6b4a21a-948b-11e6-98e1-ac833f6e6fe4.gif)

I’m not even sure if this would be considered incorrect, but it 
definitely seems related to the question of how the cascade of 
OpenType features works or should work.

-- 
GitHub Notification of comment by kennethormandy
Please view or discuss this issue at 
https://github.com/w3c/csswg-drafts/issues/552#issuecomment-254370827 
using your GitHub account

Received on Tuesday, 18 October 2016 00:11:58 UTC