aboutsummaryrefslogtreecommitdiff
path: root/generate-emoji-sprite.py
blob: b0e9dc30848d4b483077cb87c03dfa0934dec2b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3

import requests
from subprocess import Popen, PIPE

def create_image_with_text(text, image_filepath):
    process = Popen(["convert", "-size", "1024x", "-background", "#ff00ff", "-strip", "pango:" + text, image_filepath])
    _, _ = process.communicate()

resp = requests.get("https://unicode.org/Public/emoji/13.1/emoji-test.txt")
resp.raise_for_status()
emoji_sequences = resp.text

ss = []
emoji_characters = []
for line in emoji_sequences.splitlines():
    if len(line) == 0 or line[0] == '#':
        continue

    columns = line.split(";")
    sequences = columns[0].strip().split()
    text = [chr(int(c, 16)) for c in sequences]
    emoji_characters.extend(text)
    ss.append(int(sequences[0], 16))
    #print(str(sequences))

#print(str(len(emoji_characters)))
create_image_with_text("".join(emoji_characters), "emoji.jpg")

sow = list(set(ss))
sow.sort()
for i in range(len(sow) - 1):
    s1 = sow[i]
    s2 = sow[i + 1]
    print(str(s2-s1))