Interrupts are working again, new fontplate
This commit is contained in:
BIN
assets/cozette.otb
Normal file
BIN
assets/cozette.otb
Normal file
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 7.0 KiB |
42
assets/fontplate.py
Executable file
42
assets/fontplate.py
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/python
|
||||
|
||||
from fontTools.ttLib import TTFont
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
COLUMNS, ROWS = 32, 42
|
||||
CHAR_WIDTH, CHAR_HEIGHT = 6, 13
|
||||
|
||||
font_path = "assets/cozette.otb"
|
||||
canvas = Image.new("1", (COLUMNS * CHAR_WIDTH, ROWS * CHAR_HEIGHT), color=0)
|
||||
|
||||
try:
|
||||
font = ImageFont.truetype(font_path, 13)
|
||||
ttfont = TTFont(font_path)
|
||||
cmap = ttfont.getBestCmap()
|
||||
if cmap is None:
|
||||
raise Exception()
|
||||
except Exception:
|
||||
print("The font can't be loaded")
|
||||
exit()
|
||||
|
||||
ranges = [
|
||||
range(ROWS * COLUMNS),
|
||||
]
|
||||
|
||||
for range in ranges:
|
||||
for i in range:
|
||||
pos = i
|
||||
x = (pos % COLUMNS) * CHAR_WIDTH
|
||||
y = (pos // COLUMNS) * CHAR_HEIGHT
|
||||
|
||||
char_to_draw = chr(i)
|
||||
if i < 32 or i not in cmap:
|
||||
char_to_draw = chr(0xFFFD)
|
||||
|
||||
cell = Image.new("1", (CHAR_WIDTH, CHAR_HEIGHT), color=0)
|
||||
cell_draw = ImageDraw.Draw(cell)
|
||||
|
||||
cell_draw.text((0, 0), char_to_draw, font=font, fill=1)
|
||||
canvas.paste(cell, (x, y))
|
||||
|
||||
canvas.save("assets/fontplate.png")
|
||||
Reference in New Issue
Block a user