W3C home > Mailing lists > Public > public-css-archive@w3.org > October 2016

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

From: Kenneth Ormandy via GitHub <sysbot+gh@w3.org>
Date: Tue, 18 Oct 2016 00:11:50 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-254370827-1476749508-sysbot+gh@w3.org>
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
OpenType](https://github.com/kennethormandy/utility-opentype) which 
mitigates this somewhat with CSS feature qeuries:

.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:

.calt { font-feature-settings: "liga", "calt"; }
<p class="calt">

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 

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:


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" 

…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 


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 
using your GitHub account
Received on Tuesday, 18 October 2016 00:11:58 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:04 UTC