31 lines
717 B
Python
Executable File
31 lines
717 B
Python
Executable File
#!/usr/bin/env python3
|
|
import imageio
|
|
import math
|
|
|
|
asci = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
|
|
font = "font.png"
|
|
|
|
im = imageio.imread(font)
|
|
|
|
for i in range(256):
|
|
|
|
base_x = (i % 16) * 16
|
|
base_y = math.floor(i/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
|
|
|
|
if i >= 0x20 and i < 0x7F:
|
|
print("assign char_data[{:3}] = 256'h{:064x}; // {}".format(i, n, chr(i)))
|
|
else:
|
|
print("assign char_data[{:3}] = 256'h{:064x};".format(i, n))
|