28 lines
610 B
Python
Executable File
28 lines
610 B
Python
Executable File
#!/usr/bin/env python3
|
|
import imageio
|
|
import math
|
|
|
|
asci = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
|
|
font = "font.png"
|
|
|
|
im = imageio.imread(font)
|
|
|
|
for c in asci:
|
|
|
|
base_x = (ord(c) % 16) * 16
|
|
base_y = math.floor(ord(c)/16) * 16
|
|
|
|
n = 0
|
|
for y in range(16):
|
|
n = n << 16
|
|
k = 0
|
|
for x in range(16):
|
|
d = im[base_y + y][base_x + x][0]
|
|
k = k << 1
|
|
if d == 255:
|
|
k = k + 1
|
|
|
|
n = n + k
|
|
|
|
print("assign char_data[{:2}] = 256'h{:064x}; // {}".format(ord(c)-32, n, c))
|