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

Set FontAwesome as first priority to avoid clashes #364

Open
wants to merge 1 commit into
base: master
from

Conversation

@pedrocr
Copy link
Contributor

@pedrocr pedrocr commented Jun 2, 2019

In some cases FontAwesome icons were replaced by letters and symbols from other fonts. Add the font as the first priority in the style sheet to avoid this issue.

In some cases FontAwesome icons were replaced by letters and symbols
from other fonts. Add the font as the first priority in the style sheet
to avoid this issue.

Fixes #363
@pedrocr
Copy link
Contributor Author

@pedrocr pedrocr commented Jun 2, 2019

Unfortunately this doesn't seem to be a full fix. The ":" in the clock is now offset vertically because apparently it's coming from FontAwesome instead of Roboto. I fixed this manually in my stylesheet by adjusting #clock but that's probably not a real solution.

@pedrocr
Copy link
Contributor Author

@pedrocr pedrocr commented Jun 2, 2019

It's actually worse than just the : being wrong. Font Awesome apparently includes letters, numbers and a few but not all punctuation. So -: are included but %() are not. This wrecks havoc in the theme. I don't see how to fix this manually as I can't add a <span class="icon"></span> around the icons themselves as CSS class is not allowed.

@pedrocr
Copy link
Contributor Author

@pedrocr pedrocr commented Jun 2, 2019

The only way I found to solve this was to sprinkle the config file with things like "<span font=\"FontAwesome 5 Free Solid\"></span>. This works but then breaks the tooltip that shows the html as text.

@Alexays
Copy link
Owner

@Alexays Alexays commented Jun 6, 2019

That's not a correct fix i think, we can add a style to force font on format-icon.
I'll look into it, and push in this pr

@pedrocr
Copy link
Contributor Author

@pedrocr pedrocr commented Jun 6, 2019

Thanks. The workaround is working for me now because I have tooltips disabled anyway. This is definitely broken, I didn't close it in case I found a different solution to push into this branch/pr.

@Alexays
Copy link
Owner

@Alexays Alexays commented Jun 11, 2019

If you move "FontAwesome 5 Free Solid" at the end, does it still fix the issue for you?

font-family: Roboto, Helvetica, Arial, sans-serif, "FontAwesome 5 Free Solid";
@pedrocr
Copy link
Contributor Author

@pedrocr pedrocr commented Jun 11, 2019

I tried that as well. But then the conflicts return as the characters in Roboto are the ones that are conflicting with the ones in FontAwesome.

@jplatte
Copy link

@jplatte jplatte commented Jun 27, 2019

Which characters are you talking about? IIRC this kind of issue is often related to font fallback in freetype and setting a list of font-families in Gtk CSS never helps because Gtk doesn't do font fallback itself (or only after freetype does its own font fallback, which makes the whole thing pointless).

@pedrocr
Copy link
Contributor Author

@pedrocr pedrocr commented Jul 6, 2019

Here's an example from my config:

broken-icons-waybar

That's how gedit renders those icons. Without the span forcing the font that's how Waybar displays things as well. Setting FontAwesome as priority fixes that but then there are other characters that are used from FontAwesome instead of Roboto, like ":" in the clock which then becomes vertically offset.

@jtheoof
Copy link

@jtheoof jtheoof commented Sep 1, 2019

Any update on this? I'm facing the issue as well.

@jplatte
Copy link

@jplatte jplatte commented Sep 1, 2019

@jtheoof Does setting a font list for sans-serif help (like in my dotfiles) as a workaround for you? (run fc-cache and restart waybar after creating or updating that file)

@jtheoof
Copy link

@jtheoof jtheoof commented Sep 2, 2019

Yes @jplatte it works thank you.

@jtheoof
Copy link

@jtheoof jtheoof commented Sep 2, 2019

So I ended up doing things a little differently but heavily inspired. I created a custom font replacement with a Waybar font name.

So that I can have in style.css:

* {
     border: none;
     border-radius: 0;
     font-family: Waybar;
     font-weight: 800;
     font-size: 12px;
     min-height: 0;
 }

This way I have the Font Awesome override but only for the Waybar font which is used only in this file.

@Eluminae
Copy link

@Eluminae Eluminae commented Sep 26, 2019

Still got some missing char with your work arounds
missing mpd
and it is weirder if I install a new ttf package as dejavu
missing network ethernet

BTW, is someone configured his bar without any font awesome symbols and having a clean look ?

@jplatte
Copy link

@jplatte jplatte commented Sep 26, 2019

@Eluminae fc-match should be able to tell you which font is being used to render U+F796. E.g. for me it's Font Awesome:

% fc-match -s monospace:charset=f796 | head -n3
Font Awesome 5 Free-Solid-900.otf: "Font Awesome 5 Free" "Solid"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSansMono-Bold.ttf: "DejaVu Sans Mono" "Bold"

You can read more about how to fix issues like this in the Arch wiki page 'Font configuration'. The section Replace or set default fonts might be especially interesting in your situation, or you might want to blacklist or uninstall a font that is claiming to support character ranges it doesn't actually supply useful characters for.

@Eluminae
Copy link

@Eluminae Eluminae commented Sep 26, 2019

Okay I got it.. In void packages we got font-awesome and font-awesome5. And guess what, font-awesome5 works very well with

font-family: "FontAwesome 5 Free Solid", Roboto, Helvetica, Arial, sans-serif;

@Eluminae
Copy link

@Eluminae Eluminae commented Sep 26, 2019

Okay now the jtheoof's way with the Waybar font alias rocks !

@jplatte
Copy link

@jplatte jplatte commented Sep 26, 2019

@pedrocr I think this PR can now be closed since the proposed changes don't work the way they were intended to, right? I've just created an issue (see link above) about improving the documentation regarding font fallback which would probably be better for further discussion than a PR.

@Eluminae
Copy link

@Eluminae Eluminae commented Sep 26, 2019

IMHO, there is still missing something for the font to be used out of the box. We still not have the solution.

@Eluminae
Copy link

@Eluminae Eluminae commented Sep 26, 2019

Maybe providing another default template who do not use font-awesome could be minimalist alternative ?

@appelgriebsch
Copy link

@appelgriebsch appelgriebsch commented Jul 9, 2020

Thanks for this hint. Was looking for the reason why it behaves like this when installing a Nerd Font on my system.

@rdnetto
Copy link

@rdnetto rdnetto commented Aug 9, 2020

Here's what worked for me:
As well as adding a font-config file, I also had to change it to: font-family: Roboto, Helvetica; (dropping Arial and sans-serif). With those two removed, appending Font Awesome to the list also worked. I guess somehow they're matching characters like (0xf026) even when they shouldn't be. Given that most users have a better understanding of how to install a font than fontconfig overrides, a simple solution here might be to just drop support for the fallback fonts and use:

font-family: Roboto, Helvetica, "Font Awesome 5 Free Solid";
@jplatte
Copy link

@jplatte jplatte commented Aug 10, 2020

@rdnetto Do you actually have Roboto or Helvetica installed on your system? Does Waybar look any different if you set just font-family: "Font Awesome 5 Free Solid";? I suspect neither is the case, and my first comment still applies:

IIRC […] setting a list of font-families in Gtk CSS never helps because Gtk doesn't do font fallback itself (or only after freetype does its own font fallback, which makes the whole thing pointless)

@rdnetto
Copy link

@rdnetto rdnetto commented Aug 11, 2020

@rdnetto Do you actually have Roboto or Helvetica installed on your system?

I can confirm I have Roboto installed. (I thought I had Helvetica installed, but I double checked and it turns out it's just "Adobe Helvetica").

Does Waybar look any different if you set just font-family: "Font Awesome 5 Free Solid";? I suspect neither is the case, and my first comment still applies:

Yes - the font changes, and th in eth0 fails to render.

For comparison, my current working config is font-family: Roboto, Helvetica; with the following font config:

    <alias>
        <family>Roboto</family>
        <prefer>
            <family>Font Awesome 5 Free</family>
        </prefer>
    </alias>
@jplatte
Copy link

@jplatte jplatte commented Aug 11, 2020

with the following font config

Right, so it's still just matching Roboto on the Gtk side and the actual per-glyph fallback happens inside fontconfig.

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

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.