8

I've come across this in user settings "editor.fontFamily": "Consolas, 'Courier New', monospace", but is there any way to change only the font of comments? I've seen people have semi cursive comments in other editors and I'd like to be able to replicate something similar.

Brien Foss
  • 3,120
  • 3
  • 18
  • 30
Ryan Mcguinn
  • 461
  • 1
  • 8
  • 15
  • I had the same issue and found a loophole that worked great https://stackoverflow.com/a/67693674/15526565 – Jeff May 25 '21 at 18:32

2 Answers2

14

You can change the font style with the editor.tokenColorCustomizations setting:

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "comment",
            "settings": {
                "fontStyle": "italic"
            }
        }
    ]
}

I don't think there's a way to change the font family right now. The setting only allows customizing fontStyle and foreground (text color). There's an open feature request for adding support for it though:

Support fontName in textMateRules (#36512)

Gama11
  • 28,518
  • 9
  • 66
  • 91
1

I had the same issue and it seems you can only make comments italic but cannot change to a separate font. I ended up combining a regular and italic font I liked into a font family which worked.

Download a font editor (FontForge) and create a font family of your own (ex: Custom Font) by changing a regular font you like to Custom Font Regular.ttf and an italic font you like to Custom Font Italic.ttf. Just keep the family name the same.

FontForge Example:

  • Open your desired fonts separately in FontForge.
  • From Element -> Font Info just change
    1. "Fontname" : CustomFont-Regular, CustomFont-Italic
    2. "Family Name" : Custom Font (keep these the same for both)
    3. "Name For Humans" : Custom Font Regular, Custom Font Italic
    4. Don't touch anything else and hit OK.
    5. Accept if/when it asks to change ID
    6. File -> Generate Font as True Type
    7. Install your newly named ttf fonts
    8. Then add your new family to vs code. (If you're following along that's "Custom Font")

Pretty straightforward and works great in VS Code. Hope this helps somebody

Jeff
  • 51
  • 5