Created tool
This commit is contained in:
commit
9df4f752f1
27
convert-font.py
Executable file
27
convert-font.py
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/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))
|
Loading…
Reference in New Issue
Block a user