question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Icon builder from font awesome

See original GitHub issue

I’ve just got a streamdeck for christmas and am loving it! Though I find it cumbersome to search for icons so I wrote a quick&dirty program to pull icons from Font Awesome and render them in the correct size as 72x72 png files: streamdeck-fontawesome

What I’m asking is: Would this be a desirable feature to add to streamdeck-ui? I’d imagine a small text field where one would enter, for example, volume-up and the corrrect image is displayed.

To quote https://github.com/FortAwesome/Font-Awesome

In the Font Awesome Free download, the CC BY 4.0 license applies to all icons packaged as .svg and .js files types.

So the icons can be shared and remixed as long as attribution is given.

I see two ways of implementing this:

  • streamdeck-ui could just wget https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/metadata/icons.yml, search for the desired icon and download only this from the correct location in the official github-repo
  • streamdeck-ui could, by default, ship with all icons (all svgs are about 1.6 megabyte, but they could also be pre-rendered as .png instead)

I’d volunteer to implement this if it seems like a useful feature.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:8

github_iconTop GitHub Comments

2reactions
dodgyrabbitcommented, Feb 1, 2022

Probably doesn’t make sense to bundle fonts with this program. However, maybe an alternative is to make it possible to pick the desired font and size for the “Text” field. “Nerd fonts” is also a really good option if you’re looking for fonts with ligatures and glyphs.

1reaction
Gnarflordcommented, Jan 2, 2022

Ok, but I mean really quick&dirty! This is a small python program, it needs a pip-package (installed via pip install fontawesome) and the font awesome as ttf (which I’ve installed under Arch via pacman -S ttf-font-awesome).

Problem is: Generic icons (volume control etc) and brand icons (spotify) are in seperate font-files. Because I’m lazy I simply run the script twice, once with fa-solid-900.ttf and then again with fa-brands-400.ttf

Good luck!

from PIL import ImageFont, Image, ImageDraw
import fontawesome as fa
import os

# List of icons to draw
# Elements are either "icon-name" or ["icon-name", "color-code"]
icons = [
        "volume-down",
        "volume-up",
        "fast-forward",
        "forward",
        "fast-backward",
        "microphone-slash",
        "volume-mute",
        "music",
        "undo",
        "play",
        ["spotify", "#1db954"], # Draw Spotify in nice green!
        ]

# Load a OpenFont format font from a local directory as an ImageFont object
# In this case, a TrueType font using the truetype method.

# Uncomment the needed TTF: fa-solid for generic icons and fa-brands for brand icons!
font = ImageFont.truetype(font='/usr/share/fonts/TTF/fa-solid-900.ttf', size=45)
#font = ImageFont.truetype(font='/usr/share/fonts/TTF/fa-brands-400.ttf', size=45)

for element in icons:
    if isinstance(element, list):
        color = element[1]
        icon = element[0]
    else:
        icon = element
        color = '#ffffff'

    print(icon, end=", ")
    print(fa.icons[icon])

    # Create a new image onto which the text will be added
    image = Image.new(mode='RGB', size=(72, 72), color='#000000')

    # Create an ImageDraw object onto which the font text will be placed
    draw = ImageDraw.Draw(im=image)

    # Draw the text onto our image
    draw.text(xy=(72/2, 72/2), text=fa.icons[icon], font=font, fill=color, anchor='mm')

    # Save icons in temp-folder
    path = "/tmp/" + icon + ".png"
    print(path)
    image.save(path)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Construction Icons - Font Awesome
Font Awesome is the world's most popular icon set and toolkit. We've got 19,403 icons in 68 categories across 6 styles (plus brands!),...
Read more >
Construction Icon | Font Awesome
Construction icon in the Version 5 Solid style. Make a bold statement in small sizes.. Available now in Font Awesome Pro.
Read more >
Building Icon | Font Awesome
Building icon in the Solid style. Make a bold statement in small sizes.. Available now in Font Awesome 6.
Read more >
Icon Design Guidelines | Font Awesome Docs
When making your own icons using our icon grid, you'll want to keep these shapes in mind and even recreate their sizes directly....
Read more >
Triangle person digging Icon | Font Awesome
All 19,403 icons in Font Awesome · 5 Classic styles of every icon · The Sharp Solid style of every icon · A...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found