Home > front end >  VS Code: behavior of "editor.fontLigatures" and "editor.fontVariations"?
VS Code: behavior of "editor.fontLigatures" and "editor.fontVariations"?

Time:12-13

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?

CodePudding user response:

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.

  • Related