zed icon indicating copy to clipboard operation
zed copied to clipboard

Support Font Weight Variation

Open SilentGlasses opened this issue 2 years ago • 18 comments

Check for existing issues

  • [X] Completed

Describe the feature

When setting font, it would be nice to be able to set the weight variation as well..

If applicable, add mockups / screenshots to help present your vision of the feature

I don't have a screenshot but, as it is right now we can only call the font:

"buffer_font_family": "VictorMono Nerd Font",

but it would be nice to be able to set the following:

"buffer_font_family": "VictorMono Nerd Font Light",

SilentGlasses avatar Jan 27 '23 01:01 SilentGlasses

You can do this, it's not super obvious though. Try adding the weight name after the font name, like this: CleanShot - 2023-01-26 at 21 49 52@2x

iamnbutler avatar Jan 27 '23 02:01 iamnbutler

I did but it did not change the font, just made things weird with spacing...

These two are lined up properly when not using the variant...

Screen Shot 6

Here's the config without the extra variant: Screen Shot 7

Here it is after Screen Shot 8

SilentGlasses avatar Jan 27 '23 02:01 SilentGlasses

not sure if this matters but I did install the font from brew:

brew install --cask font-victor-mono-nerd-font

SilentGlasses avatar Jan 27 '23 03:01 SilentGlasses

Seeing this in the log:

02:58:16 [ERROR] could not find a non-empty font family matching one of the given names
02:58:26 [ERROR] could not find a non-empty font family matching one of the given names
02:59:51 [ERROR] could not find a non-empty font family matching one of the given names

SilentGlasses avatar Jan 27 '23 03:01 SilentGlasses

You can do this, it's not super obvious though. Try adding the weight name after the font name, like this: CleanShot - 2023-01-26 at 21 49 52@2x

Can confirm, mentioning the weight after the font name doesn't work. Zed version is 0.75.2

farskid avatar Mar 09 '23 20:03 farskid

You might need to try a few things. Usually if you open Font Book and use Family Name + Style Name it will work. It doesn't seem you can manually specify an italic weight however (we drive this from the theme.)

CleanShot 2023-03-09 at 15 30 02@2x

iamnbutler avatar Mar 09 '23 20:03 iamnbutler

Usually if you open Font Book and use Family Name + Style Name it will work.

It will work for some fonts, and won't for some others, I haven't been able to find a clear pattern. I was able to select variants of Iosevka following this method, for example, but JetBrains Mono completely refuses to work, same for Fira Code. And Postscript names do not work either.

lucsky avatar Mar 10 '23 22:03 lucsky

This seems like it's still not working on 115.3 preview. Which makes me think that the font script variant issue is related as the font uses the italic variant for this.

https://www.monolisa.dev/faq#the-script-variant-doesnt-work-what-can-i-do

I even checked to make sure the font I'm using supports it using: https://fontdrop.info/#/?darkmode=true

I want to enable script variant on my font and I can't seem to make it work even with "ss02" = true set. Do I need to add additional settings to it, like textMateRules?

ZED Config: liga and zero options are working fine

"buffer_font_family": "Monolisa",
    "buffer_font_features": {
        "liga": true,
        "zero": true,
        "ss02": true
    }

In vscode I need to set extra settings like:

"editor.fontFamily": "MonoLisa",
    "editor.fontLigatures": "'ss02' on",
    "editor.tokenColorCustomizations":
    {
        "textMateRules": [
          {
            "scope": [
              // following will be in italic
              "comment",
              "entity.name.type.class", //class names
              "keyword", //import, export, return…
              "constant", //String, Number, Boolean…, this, super
              "storage.modifier", //static keyword
              "storage.type.class.js", //class keyword
            ],
            "settings": {
              "fontStyle": "italic"
            }
          },
          {
            "scope": [
              // excluded from italics (VSCode has some defaults for italics)
              "invalid",
              "keyword.operator",
              "constant.numeric.css",
              "keyword.other.unit.px.css",
              "constant.numeric.decimal.js",
              "constant.numeric.json"
            ],
            "settings": {
              "fontStyle": ""
            }
          }
        ]
    }

I did try it with both, static and variable font!

gldtn avatar Dec 05 '23 06:12 gldtn

This was working for me until I updated to 0.119.19. I used to be able to set "buffer_font_family": "Operator Mono Book", but now it only accepts "Operator Mono" and does not allow me to select the font weight / style.

benwaffle avatar Jan 25 '24 21:01 benwaffle

This was working for me until I updated to 0.119.19. I used to be able to set "buffer_font_family": "Operator Mono Book", but now it only accepts "Operator Mono" and does not allow me to select the font weight / style.

@osiewicz this is probably a side effect of the work you were doing. Want to take a peek?

iamnbutler avatar Jan 25 '24 21:01 iamnbutler

My bad, "Operator Mono Book" does work, but I get a yellow squiggly because it fails validation. Styles with multiple words don't seem to work, like "Operator Mono Book Italic"

benwaffle avatar Jan 25 '24 23:01 benwaffle

Note: at least in the code names, we seem to deal with the "family name" only: https://github.com/zed-industries/zed/blob/f7a2118b159ac98a4fda8f15974090781522b407/crates/gpui/src/platform/mac/text_system.rs#L52

While Bold, Italic, etc. are not really names and that's why we might not be resolving it anymore. There's been a recent change in the settings file completions that removed such options completion in the settings, but those are not affecting the resolution of these.

SomeoneToIgnore avatar Jan 26 '24 08:01 SomeoneToIgnore

@SomeoneToIgnore I need to object, at least a little.

Style names like Bold and Italic might not be part of the font name but I have some fonts that have styles like Thin and UltraLight. In my case Zed selects the Thin or UltraLight style instead of Regular (this is an assumption based on how Zed looks using this font in comparison to other editors) which makes this font unusable. So providing the user a possibility to help Zed chose which style to use for Bold, Italic, Bold Italic and Regular would be a big improvement.

image

ishy-k avatar Jan 28 '24 15:01 ishy-k

I have nothing against providing these, we should do that. My take was supposed to mean "current Zed seems to have zero mechanisms to look up a font by the family name AND the style"

Previously, completions allowed to input these style variants right in the font family setting which was incorrect: all those style variants I checked during https://github.com/zed-industries/zed/pull/4205 did not work for me.

So, what we need now:

  • a better approach to the settings, so we can set both a family name and a style (in separate settings entries, presumably, as VSCode does that?)
  • a better approach to settings style retrieval and completions (as the aforementioned PR reverted font style retrievals for completions)
  • a code that actually reads those values and applies them correctly

Feel free to use that PR for the reference and ask for more clarifications, if needed. I can also pair on that in any channel during UTC+2 hours.

SomeoneToIgnore avatar Jan 28 '24 16:01 SomeoneToIgnore

As for me - it works but I get a warning message that font name is not in list:

image

info: version: 0.119.21 hash: ca60f0972bd959afab164f88d5c15074fe76892c

vitalics avatar Jan 31 '24 13:01 vitalics

Hey, same problem in my case. ;) A simple settings with the font style will be nice to have :)

florianepitech avatar Feb 06 '24 18:02 florianepitech

A simple settings with the font style will be nice to have :)

And a way to reference it in a theme, if it doesn't already exist? (I have not dug into the theme spec at all)

anoldguy avatar Feb 23 '24 13:02 anoldguy

Any progress on this? I love this editor, but I really miss my favorite "Operator Mono Book", which doesn't work for me at all.

sgttwld avatar Mar 04 '24 12:03 sgttwld

@sgttwld

Any progress on this? I love this editor, but I really miss my favorite "Operator Mono Book", which doesn't work for me at all.

In Zed 0.126.3, specifying the variant in lowercase worked for me; e.g.

{
  "buffer_font_family": "Operator Mono book",
}

(or in my case Operator Mono SSm Lig book).

mmorella-dev avatar Mar 19 '24 17:03 mmorella-dev

Love Zed but missing this sorely :)

slowdownitsfine avatar May 25 '24 14:05 slowdownitsfine