13

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 05 '15 at 00: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 05 '15 at 04: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 05 '15 at 19:19
  • @Drew As you guessed, that didn't make any difference. Thanks though. –  Apr 07 '15 at 02:59
  • @wvxvw The Fira Sans fonts come in OTF and TTF, but for some reason the Mono one only comes in OTF. Anyway, thanks for that idea, maybe I'll look into that. –  Apr 07 '15 at 03:01
  • @jch: That didn't make any difference, but thanks. –  Apr 07 '15 at 03:01
  • 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 07 '15 at 05:46
  • How do Fira and Dejavu compare to each other on Kate? – Malabarba Apr 07 '15 at 17:27
  • 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 08 '15 at 11:47
  • @blujay have you tried setting (setq line-spacing .7) in the buffer? When it's float, it reduces line spacing, as opposed adding pixel. If this works in a buffer, then we can probably try set-default and that might solve the problem. – Xah Lee Jul 17 '15 at 07:22
  • @XahLee Thanks but that doesn't seem to work. When I run `(setq line-spacing .7)`, the line spacing increases greatly. Then, `(setq line-spacing 1)` causes line spacing to decrease, and finally `(setq line-spacing nil)` resets it to the minimum/default. Even though `C-h v line-spacing` says `If value is a floating point number, it specifies the spacing relative to the default frame line height`, it doesn't reduce it as should be the case. Using Emacs 24.4 on this system. –  Aug 23 '15 at 16:39

1 Answers1

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

cemerick
  • 121
  • 2
  • 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. –  Sep 02 '15 at 07: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 02 '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. –  Sep 07 '15 at 13:44
  • 1
    Oh, and FYI, there is a [Fira Code](https://github.com/tonsky/FiraCode) in the works with less line spacing. Hopefully it pans out. –  Sep 07 '15 at 13:45
  • At the moment, though, it seems to have [a serious problem](https://github.com/tonsky/FiraCode/issues/46) in Emacs. ("Comments can only be edited for 5 minutes." Sigh.) –  Sep 07 '15 at 13:56