skip to Main Content

It has been possible to configure OpenType variations in "editor.fontLigatures" for a long time by now, but it’s very limited. E.g., to configure the double-storey ‘g’ for the Iosevka font, one can add this to settings.json:

"editor.fontLigatures": "'cv32'"

This sets the cv32 parameter to 1. However, as far as I know it’s not possible to specify the value, e.g. cv32=2 to get the double-storey-open variant.
In 1.74 they added "editor.fontVariations", and promised that it would do the job like this:

"editor.fontVariations": "'ital' 0.5"

(See https://code.visualstudio.com/updates/v1_74)
This does not seem to work. No OpenType parameters work here, there is no effect on font rendering. They do work in the old, limited way in fontLigatures.

What am I doing wrong? How are these two configuration parameters expected to work? Is it working for anyone, possibly with a different programming font?

2

Answers


  1. There is info in OTVAR fonts: fontWeight/wght conversion fails on how this setting works.

    If fontVariations is true, we translate fontWeight to
    "font-variation-settings: 'wght' ${value}". We don’t set font-weight
    CSS property because they seems conflicting with each other.

    The reason why we do like this is that font weight is a register
    variable axis. So if people are using a variable font (e.g. Cascade
    Code, Berkeley Mono) and they don’t care about other variable axes,
    they can simply set this property to true to enable variable weights.

    If fontVariations is false, we translate fontWeigh to "font-weight:
    ${value}". This is identical to current behavior.

    If fontVariations is a string, we pass it as the value of
    font-variation-settings CSS property. In this case, font-weight is
    ignored.

    But near the end of that issue it is noted that the Chromium engine that vscode uses isn’t rendering this correctly on Windows if I read that issue correctly.

    Login or Signup to reply.
  2. These settings depend on fonts that support the capabilities they activate. From the VS Code doc’n:

    // Configures font ligatures or font features. Can be either a boolean to enable/disable ligatures or a string for the value of the CSS ‘font-feature-settings’ property.
    "editor.fontLigatures": false,

    If set to true, that will activate OpenType ligature features, if they are supported in the font. But if set to some other string like "'cv32'", that will activate that specific OpenType feature — the ‘cv32’ feature — if that is supported in the font.

    Here’s the description for the ‘cv01’ – ‘cv99’ features: https://learn.microsoft.com/en-us/typography/opentype/spec/features_ae#cv01-cv99

    OpenType has different ligature features. The ‘liga’ (standard ligatures feature should normally be activated by default, though I don’t know what Electron / VS Code does if .fontLigatures is false. Here are other ligature-related features:

    The ‘clig’ and ‘dlig’ features certainly ought to be activated or deactivated using boolean values for .fontLigatures. It probably would make sense to .fontLigatures to do the same for ‘hlig’. But ‘rlig’ shouldn’t be affected by .fontLigatures since the intent of the feature is for ligatures that are required for correct display of a script, such as the lam-alef ligature in Arabic.

    Now let’s look at what the VS Code documentation says regarding .fontVariations:

    // Configures font variations. Can be either a boolean to enable/disable the translation from font-weight to font-variation-settings or a string for the value of the CSS ‘font-variation-settings’ property.
    "editor.fontVariations": false,

    The first part is not entirely clear, but I gather that a boolean value of true will cause a font-weight: nnn CSS property to be changed to the property font-variation-settings: "wght" nnn, which is functionally almost the same. (CSS cascading works differently, but otherwise they would do the same.)

    But let’s step back for a moment to explain what the font-variation-settings property does: it’s intended specifically for use with OpenType variable fonts. A variable font has one or more axes of design variation, typically with continuous variation on each axis. Within the font, all variation axes are designated with a four-character tag, such as "wght" or "wdth". Many variable fonts support a weight axis (the tag for which is "wght"), but it’s entirely up to a font designer what the axes of variation are. See https://v-fonts.com/ or https://www.axis-praxis.org/ for many examples of variable fonts and the axes they support.

    So, back to `.fontVariations. First, let me explain the second usage,

    or a string for the value of the CSS ‘font-variation-settings’ property

    This could be used to set any variation on any axes of a variable font. For example,

    "editor.fontVariations": "wdth" 93, "GRAD" 88

    would translated into CSS properties

    font-variation-settings: "wdth" 93, "GRAD" 88

    Now back to .fontVariations: true: it’s intended for use with a variable font that has a weight ("wght") axis. This doesn’t seem particularly useful to me since (a) the only difference between CSS font-weight: 700 and font-variation-settings: "wght" 700 is that the latter doesn’t cascade the same way, and (b) the same could be achieved by "editor.fontVariations": "wght" 700. But it appears to be another way to get the CSS property font-variation-settings: "wght" 700. (That, btw, will remove any other font-variation-settings, which is the different cascading behaviour I mentioned.)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search