Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for feedback: Patched fonts may be unnecessary for many users #60

Closed
Lokaltog opened this issue Jan 17, 2013 · 54 comments
Closed

Comments

@Lokaltog
Copy link
Member

After moving the glyphs to the private use area I've done some testing and on my system and it appears that I don't actually have to have a patched font for the custom glyphs to work anymore. The glyphs look nice in all the coding fonts I've tried.

I've added a font file with only the patched symbols in it in 2cfd01e (located in powerline/fontpatcher/PowerlineSymbols.otf), and I'd like users on different systems to try this and see which systems this workaround works on.

EDIT: Please try these instructions instead!


Steps to reproduce (for Linux users, but probably quite similar for OSX users):

  1. Uninstall all fonts that may have Powerline glyphs in them.
  2. Copy PowerlineSymbols.otf to ~/.fonts.
  3. Run fc-cache -vf ~/.fonts
  4. Close all gvim instances and terminal emulators that's going to use Powerline.
  5. Start vim/gvim and select any coding font you want.

My system is running Arch Linux and vim in the Xfce Terminal. Let me know which systems and fonts you're using, and feel free to provide screenshots of how it looks.

Thanks!

@kwbr
Copy link

kwbr commented Jan 17, 2013

Does not work in Debian (unstable) distribution. I see only artifacts. I use gnome-terminal by default but also tried xfce4-terminal and various fonts.
screenshot

Seems Arch Linux is more advanced in it's font system. What is it?

@amadeus
Copy link

amadeus commented Jan 18, 2013

I couldn't get this to work on Mac OSX.

I did the following:

  1. Removed all powerline enabled fonts. Replaced with stock versions
  2. Installed this custom symbols font.
  3. Used an App called Cocktail to clear the font cache.
  4. Restarted and launched MacVim.

All this resulted in the same results as @kwbr

Cheers

@rizzatti
Copy link

Couldn't make OS X fallback to grabbing the symbols from that font either.

@imaginationac
Copy link

Just tried this on Linux Mint Debian, did not work.

@Lokaltog
Copy link
Member Author

Crap, that's unfortunate. Thanks a lot for trying it though. Do you all get the exact same result as kwbr? Because in his case it appears that he already has another font on his system that occupies the same code points as Powerline, and for some reason fontconfig chooses to use that other font as a fallback instead of PowerlineSymbols. I've done some research and I think this may allow Linux users to define the order of fallback fonts, it would be great if you could try this.

Add the following to either ~/.config/fontconfig/fonts.conf or ~/.fonts.conf depending on your fontconfig version:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">

<fontconfig>
    <!-- ... -->

    <alias>
        <family>monospace</family>
        <prefer>
            <family>PowerlineSymbols</family>
            <family>YOUR MONOSPACE FONT HERE</family>
        </prefer>
    </alias>

    <!-- ... -->
</fontconfig>

Then set the font in your terminal emulator or gvim to "monospace". You may have to close all instances of terminals/gvim or even restart X for the changes to take effect.

The point here is that fontconfig has a feature that automatically chooses a fallback font for missing glyphs in the current font (I don't have many fonts on my system and none of my fonts use any code points in the PUA which may be the reason this works for me). If it's possible to define PowerlineSymbols as the default fallback font any applications will automatically select the special glyphs for any font that doesn't already have them. This workaround will set PowerlineSymbols as the default/top priority monospace font, with your monospace font of choice as the fallback font.

Unfortunately it appears that OS X doesn't support this feature for glyphs in the PUA, but if anyone is up for the task and wants to investigate this issue on OS X it would be greatly appreciated.

@amadeus
Copy link

amadeus commented Jan 18, 2013

This is what my powerline looks like without a special font on OSX, 1.8.2
powerline-error

@Lokaltog
Copy link
Member Author

@amadeus What happens if you select the PowerlineSymbols font as the font in your terminal/gvim?

@amadeus
Copy link

amadeus commented Jan 18, 2013

It looks like it applies Lucida Grande (the default Mac OSX font)
Screen Shot 2013-01-17 at 11 21 05 PM

@Lokaltog
Copy link
Member Author

Whey, it looks like a step in the right direction at least! Is there somewhere in OS X you can select the default system-wide monospace font?

@amadeus
Copy link

amadeus commented Jan 18, 2013

Not that i am able to find, unfortunately.

@Lokaltog
Copy link
Member Author

I've tried googling around as well, and it doesn't seem to be a built-in way of customizing the font in OS X. Found this, but it seems like more of a hassle to install that and changing your settings than just installing a patched font in OS X.

Edit: We could say that the trick works for anyone who enjoys the default monospace font in OS X though. :P

@kwbr
Copy link

kwbr commented Jan 18, 2013

Modifiying the fonts.conf (in my case ~/.fonts.conf) as described works!

@Lokaltog
Copy link
Member Author

Excellent! Does it look nice as well, or does it have big gaps, weird offsets, etc. on your setup?

@kwbr
Copy link

kwbr commented Jan 18, 2013

Looks good.

But now every Monospace font is the same as the Terminal's font. This may be a problem for some users if they want to use different fonts for Browsers and Terminals.

@Lokaltog
Copy link
Member Author

That's true, but it's still possible to customize the monospace font to another one in browsers. It's a tradeoff, but I have the impression that most users use the same monospace font system-wide.

Lokaltog added a commit that referenced this issue Jan 18, 2013
Lokaltog added a commit that referenced this issue Jan 18, 2013
@Lokaltog
Copy link
Member Author

It may be possible to workaround the issue, I'm investigating if there's some fontconfig magic that allows us to add the symbol font as a prioritized system font without overriding the default monospace font.

@Lokaltog
Copy link
Member Author

@kwbr Can you try this: Remove the other fontconfig stuff you used, and copy this file into ~/.fonts.conf.d/, and see if you still get the correct glyphs.

@kwbr
Copy link

kwbr commented Jan 18, 2013

@Lokaltog Works as expected. Perfect! As I use PragmataPro the file suites my needs.

Lokaltog added a commit that referenced this issue Jan 18, 2013
@Lokaltog
Copy link
Member Author

@kwbr Awesome. The glyphs are made for Pragmata Pro by the author of the same font so they work very well with that font ;) Thanks for the help!

I'll leave this issue open in case someone experiences some other problems with this method.

@ghost
Copy link

ghost commented Jan 19, 2013

I'm running into the same issue @kwbr was earlier. I'm on debian testing, but haven't come up with a solution yet. I have tried placing 10-powerline-symbols.conf in both ~/.config/fontconfig/conf.d/ and ~/.fonts.conf.d/ as well as restarting xorg.

2013-01-19-000932_834x17_scrot

@ZyX-I
Copy link
Contributor

ZyX-I commented Jan 20, 2013

Feedback:

Konsole, terminus, 11pt: Weird @

Konsole, terminus, 14pt: Invalid symbols: z`

Konsole, Ubuntu Mono: Not centered

Konsole, Droid Sans Mono: Fine Fine (but not Droid Sans Mono Dotted/Slashed)

Konsole, Liberation Mono: Fine Fine

Konsole, Bitstream Vera Sans Mono: Fine Fine (with bigger font not so fine, but font is not so fine as well).

Konsole, Lucida terminal: same as Terminus.

Konsole, Inconsolata: Fine Fine

Konsole, DejaVu Sans Mono: Fine Fine

Konsole, Monospace, 13pt: Fine Fine

Konsole, Monospace, >13pt: >=1px gap between one or another border >=1px gap between one or another border.


Xterm launched with xterm -fa DroidSansMono: No symbols


Rxvt-unicode launched with urxvt -fn "-bitstream-bitstream vera sans mono-medium-r-*-*-17-*-*-*-m-*-iso10646-1" -fb "-bitstream-bitstream vera sans mono-bold-r-*-*-17-*-*-*-m-*-iso10646-1": No symbols


Konsole, Terminus, 11pt with additions to 10-powerline-symbols.conf: Not centered. Additions:

<alias>
    <family>Terminus</family>
    <prefer><family>PowerlineSymbols</family></prefer>
</alias>

Anonymous skipped (no stable version).

Consolas, source code pro, menlo, pragmato*, monaco, envy code r skipped (not present in repository).

@ZyX-I
Copy link
Contributor

ZyX-I commented Jan 20, 2013

Summary: terminus, Ubuntu Mono are not working well. Bitstream Vera Sans Mono, Monospace work fine for relatively small sizes. Nothing works in xterm/rxvt-unicode.

@Lokaltog
Copy link
Member Author

@gregf Which terminal emulator are you using? And have you set the required UTF-8 environment variables as specified in the docs?

@ZyX-I Nice! What do you think, should we add terminus to the fontconfig file even if it looks bad? Edit: rxvt-unicode doesn't work at all unless it's compiled with --enable-unicode3, and I think you can manually specify the fallback font by having two xorg font names separated by a comma.

@ghost
Copy link

ghost commented Jan 20, 2013

@Lokaltog Using rxvt-unicode with unicode3 enabled. My locale is set to en_US.UTF-8, and both my vimrc and tmux.conf have utf-8 enabled. I also tested in xterm with multiple fonts same problem.

@Lokaltog
Copy link
Member Author

Hmm, which font are you using then? It may not be present in the fontconfig file.

@ghost
Copy link

ghost commented Jan 20, 2013

@Lokaltog Inconsolata normally, but I tried other fonts specifically listed in the fontconfig you provided.

@Lokaltog
Copy link
Member Author

That's too bad. I'll look into how you can specify fallback fonts for urxvt (I'm not even sure if it uses fontconfig since it reads its settings from Xresources or the command line).

@Lokaltog
Copy link
Member Author

Not sure if it's even possible to resolve the issue, there's really not much we can do with the symbol font without screwing up every other font. I'll remove Ubuntu Mono from the fontconfig file until a fix is discovered.

@ghost
Copy link

ghost commented Jan 20, 2013

Adding URxvt.font: xft:PowerlineSymbols:pixelsize=11,xft:Inconsolata to my config gives me the the following error.

urxvt: unable to calculate font width for 'PowerlineSymbols:pixelsize=11:minspace=True', ignoring.
urxvt: unable to load base fontset, please specify a valid one using -fn, aborting

So, I tried reversing the order of the fonts, and initially there was no error. When I fire up vim or tmux I then see this printed to console.

urxvt: unable to calculate font width for 'PowerlineSymbols:slant=0:weight=100:pixelsize=11:minspace=True', ignoring.

@ZyX-I
Copy link
Contributor

ZyX-I commented Jan 20, 2013

Not sure if it's even possible to resolve the issue, there's really not much we can do with the symbol font without screwing up every other font. I'll remove Ubuntu Mono from the fontconfig file until a fix is discovered.

I did not suggest adding a fix to existing font: I believe it is not possible without breaking something. I suggested to add another font (maybe more then one) and update fontconfig so that Ubuntu Mono and Terminus will use this new font.

@Lokaltog
Copy link
Member Author

That's an excellent idea, let's do that!

@ghost
Copy link

ghost commented Jan 20, 2013

@Lokaltog well for the mean time I have switched to xfce4-terminal, which is a lot nicer than I had expected. Works just fine there. Thanks for the help.

Lokaltog added a commit that referenced this issue Jan 20, 2013
@Lokaltog
Copy link
Member Author

@gregf I personally would recommend you to stick with it, unless you find one that's much better for you. I've tried all the most common terminal emulators after I ditched urxvt and I think the Xfce terminal is the best I've tried. It listens to fontconfig so the font rendering is nice, it doesn't screw up the private use area, the only downside is that urxvt appears to have better performance and customizability but I don't think it's worth it if you're going to use Powerline. I'm glad that the issue got resolved for you.

@ZyX-I
Copy link
Contributor

ZyX-I commented Jan 21, 2013

@Lokaltog And what’s with Konsole? It does not screw up the private use area and listens to fontconfig as well, but also supports 24-bit color: the only one from the list (except for tilda, guake, lilyterm, lxterminal, mt (though don’t think it will be different from sakura), sjterm, termit, termite which were not tested). Yakuake is known to also work well, but I consider it not being a separate thing from konsole.

All terminal emulators from that list are said to use vte library (and tilda also pulls this as a dependency, though not said to use vte in arch wiki), so they are all not expected to work with 24-bit as some other vte-based do not.

@Lokaltog
Copy link
Member Author

@ZyX-I Depends on whether you're using mainly Qt or GTK based apps, I guess. I don't have KDE or any other Qt based apps on my system, so installing Konsole pulls a hefty 200MB of dependencies along with it. I should have added that I haven't tried the other Qt apps for the same reason, but for GTK users the Xfce terminal works great. Edit: And it sucks if it won't support 24-bit colors in the foreseeable future, because that looks like an awesome feature.

@Lokaltog
Copy link
Member Author

Closing this as it seems to work fine for the users who are able to use this method, and instructions have been added to the docs.

@ZyX-I
Copy link
Contributor

ZyX-I commented Jan 22, 2013

@Lokaltog I use mainly Qt or Qt/KDE apps, but if gtk apps were the first ones that worked fine for achieving specific task they are installed and kept; and I actually have a number of them. I see no reason to be afraid of having both toolkits, you just prevent yourself from using better applications if you forbid any of the toolkits.

@Lokaltog
Copy link
Member Author

@ZyX-I Allright, I'll try Konsole today and see how it works. ;)

@Lokaltog
Copy link
Member Author

@ZyX-I So Konsole quickly became my default terminal emulator, and I absolutely love the possibility of changing properties like the cursor shape via escape codes!

@skinner33
Copy link

I think i 'know' why the patched fonts don't work with urxvt.

Apparently urxvt supports some kind of combining of characters to form new characters (manual, --enable-combining).
Therefore urxvt uses the private use area, which is also used by the new symbols in powerline (in vim-powerline they were in a lower area), and always assumes that symbols in this area are home-made and don't use the font.

So, what to do?

I took a look at the source (well, i did that before to be accurate :P) and found that urxvt uses 3 different ranges, depending on the compiler flags:

With perl supoort enabled it is 0xe000 - 0xf8ff (57344 - 63743) which leads to the known faulty behavior.
When perl is not enabled the lower bound starts at 0xd800 (55296).

I have no idea why the bound depends on the perl support, although it doesn't matter.

So the good news: if you don't care about memory usage there is another bound:

With unicode3 enabled (--enable-unicode3), the lower bound is 0x40000000.

According to the manual, this will increase the memory used for one screencell (e.g. a character in the scrollbackbuffer) by 2 byte to 8 bytes, but the fonts work

tl;dr:
if urxvt is compiled right (--enable-unicode3), it will work with the powerline fonts.

@ghost
Copy link

ghost commented Jan 23, 2013

@skinner33 I have urxvt compiled with unicode3 and it never worked for me.

rxvt-unicode (urxvt) v9.15 - released: 2012-01-21
options: perl,xft,styles,combining,blink,iso14755,unicode3,encodings=eu+vn+jp+jp-ext+kr+zh+zh-ext,fade,transparent,tint,pixbuf,XIM,frills,selectionscrolling,wheel,slipwheel,smart-resize,cursorBlink,pointerBlank,scrollbars=plain+rxvt+NeXT+xterm

@skinner33
Copy link

argh just saw that the unicode3 was already mentioned above ...

@gregf
i have the following urxvt

rxvt-unicode (urxvt) v9.16 - released: 2012-11-06
options: perl,xft,styles,combining,blink,iso14755,unicode3,encodings=eu+vn+jp+jp-ext+kr+zh+zh-xt,fade,transparent,tint,pixbuf,XIM,frills,selectionscrolling,wheel,slipwheel,smart-resize,cursorBlink,pointerBlank,scrollbars=plain+rxvt+NeXT+xterm

Furthermore i have some patches applied, essentially its this package with unicode3.

Also are you sure you have the right font configured? try ctrl + shift + 52, then while still holding ctrl + shift, in the 4th line the font used should be given.

@ghost
Copy link

ghost commented Jan 23, 2013

@skinner33 It appears our options are the same. I was a version behind you, and missing the font-width.patch. So I removed urxvt from my system, and compiled it by hand using the patches, and same options from the PKGBUILD you provided. Sadly, it still doesn't work on my end.

I am Currently using Inconsolata.

URxvt*font:     xft:inconsolata

@Lokaltog
Copy link
Member Author

@gregf I think you have to use a patched font with urxvt (I haven't been able to make the fallback font method to work), have you tried using Inconsolata from the powerline-fonts repo?

@ghost
Copy link

ghost commented Jan 23, 2013

@Lokaltog I switched to xfce4-terminal after your recommendation. I was just speaking with @skinner33, as he posted above he had it working without the patched font.

@skinner33
Copy link

@gregf i newer said that i didn't had a patched font, in fact i'm using a patched Inconsolata.

@Lokaltog
Copy link
Member Author

@gregf Ah, I see.

Anyways, regarding the urxvt support: the official recommendation is to switch to another terminal emulator unless you have a very good reason to keep using urxvt. It works in several strange, non-standard ways (the defective unicode support and lack of fontconfig support are two good examples) and I personally haven't missed any urxvt-specific fuctionality after switching to another terminal emulator. If a patched font works then all is good, but if you don't require any specific urxvt features and don't want to compile your own unicode3 variant you might as well switch to something else.

@ghost
Copy link

ghost commented Jan 23, 2013

@skinner33 I'm sorry, I miss understood your original post!

@ZyX-I
Copy link
Contributor

ZyX-I commented Feb 3, 2013

I was false about Terminus: it displays fine, except for branch symbol. And except for the case when you try to force konsole to display terminus with unsupported size. I.e. without branch segment it displays as following:

1 px shift

. Has 1 pixel shift

1 px shift: zoomed

, but it is hard to notice without zooming. Fontforge shows that arrow symbol extends 5 points (?) beyond branch symbol. Altering branch symbol so that its vertical dimensions match those of hard arrow did not fix the issue: (old new, “z” fragment is the same for both)

Old branch, new branch, shifted z

Altering it so that horizontal dimensions also are not greater then wide arrow ones did not fix the issue as well. I have no other ideas.

@kierun
Copy link
Contributor

kierun commented Mar 11, 2013

Which terminal would you recommend to replace urxvt?

I cannot get the terminus font to work for it and while I am attached to urxvt, I can be convinced to use something else.

@Lokaltog
Copy link
Member Author

I was also very attached to urxvt (and later Gnome Terminal), but ZyX-I convinced me to try out Konsole and I'm really happy with that. Just configure away the menu line and tabs and all that stuff and fix the colors, and you have basically the exact same thing. And in addition:

  • True color support
  • Possibility to change all Terminal properties with an escape sequence (e.g. switch cursor properties in insert mode)
  • Much better fontconfig support and very nice antialiasing
  • Very good performance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants