mirror of https://github.com/chubin/wttr.in
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.3 KiB
63 lines
1.3 KiB
5 years ago
|
#!/usr/bin/env python
|
||
|
#vim: fileencoding=utf-8
|
||
|
|
||
|
"""
|
||
|
|
||
|
At the moment, Pillow library does not support colorful emojis,
|
||
|
that is why emojis must be extracted to external files first,
|
||
|
and then they must be handled as usual graphical objects
|
||
|
and not as text.
|
||
|
|
||
|
The files are extracted using Imagemagick.
|
||
|
|
||
|
Usage:
|
||
|
|
||
|
ve/bi/python lib/extract_emoji.py
|
||
|
"""
|
||
|
|
||
|
import subprocess
|
||
|
|
||
|
EMOJIS = [
|
||
|
"✨",
|
||
|
"☁️",
|
||
|
"🌫",
|
||
|
"🌧",
|
||
|
"🌧",
|
||
|
"❄️",
|
||
|
"❄️",
|
||
|
"🌦",
|
||
|
"🌦",
|
||
|
"🌧",
|
||
|
"🌧",
|
||
|
"🌨",
|
||
|
"🌨",
|
||
|
"⛅️",
|
||
|
"☀️",
|
||
|
"🌩",
|
||
|
"⛈",
|
||
|
"⛈",
|
||
|
"☁️",
|
||
|
"🌑", "🌒", "🌓", "🌔", "🌕", "🌖", "🌗", "🌘"
|
||
|
]
|
||
|
|
||
|
def extract_emojis_to_directory(dirname):
|
||
|
"""
|
||
|
Extract emoji from an emoji font, to separate files.
|
||
|
"""
|
||
|
|
||
|
emoji_font = "Noto Color Emoji"
|
||
|
emoji_size = 30
|
||
|
|
||
|
for emoji in EMOJIS:
|
||
|
filename = "%s/%s.png" % (dirname, emoji)
|
||
|
convert_string = [
|
||
|
"convert", "-background", "black", "-size", "%sx%s" % (emoji_size, emoji_size),
|
||
|
"-set", "colorspace", "sRGB",
|
||
|
"pango:<span font=\"%s\" size=\"20000\">%s</span>" % (emoji_font, emoji),
|
||
|
filename
|
||
|
]
|
||
|
subprocess.Popen(convert_string)
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
extract_emojis_to_directory("share/emoji")
|