Waybar icon indicating copy to clipboard operation
Waybar copied to clipboard

Ability to define font family for the icons

Open cinghiopinghio opened this issue 6 years ago • 16 comments

Great bar, thanks for your work!

Atm your bar support icons from fontawesome project. This carry many problems with weird fallbacks which depends on the font set installed by the user (to my knowledge) (I've seen several issues about fontawesome missing/mispatched fonts etc.). Is it possible/hard to implement the possibility for the user to select a different font for the icons?

cinghiopinghio avatar Mar 13 '19 10:03 cinghiopinghio

I know that this can be performed by using the pango markup as in: "<span font_desc='whateverfont'>your character</span>" but the configuration will become uite unreadable. Edit: typo Edit2: closed and reopened by mistake

cinghiopinghio avatar Mar 13 '19 10:03 cinghiopinghio

You can make it (kinda) work setting your font like this in style.css :

* {
font-family: Roboto, "Font Awesome 5 Pro Solid", "Font Awesome 5 Brands";
}

Obviously you have to replace with the fonts you want. The problem with this is that some characters, for instance the "Clock" in FA5, render as a ~ in text fonts, and because CSS tests fonts from left to right, Roboto is used to display it.

Maybe there is a way to target only the icon with a selector like #clock .icon. I've tried this one, and it does not work.

dtnmr avatar Mar 13 '19 23:03 dtnmr

I think this is more of a bug, if you set the {icon} placeholder to the left of text with a space in between, the space gets rendered with the icons font, and at least "Material Design Icons" font doesn't have the space glyph (0x0020), so a weird placeholder glyph shows up.

severoraz avatar Jul 14 '19 14:07 severoraz

Had also issues with some icons not showing up. I tinkered a while until I found out, that my AUR package ttf-ms-fonts (Arial probably) "overwrote" some glyps (volume-up, down for example).

I tried the suggestion above (put FontAwesome in styles.css). It works, but for me all other characters were now slightly different and colons were misplaced. Not as pretty as before.

I uninstalled ttf-ms-fonts now, and all icons and fonts are as expected.

cryptoluks avatar Dec 07 '19 20:12 cryptoluks

@Alexays and @dtnmr

Does Waybar support his style? For example:

@font-face
{
  font-family: "Twemoji";
  font-style: "normal";
  font-weight: "normal";
  src: url("../../.local/share/fonts/Emoji e ícones/Twitter Colour Emoji.ttf") format("truetype");
}

#custom-flag
{
  font-family: "Twemoji", sans-serif;
}

I want to set this font to the specific module, while I keep JoyPixels as system emoji font. I prefer the non-wavy rectangle flag (Twitter Color Emoji) instead of rounded flag (JoyPixels) and of wavy flag (Apple Color Emoji and Noto Emoji).

gusbemacbe avatar Feb 10 '21 19:02 gusbemacbe

I second this. It would be great if all icons were wrapped in <span class="icon">...</span> by default. That way we could explicitly set which font to use for an icon and not have to rely on complicated font fallback behavior.

Hubro avatar Jul 25 '21 18:07 Hubro

Yes, @gusbemacbe were you able to get a module specific font-family to work? For me it only seems to pick the main one and ignores the module specific one.

nnuel avatar Jan 15 '22 16:01 nnuel

Yes, @gusbemacbe were you able to get a module specific font-family to work? For me it only seems to pick the main one and ignores the module specific one.

I have tested it a dozen times, but it didn't work. It captures still rounded flags of JoyPixels instead of rectangular flags of Twemoji. I uninstalled JoyPixels and Noto Emoji fonts, left only Twemoji font, and the emojis in that module ended up being tofu.

gusbemacbe avatar Jan 15 '22 17:01 gusbemacbe

I second this. It would be great if all icons were wrapped in <span class="icon">...</span> by default. That way we could explicitly set which font to use for an icon and not have to rely on complicated font fallback behavior.

Was this ever opened/implemented?

mrshmllow avatar Apr 17 '22 08:04 mrshmllow

Pango markup doesn’t support <span class="icon">...</span>, so I came up with another workaround: wrapping all icons in the Waybar config in <span font='icon'>...</span> and adding a font “alias” into font-config /etc/fonts/local.conf:

<fontconfig>
  ...
  <alias>
    <family>icon</family>
    <prefer>
      <family>Font Awesome 5 Free</family>
    </prefer>
  </alias>
</fontconfig>

jirutka avatar May 01 '22 16:05 jirutka

Which font family should cover "", "", "", "", "", "", "", "", ""? Is it Symbols Nerd Font?

adamant-pwn avatar Nov 28 '22 17:11 adamant-pwn

Which font family should cover "", "", "", "", "", "", "", "", ""? Is it Symbols Nerd Font?

Font Awesome, apparently, but I'm not able to find the corresponding package in Ubuntu repo.

mlazzarotto avatar Feb 01 '23 16:02 mlazzarotto

Which font family should cover "", "", "", "", "", "", "", "", ""? Is it Symbols Nerd Font?

Install firacode-nerdfont also helpful

xz-dev avatar Aug 21 '23 16:08 xz-dev

Any news or solution on this? even if it's a really dumb fix I would rather go for it

iceeburr avatar Dec 10 '23 11:12 iceeburr

Any news or solution on this? even if it's a really dumb fix I would rather go for it

I just simply fix it by install fontawesome(6.1.1) and setting font-family: 'Font Awesome 6 Free'; at style.css.

xz-dev avatar Dec 10 '23 15:12 xz-dev