zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
47.97k stars 2.83k forks source link

Support Font Weight Variation #5028

Open SilentGlasses opened 1 year ago

SilentGlasses commented 1 year ago

Check for existing issues

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",
iamnbutler commented 1 year ago

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
SilentGlasses commented 1 year ago

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 commented 1 year ago

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

brew install --cask font-victor-mono-nerd-font
SilentGlasses commented 1 year ago

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
farskid commented 1 year ago

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

iamnbutler commented 1 year ago

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
lucsky commented 1 year ago

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.

gldtn commented 10 months ago

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!

benwaffle commented 8 months ago

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.

iamnbutler commented 8 months ago

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?

benwaffle commented 8 months ago

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"

SomeoneToIgnore commented 8 months ago

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.

ishy-k commented 8 months ago

@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

SomeoneToIgnore commented 8 months ago

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:

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.

vitalics commented 8 months ago

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

florianepitech commented 8 months ago

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

anoldguy commented 7 months ago

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)

sgttwld commented 7 months ago

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.

mmorella-dev commented 6 months ago

@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).

slowdownitsfine commented 4 months ago

Love Zed but missing this sorely :)