Skip to content

Clarify precedence of font-feature-settings descriptor and font-variant property #7498

@faceless2

Description

@faceless2

I've put a test up at https://jsbin.com/veqidew/edit?html,output, here it is too:

 <style>
  @font-face {
    font-family: Lato-On;
    src: url("https://bfo.com/misc/Lato-Medium-Liga.ttf");
    font-feature-settings: 'liga' on;
  }
  @font-face {
    font-family: Lato-Off;
    src: url("https://bfo.com/misc/Lato-Medium-Liga.ttf");
    font-feature-settings: 'liga' off;
  }
  .feature-on {
     font-family: Lato-On;
  }
  .feature-off {
     font-family: Lato-Off;
  }
  .variation-off {
    font-variant-ligatures: none;
  }
  .variation-on {
    font-variant-ligatures: initial; /* = normal */
  }
  p {
    font-size: 100px;
    margin: 0;
  }
 </style>
 <body>
  <p class="feature-off variation-off">fi</p>
  <p class="feature-on variation-off">fi</p>
  <p class="feature-off variation-on">fi</p>
  <p class="feature-on variation-on">fi</p>
 </body>

The font precedence rules in both Fonts-3 and Fonts-4 seem clear - we are to:

  • apply the default rules
  • apply the font-feature-settings descriptor
  • apply the font-variant properties

Which means that we start with the "liga" feature on (the default), that's overridden by the font-feature-settings descriptor, and is then always overridden by the font-variant-ligatures property - the initial value is "normal" which turns it on, or I can set to "none" which turns it off. But it will always change - there is no font-variant-ligatures value that means "don't change anything".

This means that the first two paragraphs of the test have no change, and the second two have a ligature.

Correct?

The reason I ask is that's not the behaviour in Webkit or Gecko, which give precedence to font-feature-settings (Blink doesn't support the descriptor). It's also not what's being tested in https://wpt.fyi/results/css/css-fonts/font-feature-resolution-001.html from where the above test was derived, which came from the Chromium team. So I have a nagging doubt I have misunderstood. I've raised a PR anyway for that test, if I'm wrong it can be closed.

Related: #4358 - I think this could be closed, or at least reduced to remove font-feature-settings given you've got two browsers implementing the descriptor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions