Consolas Font in Vim Powerline (Windows)

Update: Fixed a small rendering issue with the left-facing block arrow. If you noticed a thin line to the right of that arrow (you can actually see it in the screenshot below if you look hard), grab the latest version. That fixes the problem.

Github: https://github.com/eugeneching/consolas-powerline-vim

A colleague of mine introduced me to the beauty of Powerline, for Vim. In short, it’s a very beautiful status bar for Vim. It looks like this:

Powerline is a utility plugin which allows you to create better-looking, more functional vim statuslines.

The status bar uses some fancy symbols that are not found in a normal font. The pretty right and left facing arrows you see are those fancy symbols. Hence, Kim (Lokaltog), the author of Powerline, provides a “font patch” to patch any given font with the correct symbols, so that Powerline can look, well, beautiful. If that fails, there is a revert, that doesn’t use fancy symbols, which looks like this:

I don’t know about you, but to me, that’s a far cry from the beautiful, if I may say, real, Powerline.

 

Consolas

So what’s the problem? The problem is that the font patch to make the fancy symbols appear doesn’t work with the Consolas font. And Consolas is a very beautiful and elegant font for programming. In pursuing the Consolas font patch, I experienced various things, from the font being uninstallable, to it installing but rendering horrendously. Absolutely losing the quality of the beautiful Consolas. Hence, this post is about Powerline with Consolas. If you’re not a fan of Consolas, then this really isn’t for you :)

So, the problem with using this with gVim, on Windows, is that the Consolas font cannot be patched correctly. After going through loops, and learning quite a bit about fonts in the process (that’s a good thing!), what I’ve provided here is a set of already fixed Consolas fonts, for all the four default font-faces (regular, bold, italics, bold-italics).

Here’s my Vim with Consolas, and Powerline:

I like light themes, hence the difference from the first screenshot, but in any case, the point is the fancy bar!

In order to use these files, you also need to fix up your .vimrc. For convenience, here’s the part that matters:

set encoding=utf-8
set guifont=Consolas\ for\ Powerline\ FixedD:h9
let g:Powerline_symbols="fancy"

The encoding setting is to tell Vim to display the UTF symbols correctly. The patched file contains those fancy arrow-like symbols as part of a UTF-8 encoding, so Vim needs to know about that in order to display that correctly.

The FixedD part is just a random name I gave it, as I iterated through the patching. The h9 refers to the font size I want. That means a 9 point font size. Change it to whatever pleases you.

The Powerline_symbols setting is to tell Powerline to use the fancy symbols so that you get the nice arrow-like effect. It’s an internal Powerline setting.

As a note, it’ll be a good idea to hit :PowerlineClearCache.

Finally, and of course, I assume you already have your basic Powerline functioning. If you don’t, do check out the package manager Vundle, which makes installing Powerline a breeze. But that’s for another time!

Github: https://github.com/eugeneching/consolas-powerline-vim

Comments
20 Responses to “Consolas Font in Vim Powerline (Windows)”
  1. Ken says:

    You saved me a lot of time grabbing all of the dependencies for the fontpatcher. Thank you so much!

    Consolas sure does look great in vim and with Powerline.

  2. George says:

    First of all: I think it’s great of you to provide patched versions of Consolas, which is indeed one of the best coding fonts. But sadly, it doesn’t work for me. I successfully installed it and added the lines to my _vimrc. I already tried restarting gvim and clearing the Powerline-cache using :PowerlineClearCache several times, but both didn’t work. Do you have any idea what could have gone wrong?

  3. Grippen says:

    Works beautifully, using vim on Cygwin’s mintty. Thanks!

  4. Eugene Ching says:

    Well, it’s hard to tell what happened off-hand, and I don’t mean to state the obvious but is there a chance that you are overriding the font settings in your vimrc later? Also, I assume you’re using gVim for Windows. On another train of thought, when you say it’s not working, do you mean that the font -is- actually Consolas but the rendering is poor, or does the font not even display as Consolas? Finally, do your other applications see the modified Consolas font (which should show up as “Consolas For Powerline FixedD”, such as in Microsoft Word, or similar? Hope you can find the cause! If you really want, hit me up on email.

  5. Manu says:

    Thank you so much for this! I had tried to patch Consolas quite a while back but was never able to do so. The resulting font, although had the fancy symbols, was all washed out and it looked like the original hinting information was gone.

    It would be great if you could write a blog post on how you got the patcher working with Consolas?

  6. jdg says:

    Worked great for me! Thanks for your good work. I love your blog.

  7. gfixler says:

    You are the best kind of person. This works great (once I remembered to clear the cache). There is one character not working for me on Windows 7, however, even after clearing cache. It shows up during line or block visual mode in Powerline at the left. I see either “V?LINE” or “V?BLOCK”, respectively. Any idea why that’s happening?

    Thanks!

  8. codejury says:

    Hi gfixler, could you email me a screenshot? Also, the relevant lines in your vimrc would always be helpful in debugging the issue.

  9. theo says:

    Hi,

    Thanks for the fonts, it works well with cygwin/mintty.

    Although, I have trouble with gvim.

    First of all, the option
    set guifont=Consolas for Powerline FixedD:h9
    didn’t work.

    I had to use
    set guifont=Consolas\ for\ Powerline\ FixedD:h9

    I’m surprised nobody had this error before me.

    But even now it’s not totally working.

    I’ve uploaded screenshots here : http://imgur.com/a/z7Wcg#0

    The first screenshot is what I see with the fancy mode enabled. The separation characters are not displayed as expected. I see € and ‘f’ signs instead.

    The second screenshot is what I see with the fancy mode disabled. The left and right parts are ok, but the middle (between “dos”, “latin1″ and “vim”), where ‘f’ used to be displayed are now empty.

    I also tried with/without ‘set fillchars+=stl:\ ,stlnc:\’ and with/without ‘set t_Co=256 “‘, but nothing worked.

    Any ideas?

  10. codejury says:

    First off, thanks for the escaping of the font name. I missed it out, my bad. Corrected now, so thanks!

    With regard to your queer characters, may I just ask if you set the encoding in your vimrc to utf-8?

  11. gfixler says:

    Here’s what I’m seeing. It’s the same for V-Line.

    http://i.imgur.com/Jf7Le.png

    This is in my .vimrc:

    if g:Powerline_enabled
    set encoding=utf-8
    set guifont=Consolas\ for\ Powerline\ FixedD:h11
    let g:Powerline_symbols = ‘fancy’
    set laststatus=2
    highlight VertSplit ctermbg=234 ctermfg=234
    endif

    Thanks for looking in it.
    -g

  12. gfixler says:

    And I meant “It’s the same for V-Block.”

  13. codejury says:

    Hi gfixler, unfortunately I am unable to reproduce the issue. I’ve tried precisely replicating your .vimrc on a fresh OS and Vim install, with the only additional step of installing the font (of course), and it seems to work fine. I installed Powerline using Vundle but I highly doubt that’s going to be an issue at all. Just to ask, are you using the English version of Windows?

    Sorry that I can’t give you a solution off-hand. If I do find one rest assured I’ll let you know.

  14. VimOnWin says:

    @ gfixler: I had the same problem on Win8. It seems to be a github encoding issue. To fix it, edit “vim-powerline-develop\autoload\Powerline\Functions.vim” with Notepad++ (or any good editor) and change the buggy characters manually.

  15. qall says:

    Thanks VimOnWin, that solved the problem for me! But you can actually keep using Vim! This will show you more clearly what command are involved. Then just substitute the strange ? symbol using 183 or .M
    ;)

  16. qall says:

    Oops, part of the commands is gone… i meant CTRL-v 183 or CTRL-k .M

  17. tre says:

    I’m getting a ? on my powerline on windows. I’m using a pached font but its now showing any icons.

  18. Darcy says:

    I had the same problem on windows. As an alternative to editing “vim-powerline-develop\autoload\Powerline\Functions.vim”, you can also add this to your vimrc:

    let g:Powerline_mode_V=”V·LINE”
    let g:Powerline_mode_cv=”V·BLOCK”
    let g:Powerline_mode_S=”S·LINE”
    let g:Powerline_mode_cs=”S·BLOCK”

  19. Richard Goodrich says:

    I tried it and it is nice, but still cannot get the FOR ALL symbol to show-up correctly (upside down A)
    which is dec 2200, hex 8704 in utf-8. I can get it to work in MS_GOTHIC butt that is a VERY ugly font!

    Wish I could use Consolas which is great except for that symbol – any ideas?

  20. Stormy says:

    It appears this font no longer works for Powerline:

    > Warning
    > The code points have changed in this version of Powerline! This means that you either have to patch your font again, or change the glyphs Powerline uses in your user configuration.

    Will you be rereleasing this font with the new patches, or perhaps post instructions on how you accomplished it the first time?

    Thanks!

Leave A Comment

*