How to use an italic font for code comments?

The following image shows a cursive font being used for comments, while retaining a monospace font for the code. I am trying to achieve this with the following:

  doom-font (font-spec :family "JetBrainsMono Nerd Font" :size 24)
  doom-variable-pitch-font (font-spec :family "Cascadia Code NF" :size 24 :slant 'italic :weight 'light)

But alas I don’t see any difference in the code comments. Is there a different way to achieve italics font for code comments? Thank you. See image below for example of intended result:

Italics in code is not controlled by the font setting, but rather by the theme, in particular by the value of font-lock-comment-face. For example, try switching to theme doom-feather-dark, which sets the comment face to italics. As long as you are using a doom-font that supports italics, you should get a result similar to your screenshot (but with different colors, obviously).

To enable italics globally for comments in all themes, you could do something like:

(custom-set-faces!
  '(font-lock-comment-face :slant italic)
)

This topic was automatically closed after 90 days. New replies are no longer allowed.