How can I specify different fonts for different file types?


#1

I’d like to have different fonts set up for different languages. For instance, I’d like my plain text files to use a proportional font for the long-form writing I do, but I’d like my python files and other source code files to use a monospace font.

Is there a way to make the font selection change depending on the file type?


#2

You can try this, but it may screw up cursor location and some other things. I’m not sure if Atom is designed right now to handle different fonts by file type … but this will be a nice test! Add the following to your styles.less:

atom-text-editor::shadow {
  .text.plain {
    font-family: "Times New Roman"; // Or whatever font it is you want to use
  }
}

#3

Brilliant! Thank you! So far, it looks like it is working properly.


#4

“it may screw up cursor location and some other things” - yeah it does (in my case it causes a little bit ‘weired-blur’ text rendering).