justbuchanan / i3scripts

My scripts for enhancing i3wm
Other
162 stars 45 forks source link

Use system fontawesome #31

Closed fn-ix closed 5 years ago

fn-ix commented 5 years ago

Hello!

I was wondering if it's possible to configure the autorename_workspaces.py script to reference the FA file that's installed on the system along with other fonts as opposed to the one installed through pip. The one in the python repository tends to be updated more slowly, so it's not possible to take advantage of the newest icons.

Alternatively, would it be possible to feed the script the unicode code for the desired characters directly and thus bypass the need for the script to handle fontawesome altogether?

justbuchanan commented 5 years ago

Hi @hfel, the fontawesome python package actually isn't a font at all - it's just a mapping from the name of an icon to character code for the font. You can try this out in python:

python3
>>> import fontawesome
>>> fontawesome.icons['youtube']
'\uf167`

The python package gives you the character code, which is later rendered by i3bar using the system-installed font. If you have a newer version of the font awesome font on your system that the python package doesn't have a mapping for, you can just use the character code directly in the autoname_workspaces.py script. Instead of writing fontawesome.icons['youtube'], you can use \uf167. Alternatively if you notice that the python package is out of date, feel free to open an issue on the github repo requesting that it be updated: https://github.com/justbuchanan/fontawesome-python.

I just updated fontawesome to version 5.10.1, so a pip3 install --upgrade fontawesome will get you the latest.

fn-ix commented 5 years ago

Ok, thanks. My question was though if it's not possible to use the system-installed font for the mapping itself as well. EDIT: I guess it doesn't contain the name info...

EDIT2: Replacing the fa.icons['name'] line with the relevant character code in the autorename script didn't work for me. I even tried your example of youtube and \uf167; no glyph gets displayed at all.

EDIT3: Actually, I still have problems displaying some of the new glyphs. I have only one version of FA installed on my system, which seems to be referenced correctly in the bar config, at least according to fc-match. For example, for the glyph dharmachakra I instead get a cross. I already checked the character code in gucharmap and there it is mapped to the correct glyph, so it doesn't seem to be a problem with the font itself. Note that I am using polybar, so it's possible the problem lies in that, but I have no idea where to begin, since the most likely explanation seems to be that the autorename script is still somehow feeding it old character codes, although that seems impossible too, since running just the fontawesome package in python like in your example I get the correct character code for dharmachakra. :|

justbuchanan commented 5 years ago

Yeah unfortunately I don't think the font contains the "name" for each glyph, so the mapping has to be generated from the source and not the font itself.

Hmm, it sounds to me like you have it setup correctly, so I'm not sure what the issue is. Are you able to get any icons to work (that you've tried) or do they all seem broken? I'd guess it's an issue with the polybar setup, but I don't have much familiarity with it. It's possible this github issue is relevant, but I'm afraid I don't know much about it: https://github.com/justbuchanan/i3scripts/issues/29.

fn-ix commented 5 years ago

Most icons work correctly, but some don't, almost as if polybar was using the older version of FA. I'll bring it up with them.