12

For a long time I've been using DejaVu Sans Mono as my programming font. I've yet to find a better font.

But a little while ago I discovered Mozilla's Fira, which looks very nice for code. So I decided to give it a try in Emacs.

Unfortunately, when I use it in Emacs, the line spacing blows up and reduces the number of lines I can see by about 10.

I've tried (setq line-spacing 0) and different combinations of things like (set-frame-font (font-spec :name "Fira Mono" :width 'normal :height 100)), but no matter what I do, the excessive line spacing remains. (It's not possible to use negative line-spacing values in Emacs, unfortunately, which would seem like the obvious solution.)

It doesn't seem to be a bug in the font though, because when I use Fira Mono in Kate at the same size, the line spacing is what I would consider normal, and apparently about the same as the Emacs line spacing with DejaVu Sans.

Is this a bug in Emacs? Is there any way to fix this?

Thanks for any advice.

Left: Emacs Fira Mono Right: Emacs DejaVu Sans Mono Emacs Fira Mono vs. Emacs DejaVu Sans Mono

Left: Emacs Fira Mono Right: Kate Fira Mono Emacs Fira Mono vs. Kate Fira Mono

  • 1
    You could try --line-spacing=PIXELS on the command line with emacs, but my guess is that that won't help. My crystal ball tells me that line spacing is not inserting any extra pixels and that the problem is with Emacs's display of the font. Does the buffer mode make any difference? (I assume that you've checked frame-parameters to see what the font is etc.) – Drew Apr 5 '15 at 0:51
  • 2
    To be honest, to me it looks like DejaVu has not enough spacing, and if you look at the last screenshot with Fira, then you can even see that characters which have descending elements such as g and y are cropped. Other than that, I think that the minimum line height would be calculated based on some TTF parameter, so if you really want to change that, I'd be looking into modifying the TTF (or is it OTF?) file to change the font's metric to allow less leading. – wvxvw Apr 5 '15 at 4:57
  • 1
    What happens if you append minspace=true to the FontConfig font definition? E.g. something like emacs -fn 'Fira Mono:minspace=true', or whatever the name of the font. – jch Apr 5 '15 at 19:19
  • 3
    This is not what you want to hear, but I gave up on line spacing about a little over a year ago. Instead, I choose a font I am comfortable with and I set the :height and that's it. Emacs doesn't really have good control of distance between lines, and adjusting it just causes more problems. Perhaps a feature request would be appropriate -- e.g., to set distance between lines in pixels and have it work with all fonts. – lawlist Apr 7 '15 at 5:46
  • 1
    The line height is a property of the font, Emacs' rendering respects the given value. If you force a certain height regardless of the font's property you might end up with cropped characters, like in the screenshot of Fira Mono in Kate (as wvxvw already pointed out). When it comes to proportional fonts I find that Lucida Grande Mono is the most efficient in terms of space while still very readable at small sizes (Droid Sans Mono comes close, but it's less dense). – paprika Apr 8 '15 at 11:47
2

Fira Mono v3.2 adjusted the font's line height, which has made it usable by me in Emacs:

https://github.com/mozilla/Fira/issues/67

  • Thanks for the update. That seems a little better, but I still get 4 fewer lines in Emacs with Fira Mono 3.2 than with DejaVu Sans Mono. So, unfortunately, it's still useless. I don't need more space between lines; it doesn't gain me anything. All it does is reduce how much I can see on the screen and make me scroll more, reducing my efficiency and wasting my time. :( Too bad that Mozilla's more concerned with making a font look airy than making it useful. – blujay Sep 2 '15 at 7:34
  • …and you can get 4 more lines on the screen with Consolas (for example) compared with DejaVu Sans Mono. Individual fonts do have different intrinsic heights (and widths, in the case of monospace variants), which has nothing to do with line spacing. Imputing some kind of malice to Mozilla or Carrois (the type foundry that seems to be leading Fira's design) is just silly. – cemerick Sep 2 '15 at 12:19
  • Who said anything about malice? Or since when does "airy" = malice? The fact is that there is currently a trend toward increasing whitespace in, basically, all things UI-related. Practically every large web site that does a redesign lately greatly increases line spacing. It's what's currently popular. These same trends bleed over into the tools that are created to make these things. "More whitespace on the web site = good, therefore more whitespace in the editor = good." This dogmatism isn't malicious, it's just useless. Please try to understand before you defend against non-attacks. – blujay Sep 7 '15 at 13:44
  • 1
    Oh, and FYI, there is a Fira Code in the works with less line spacing. Hopefully it pans out. – blujay Sep 7 '15 at 13:45
  • At the moment, though, it seems to have a serious problem in Emacs. ("Comments can only be edited for 5 minutes." Sigh.) – blujay Sep 7 '15 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.