Numeric fontWeight is rejected by the profile parser #10702

Closed
opened 2026-01-31 02:27:48 +00:00 by claunia · 5 comments
Owner

Originally created by @TBBle on GitHub (Sep 21, 2020).

Originally assigned to: @DHowett on GitHub.

Environment

Windows build number: Microsoft Windows [Version 10.0.19041.508]
Windows Terminal version (if applicable): Windows Terminal Preview Version: 1.3.2382.0

Any other software? Fira Code 5.2: https://github.com/tonsky/FiraCode/releases/tag/5.2

Steps to reproduce

(How I got there, starting from a working setup, is hidden inside the fold. It shouldn't affect the reproduction, but is here in case there is something relevant hidden there.)

Starting from a working default profile:

  "profiles": {
    "defaults": {
      // Put settings here that you want to apply to all profiles.
      "colorScheme": "Canon Solarized Dark",
      "fontFace": "Fira Code Retina",
      "fontSize": 14,
      "padding": "0, 0, 0, 0",
      "cursorShape": "filledBox"
    },
    "list": [
//...
    ]
  },

with the Fira Code TTFs (six files, one for each of Bold, Light, Mediuma, Regular, Retina, SemiBold) installed.

I then removed the Fira Code TTFs, and installed the Variable TTF (FiraCode-VF.ttf).

Samples in white-on-black are from the Windows "Font Properties" dialogs.

After this change, my terminal looked like this: image which is Consolas Regular at 14pt:
image, but with better anti-aliasing. (Or rather, with any anti-aliasing, I suspect)

This makes sense, since there isn't a "Fira Code Retina" font anymore on my machine, although some kind of notification that my font wasn't found would have been nice. Also, I would have expected a fallback to Cascadia Code, not Consolas. Cascadia Code is installed on my machine as part of the Windows Terminal package (twice, once for Preview, once for regular), so it seems like a better fallback?

I initially tried to move the 'Retina' from the fontFace to the fontWeight

  "profiles": {
    "defaults": {
      // Put settings here that you want to apply to all profiles.
      "colorScheme": "Canon Solarized Dark",
      "fontFace": "Fira Code",
      "fontSize": 14,
      "fontWeight": "Retina",
      "padding": "0, 0, 0, 0",
      "cursorShape": "filledBox"
    },
    "list": [
//...
    ]
  },

but that's not in the hard-coded list of named font-weights. I was disappointed that it wasn't just asking the chosen font if the fontWeight given matched to a font instance name, but not super-disappointed:

I saw in the profile schema and settings implementation that I could pass in a uint to fontWeight, if there was no existing hard-coded name for my desired weight.

I looked up the weight of the Retina instance in the Fira Code variable TTF (450), and got:

  "profiles": {
    "defaults": {
      // Put settings here that you want to apply to all profiles.
      "colorScheme": "Canon Solarized Dark",
      "fontFace": "Fira Code",
      "fontSize": 14,
      "fontWeight": "450",
      "padding": "0, 0, 0, 0",
      "cursorShape": "filledBox"
    },
    "list": [
//...
    ]
  },

Expected behavior

I get the same font I had when using Fira Code Retina as my fontFace and no fontWeight setting, with the Fira Code non-variable TTF files installed, i.e. 6 separate TTFs, one for each of Bold, Light, Mediuma, Regular, Retina, and SemiBold.

Actual behavior

Windows Terminal raises an error about the fontWeight value:

image

and then ignores the entire theme configuration, including my colour scheme setting.

So yeah, unlike above, I was super-disappointed this time. As a workaround, I'm using "fontWeight": "medium".


If I comment-out the fontWeight, it looks like this: image
which appears to be 'Regular' instance (weight 400): image rather than 'Retina' instance (weight 450): image which makes sense, if the default value for fontWeight is 'normal'.

Side-note: I was inspired to make this change by noticing that Cascadia Code recommends their Variable TTF over the fixed-size TTFs, and also https://github.com/microsoft/terminal/issues/107#issuecomment-614347087

Originally created by @TBBle on GitHub (Sep 21, 2020). Originally assigned to: @DHowett on GitHub. <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: Microsoft Windows [Version 10.0.19041.508] Windows Terminal version (if applicable): Windows Terminal Preview Version: 1.3.2382.0 Any other software? Fira Code 5.2: https://github.com/tonsky/FiraCode/releases/tag/5.2 ``` # Steps to reproduce <!-- A description of how to trigger this bug. --> (How I got there, starting from a working setup, is hidden inside the fold. It shouldn't affect the reproduction, but is here in case there is something relevant hidden there.) <details> Starting from a working default profile: ```jsonc "profiles": { "defaults": { // Put settings here that you want to apply to all profiles. "colorScheme": "Canon Solarized Dark", "fontFace": "Fira Code Retina", "fontSize": 14, "padding": "0, 0, 0, 0", "cursorShape": "filledBox" }, "list": [ //... ] }, ``` with the Fira Code TTFs (six files, one for each of Bold, Light, Mediuma, Regular, Retina, SemiBold) installed. I then removed the Fira Code TTFs, and installed the *Variable* TTF (FiraCode-VF.ttf). Samples in white-on-black are from the Windows "Font Properties" dialogs. After this change, my terminal looked like this: ![image](https://user-images.githubusercontent.com/138397/93771457-df33df00-fc60-11ea-9e17-513c071197b2.png) which is Consolas Regular at 14pt: ![image](https://user-images.githubusercontent.com/138397/93774753-ef4dbd80-fc64-11ea-8d00-2e771badd69b.png), but with better anti-aliasing. (Or rather, with _any_ anti-aliasing, I suspect) This makes sense, since there isn't a "Fira Code Retina" font anymore on my machine, although some kind of notification that my font wasn't found would have been nice. Also, I would have expected a fallback to Cascadia Code, not Consolas. Cascadia Code is installed on my machine as part of the Windows Terminal package (twice, once for Preview, once for regular), so it seems like a better fallback? I initially tried to move the 'Retina' from the fontFace to the fontWeight ```jsonc "profiles": { "defaults": { // Put settings here that you want to apply to all profiles. "colorScheme": "Canon Solarized Dark", "fontFace": "Fira Code", "fontSize": 14, "fontWeight": "Retina", "padding": "0, 0, 0, 0", "cursorShape": "filledBox" }, "list": [ //... ] }, ``` but that's not in the hard-coded list of named font-weights. I was disappointed that it wasn't just asking the chosen font if the `fontWeight` given matched to a font instance name, but not super-disappointed: </details> I saw in the [profile schema](https://github.com/microsoft/terminal/blob/v1.3.2382.0/doc/cascadia/profiles.schema.json#L765-L791) and [settings implementation](https://github.com/microsoft/terminal/blob/v1.3.2382.0/src/cascadia/TerminalApp/TerminalSettingsSerializationHelpers.h#L133-L150) that I could pass in a uint to `fontWeight`, if there was no existing hard-coded name for my desired weight. I looked up the weight of the Retina instance in the Fira Code variable TTF (450), and got: ```jsonc "profiles": { "defaults": { // Put settings here that you want to apply to all profiles. "colorScheme": "Canon Solarized Dark", "fontFace": "Fira Code", "fontSize": 14, "fontWeight": "450", "padding": "0, 0, 0, 0", "cursorShape": "filledBox" }, "list": [ //... ] }, ``` # Expected behavior <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> I get the same font I had when using `Fira Code Retina` as my `fontFace` and no `fontWeight` setting, with the Fira Code non-variable TTF files installed, i.e. 6 separate TTFs, one for each of Bold, Light, Mediuma, Regular, Retina, and SemiBold. # Actual behavior <!-- What's actually happening? --> Windows Terminal raises an error about the fontWeight value: ![image](https://user-images.githubusercontent.com/138397/93770958-3a190680-fc60-11ea-9574-ce9164716038.png) and then ignores the _entire_ theme configuration, including my colour scheme setting. So yeah, unlike above, I was super-disappointed this time. As a workaround, I'm using `"fontWeight": "medium"`. ---- If I comment-out the `fontWeight`, it looks like this: ![image](https://user-images.githubusercontent.com/138397/93772765-92510800-fc62-11ea-8725-3c1d596a8889.png) which appears to be 'Regular' instance (weight 400): ![image](https://user-images.githubusercontent.com/138397/93771548-025e8e80-fc61-11ea-8905-1c0897e94403.png) rather than 'Retina' instance (weight 450): ![image](https://user-images.githubusercontent.com/138397/93771581-0ee2e700-fc61-11ea-91ad-7d936974e556.png) which makes sense, if the default value for `fontWeight` is 'normal'. Side-note: I was inspired to make this change by noticing that Cascadia Code recommends [their Variable TTF over the fixed-size TTFs](https://github.com/microsoft/cascadia-code/wiki/Installing-Cascadia-Code), and also https://github.com/microsoft/terminal/issues/107#issuecomment-614347087
claunia added the Resolution-Fix-CommittedNeeds-Tag-FixNeeds-Attention labels 2026-01-31 02:27:48 +00:00
Author
Owner

@DHowett commented on GitHub (Sep 21, 2020):

So, the error message does a right poor job of surfacing this...

Can you try 450 without the quotes? 😁

@DHowett commented on GitHub (Sep 21, 2020): So, the error message does a right poor job of surfacing this... Can you try `450` _without the quotes_? 😁
Author
Owner

@TBBle commented on GitHub (Sep 21, 2020):

Gah. >_<

Yeah, that works.

Thank you.

I'm going to go sit quietly away from the computer for a little while...


I assume the error message doesn't mention integers because the "Override mapping parser to add boolean parsing" (sic) code doesn't override TypeDescription, but just delegates it up to BaseEnumMapper. I expect it could provide its own TypeDescription, which would probably have left me still confused, but confused in the right direction.


I've just noticed that the hover-text in VS Code says:

Sets the weight (lightness or heaviness of the strokes) for the given font. Possible values:

-"thin"

-"extra-light"

-"light"

-"semi-light"

-"normal" (default)

-"medium"

-"semi-bold"

-"bold"

-"extra-bold"

-"black"

-"extra-black" or the corresponding numeric representation of OpenType font weight.

which suggests a couple of newlines are missing in the schema comment to take the last clause out of the list. Not that this would have clued me in to my mistake, if looking at profiles.schema.json and implementation didn't. Although given the current error message, the first thing I checked was "Is this code newer than the version I'm using?".

@TBBle commented on GitHub (Sep 21, 2020): Gah. >_< Yeah, that works. Thank you. I'm going to go sit quietly away from the computer for a little while... ---- I assume the error message doesn't mention integers because the "Override mapping parser to add boolean parsing" (sic) code doesn't override `TypeDescription`, but just delegates it up to `BaseEnumMapper`. I expect it _could_ provide its own `TypeDescription`, which would probably have left me still confused, but confused in the right direction. ---- I've just noticed that the hover-text in VS Code says: ``` Sets the weight (lightness or heaviness of the strokes) for the given font. Possible values: -"thin" -"extra-light" -"light" -"semi-light" -"normal" (default) -"medium" -"semi-bold" -"bold" -"extra-bold" -"black" -"extra-black" or the corresponding numeric representation of OpenType font weight. ``` which suggests a couple of newlines are missing in the schema comment to take the last clause out of the list. Not that this would have clued me in to my mistake, if looking at profiles.schema.json and implementation didn't. Although given the current error message, the first thing I checked was "Is this code newer than the version I'm using?".
Author
Owner

@DHowett commented on GitHub (Sep 22, 2020):

I should at least throw in a better type description. Thanks for calling that out 😄

@DHowett commented on GitHub (Sep 22, 2020): I should at least throw in a better type description. Thanks for calling that out :smile:
Author
Owner

@Vanderdecken commented on GitHub (Sep 23, 2020):

I have a similar warning but with fontSize as of the latest update:
Microsoft Windows [Version 10.0.19041.508]

        {
            // Make changes here to the cmd.exe profile
            "fontFace": "Cascadia Code",
            "fontSize": "10",
            "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "name": "cmd",
            "commandline": "cmd.exe",
            "hidden": false,
            "startingDirectory": "."
        }

This config with the value 10 in quotes previously worked okay, but now produces:
image
on startup.

Removing the quotes fixes it:

        {
            // Make changes here to the cmd.exe profile
            "fontFace": "Cascadia Code",
            "fontSize": 10,
            "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "name": "cmd",
            "commandline": "cmd.exe",
            "hidden": false,
            "startingDirectory": "."
        }

Admittedly putting in a number as a string was dumb to start with (I'm sure I copied it from an example without thinking), but previously it was accepted without error.

@Vanderdecken commented on GitHub (Sep 23, 2020): I have a similar warning but with fontSize as of the latest update: Microsoft Windows [Version 10.0.19041.508] ``` { // Make changes here to the cmd.exe profile "fontFace": "Cascadia Code", "fontSize": "10", "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "name": "cmd", "commandline": "cmd.exe", "hidden": false, "startingDirectory": "." } ``` This config with the value 10 in quotes previously worked okay, but now produces: ![image](https://user-images.githubusercontent.com/7602506/94004280-5cac3c00-fd94-11ea-9af6-19adc7f0216f.png) on startup. Removing the quotes fixes it: ``` { // Make changes here to the cmd.exe profile "fontFace": "Cascadia Code", "fontSize": 10, "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "name": "cmd", "commandline": "cmd.exe", "hidden": false, "startingDirectory": "." } ``` Admittedly putting in a number as a string was dumb to start with (I'm sure I copied it from an example without thinking), but previously it was accepted without error.
Author
Owner

@ghost commented on GitHub (Jan 28, 2021):

:tada:This issue was addressed in #8558, which has now been successfully released as Windows Terminal Preview v1.6.10272.0.🎉

Handy links:

@ghost commented on GitHub (Jan 28, 2021): :tada:This issue was addressed in #8558, which has now been successfully released as `Windows Terminal Preview v1.6.10272.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.6.10272.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10702