monaspace icon indicating copy to clipboard operation
monaspace copied to clipboard

Mix & Match in VS Code?

Open marvinruder opened this issue 2 years ago • 26 comments

I really like the examples shown in the Mix & Match section, using different font families for comments, Copilot suggestions etc.:

As I understand it from https://github.com/Microsoft/vscode/issues/36512, this is not yet reproducable in VS Code. Are there any plans to support that soon, perhaps via plug-in or by discussing support with the VS Code maintainers directly?

marvinruder avatar Nov 09 '23 22:11 marvinruder

I was looking for this too. Great project!

taciturnaxolotl avatar Nov 09 '23 22:11 taciturnaxolotl

I'm achieving exactly this with the Custom CSS and JS Loader plugin.

1eldiego avatar Nov 10 '23 04:11 1eldiego

I was also looking for this!

Bosphoramus avatar Nov 10 '23 08:11 Bosphoramus

I'm achieving exactly this with the Custom CSS and JS Loader plugin.

Yes, I also tried this and got some of it working, but found it difficult to distinguish between line and block comments. Overall this would require very hacky solutions. textMateRules is much better suited for this purpose.

marvinruder avatar Nov 10 '23 17:11 marvinruder

Current settings with custom css and js loader plugin:

.mtk7 {
        font-family: "Monaspace Radon Var";
        font-weight: 500;
}

.mtk11 {
        font-family: "Monaspace Radon Var";
        font-weight: 500;
}

.mtk4 {
	font-family: "Monaspace Radon Var";
	font-weight: 500;
}

.ghost-text-decoration {
	font-family: 'Monaspace Krypton Var';
	font-weight: 200;
}

.ghost-text-decoration-preview {
	font-family: 'Monaspace Krypton Var';
	font-weight: 200;
}

taciturnaxolotl avatar Nov 10 '23 21:11 taciturnaxolotl

Current settings with custom css and js loader plugin:

.mtk7 {
        font-family: "Monaspace Radon Var";
        font-weight: 500;
}

.mtk11 {
        font-family: "Monaspace Radon Var";
        font-weight: 500;
}

.mtk4 {
	font-family: "Monaspace Radon Var";
	font-weight: 500;
}

.ghost-text-decoration {
	font-family: 'Monaspace Krypton Var';
	font-weight: 200;
}

.ghost-text-decoration-preview {
	font-family: 'Monaspace Krypton Var';
	font-weight: 200;
}

Nice one! I figured out something similar in the meantime as well. In short:

If you define a custom and unique color for a textMate scope (e.g. comment.block.documentation, comment.line), it will be assigned a separate .mtk… class (the numbers will vary, even per theme, my light theme results in different ones than my dark theme). You can grab the class name using developer tools and then create your own CSS for the aforementioned plugin. @media (prefers-color-scheme: dark / light) { … } will also work if you use system-wide light / dark mode to switch between themes so you can easily maintain class definitions for one dark and one light theme.

This is still very hacky, so I hope that we will native support using the textMateRules setting soon. I played around a little in the VS Code codebase and found that the two main difficulties will be extending the external package vscode-textmate and moving away from bitwise-encoding all styles in a number (which is later stored in a Uint32Array, of which all 32 bits are already in use), as explained here: https://github.com/microsoft/vscode/blob/6f2f46ec25c134595c7cb8399219d9b59794a526/src/vs/editor/common/encodedTokenAttributes.ts#L45-L66

marvinruder avatar Nov 10 '23 21:11 marvinruder

Current settings with custom css and js loader plugin:

.mtk7 {
        font-family: "Monaspace Radon Var";
        font-weight: 500;
}

.mtk11 {
        font-family: "Monaspace Radon Var";
        font-weight: 500;
}

.mtk4 {
	font-family: "Monaspace Radon Var";
	font-weight: 500;
}

.ghost-text-decoration {
	font-family: 'Monaspace Krypton Var';
	font-weight: 200;
}

.ghost-text-decoration-preview {
	font-family: 'Monaspace Krypton Var';
	font-weight: 200;
}

I tested this myself and found it assigned the wrong fonts to the wrong things.

Disabling for now until someone figures out a proper solution (I'd be fine with a dedicated VSCode plugin for Monaspace if that's necessary)

EliteMasterEric avatar Nov 10 '23 23:11 EliteMasterEric

What VS Code version do you have? I'm using the latest version for mac, 1.84.2 (Universal) commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e. The classes seem to change between versions, so that might be the issue.

Here is what it looks like on my end: screely editor

taciturnaxolotl avatar Nov 10 '23 23:11 taciturnaxolotl

I'm on 1.84.0.

If these classes change with every minor version, I'm going to hold off until it's properly fixed.

EliteMasterEric avatar Nov 10 '23 23:11 EliteMasterEric

minor tweak; the styles for comments should only be mtk4:

/* Comment Class */
.mtk4 {
	font-family: "Monaspace Radon Var";
	font-weight: 500;
}

/* Copilot Classes */
.ghost-text-decoration {
	font-family: 'Monaspace Krypton Var';
	font-weight: 200;
}

.ghost-text-decoration-preview {
	font-family: 'Monaspace Krypton Var';
	font-weight: 200;
}

taciturnaxolotl avatar Nov 11 '23 02:11 taciturnaxolotl

I use a theme in VSCode with many italics (Dracula), using that, I used the .mtki class to set Monaspace Radon (using APC) which looks very nice to me.

The relevant parts of my settings.json:

{
  "editor.fontFamily": "'Monaspace Neon', 'Jetbrains Mono', Menlo, Monaco, 'Courier New', monospace",
  "editor.fontLigatures": "'ss01', 'ss02', 'ss03', 'ss06', 'ss07', 'ss08', 'calt', 'dlig'",
  "editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "scope": "comment",
        "settings": {
          "fontStyle": "italic"
        }
      }
    ]
  },
  "apc.stylesheet": {
    // Make all italic fonts use Monospace Radon
    ".mtki": {
      "font-family": "Monaspace Radon"
    },
    // Make GitHub suggestions use Monospace Krypton
    ".ghost-text-decoration,.ghost-text-decoration-preview": {
      "font-family": "Monaspace Krypton",
      "font-weight": "lighter"
    }
  }
}

HTH

mjakl avatar Nov 11 '23 09:11 mjakl

@mjakl Thats cool, but do you know why it only applies to the first line of the GH suggestion? First line is Krypton, but the following line(s) use my normal default font 🤔 I can see it is not part of the div that has the class (highlighted in screenshot below):

Screenshot 2023-11-14 at 13 01 34

klippx avatar Nov 14 '23 12:11 klippx

@mjakl Thats cool, but do you know why it only applies to the first line of the GH suggestion? First line is Krypton, but the following line(s) use my normal default font 🤔 I can see it is not part of the div that has the class (highlighted in screenshot below):

@klippx Can you try the selector .ghost-text-decoration, .ghost-text?

marvinruder avatar Nov 14 '23 12:11 marvinruder

That works, thanks @marvinruder 💪

Edit: Actually I think .ghost-text-decoration, .ghost-text-decoration-preview, .ghost-text works best.

klippx avatar Nov 14 '23 12:11 klippx

I have tried the things that were suggested here, I installed APC and edited the apc.stylesheet section, but they are just not applied for me. Here is the relevant code from my settings.json file:

{
  "editor.fontSize": 14,
  "editor.fontFamily": "'Monaspace Argo', 'JetBrains Mono', monospace",
  "editor.fontLigatures": "'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'ss07', 'ss08', 'calt', 'liga', 'dlig',",
  "editor.letterSpacing": 1.2,
  "editor.inlayHints.fontFamily": "Monaspace Krypton Var",
  "apc.stylesheet": {
    ".mtk3": "font-family: 'Monaspace Radon Var'; font-weight: 500;",
    ".mtk4": {
      "font-family": "Monaspace Radon"
    },
    ".ghost-text-decoration,.ghost-text-decoration-preview, .ghost-text": {
      "font-family": "Monaspace Krypton",
      "font-weight": "200"
    }
  }
}

wiktoriavh avatar Nov 14 '23 12:11 wiktoriavh

I have tried the things that were suggested here, I installed APC and edited the apc.stylesheet section, but they are just not applied for me.

@wiktoriavh You need to enable APC everytime you update VSCode, maybe that's the problem?

mjakl avatar Nov 14 '23 13:11 mjakl

I tried enabling it, and I kept getting an error message, same thing with the Custom CSS and JS Loader extension. I will try it again on my private machine after work.

wiktoriavh avatar Nov 14 '23 13:11 wiktoriavh

I think your problem might be the argon typo in the "editor.fontFamily", if that's not the case, the readme mentions that for font ligatures you need to have the 'calt', 'liga', 'dlig' first, and then the others

MicroMelone avatar Nov 14 '23 14:11 MicroMelone

Hey @mjakl @MicroMelone thanks for your Tips. I am now on my private machine and tried it again, and it worked again. The error I mentioned was some pathing error on my work macbook. On my private windows it works great.

image

wiktoriavh avatar Nov 14 '23 17:11 wiktoriavh

EDIT: See also https://github.com/githubnext/monaspace/issues/6#issuecomment-1965819103 below for the new editor.inlineSuggest.fontFamily, as well.


With stock VSCode you can differentiate at least to the level of granularity of editor, error lens, chat, code lens, inlay hints, and SCM (commit message). Below I specify Neon as the primary font family for the editor (falling back to the default fonts listed in this option prior). Then I do the same for the other font families, but start off with Krypton for all other text areas. Heads up, it seems you can't specify 'editor' to propagate editor font to the other font families, as you can with the scm.inputFontFamily key.

settings.json

{
  "editor.fontFamily": "'Monaspace Neon Var', Consolas, 'Courier New', monospace",
  "errorLens.fontFamily": "'Monaspace Krypton Var', Consolas, 'Courier New', monospace",
  "chat.editor.fontFamily": "'Monaspace Krypton Var', Consolas, 'Courier New', monospace",
  "editor.codeLensFontFamily": "'Monaspace Krypton Var', Consolas, 'Courier New', monospace",
  "editor.inlayHints.fontFamily": "'Monaspace Krypton Var', Consolas, 'Courier New', monospace",
  //? Monospace font in Source Control fields
  "scm.inputFontFamily": "editor",
}

blakeNaccarato avatar Nov 16 '23 02:11 blakeNaccarato

I think your problem might be the argon typo in the "editor.fontFamily", if that's not the case, the readme mentions that for font ligatures you need to have the 'calt', 'liga', 'dlig' first, and then the others

Sadly their webpage generator gives the wrong order.

TZECHIN6 avatar Jan 15 '24 07:01 TZECHIN6

The "What if Copilot had its own voice?" part of the "Mix & Match" proposal is now implemented as of VSCode 1.86 (January '24) with editor.inlineSuggest.fontFamily. Technically, the other what-ifs (different docstring font and a "draft comment" font) are not yet implemented, but it's nice to have the inline suggest font configurable now!

blakeNaccarato avatar Feb 27 '24 05:02 blakeNaccarato

The "What if Copilot had its own voice?" part of the "Mix & Match" proposal is now implemented as of VSCode 1.86 (January '24) with editor.inlineSuggest.fontFamily. Technically, the other what-ifs (different docstrimg font and a "draft comment" font) are not yet implemented, but it's nice to have the inline suggest font configurable now!

I tested this out and it seems to work great, but is there a way to switch the inlineSuggest font color from light gray to syntax-highlighted once the font has been enforced?

EliteMasterEric avatar Feb 28 '24 07:02 EliteMasterEric