\( \renewcommand\vec[1]{\mathbf #1} \newcommand\pp[2]{\frac{\partial #1}{\partial #2}} \newcommand\dd[2]{\frac{\mathrm d #1}{\mathrm d #2}} \newcommand\d{\,\mathrm d} \)

❀✿❀ SuperLaserNino ✿❀✿

home · about · archive · RSS

DPI-dependent CSS in Atom and everywhere else too

04 Dec 2017

143 words

When programming on low-resolution screens, I like to use 10pt Monaco with antialiasing turned off. But when switching to my MacBook’s retina display, I want antialiasing turned back on. Until now, I would manually comment/uncomment some CSS in Atom’s styles.less file to change this.

Turns out, you can define CSS rules based on the current screen resolution. By adding the following to styles.less, Atom automatically switches the font and antialiasing settings as soon as you move the window from one screen to the other:

atom-text-editor {
  @media (-webkit-max-device-pixel-ratio: 1), (max-resolution: 150dpi) {
    .line {
      -webkit-font-smoothing: none;
      font-family: Monaco;
      font-size: 10;
      transform: translateX(1px);
      font-style: normal !important;
      * {
        font-style: normal !important;

The transform line is there because Atom will sometimes cut off the first column of pixels when antialiasing is turned off.