Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import defaultdict
- from PIL import (
- Image,
- ImageDraw,
- ImageFont
- )
- img = Image.new('1', (8, 16))
- font = ImageFont.truetype('arial.ttf', 10)
- draw = ImageDraw.Draw(img)
- forward_lut = {}
- reverse_lut = defaultdict(list)
- for i in range(32, 0xFFFF):
- c = chr(i)
- draw.rectangle((0, 0, 8, 16), fill=(255, ))
- draw.text((0, 0), c, font=font, fill=(0, ))
- pixels = map(lambda x: str(x & 1), img.getdata())
- footprint = int(''.join(pixels), 2)
- reverse_lut[footprint].append(c)
- forward_lut[c] = footprint
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement