I am trying to set [Inconsolata-dz][1] as my default font to Emacs. Regular Inconsolata works fine, but the dz version is not working properly. Most functions I use keep throwing this error (followed all the instructions online on how to set Emacs font):

set-face-attribute: Invalid font name: "-*-Inconsolata-dz-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1"

I finally got it to work by doing this in my init.el:

(setq initial-frame-alist '((font . "Inconsolata-dz-13")))
(setq default-frame-alist '((font . "Inconsolata-dz-13")))

I also have this in init.el, which was generated by customize-faces, but it seems to change the font to Helvetica (unless overridden by the code above):

 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.

 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :inverse-video nil
             :box nil :strike-through nil :overline nil
             :underline nil :slant normal
             :weight normal :height 140 :width normal
             :foundry "nil" :family "Inconsolata-dz")))))

Now the issue with the first code above is that doing a Ctrl+N, to create a new window will throw the same Invalid font name error.

I installed Inconsolata and Inconsolata-dz the same way on my Mac. Just the regular, default way of installing fonts on OS X.

Does anyone know what I'm doing wrong and how I can use Inconsolata-dz properly?

  • 1
    To see what fonts are available, evaluate the following in a *Scratch* buffer: (insert (prin1-to-string (x-list-fonts "*"))) If it is not there, then it's not available.
    – lawlist
    Sep 23, 2015 at 18:30
  • @lawlist I see it there but it is a very long name. When I pasted it into set-face-attribute, ((set-face-attribute 'default nil :family "-*-Inconsolata-g-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1")), I get 'Invalid face foundry'. Any ideas why? What exactly is the name suppose to be? Inconsolata works but Inconsolata-g and Inconsolata-dz do not work, even though they're all available and installed the same way. I suspect it's the dash in the name?
    – darksky
    Sep 24, 2015 at 14:40

1 Answer 1


Emacs doesn't allow fonts that have hyphens in them. I would rename the font to something that doesn't contain hyphens.

You can do this using ttx. For example, assuming you have a font named Inconsolata-dz for Powerline.otf in your current working directory:

# Convert the font to ttx format (an xml-like font format)
ttx "Inconsolata-dz for Powerline.otf"

# Replace all instances of "Inconsolata-dz" with "InconsolataDZ" in the ttx file
sed -i 's/Inconsolata-dz/InconsolataDZ/g' "Inconsolata-dz for Powerline.ttx"

# Convert the resulting ttx file back to an otf file. 
# (Will create a file called "Inconsolata-dz for Powerline#1.otf".)
ttx "Inconsolata-dz for Powerline.ttx"

You can then rename the produced otf file to whatever you want and move it to your fonts directory.

  • Do you have an example or a link to some documentation to support your belief that "Emacs doesn't allow fonts that have hyphens in them."?
    – lawlist
    Dec 19, 2016 at 0:29
  • 5
    My specific problem was that I was seeing the error "Invalid font name: Inconsolata-g for Powerline". I searched the Emacs source code for "Invalid font name:" and found this function. I believe that if you look carefully at the font_parse_name function, you'll find that parses the XFT string by splitting it at the hyphens, assuming that the entire font name is contained between two hyphens.
    – sid-kap
    Dec 19, 2016 at 0:33
  • 1
    Thanks so much @sid-kap, finally an answer! I've never figured this one out.
    – darksky
    Dec 20, 2016 at 15:32
  • 3
    You can rename the font without using ttx nor converting the font files. I visited the font files Inconsolata-g.otf, Inconsolata-g.sfd, and Inconsolata-g.ttf with Emacs and replaced every occurrence of "Inconsolata-g" and "Inconsolata-d" with "Inconsolata_g" and "Inconsolata_d". This text also appears intermingled with "^@" as in "I^@n^@c^@o^@n^@s^@o^@l^@a^@t^@a^@-^@g^@Inconsolata-g" which I have replaced as "I^@n^@c^@o^@n^@s^@o^@l^@a^@t^@a^@_^@g^@Inconsolata_g". I have then renamed the filenames as Inconsolata_g.* and drag-and-drop'd them into Font Book.app, which worked. Mar 22, 2017 at 13:24
  • @sid-kap Thank you, your instructions were very clear. Great answer. Apr 2, 2018 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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