Skip to content

Commit 30170b1

Browse files
committed
Add latin3_terminus_14_bold.py (as marimo notebook/script)
1 parent 2de50a9 commit 30170b1

File tree

3 files changed

+620
-0
lines changed

3 files changed

+620
-0
lines changed

latin3_terminus_14_bold.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import marimo
2+
3+
__generated_with = "0.18.0"
4+
app = marimo.App()
5+
6+
with app.setup:
7+
from pathlib import Path
8+
from PIL import Image
9+
import marimo as mo
10+
11+
from df_font_generator.font_generator import FontGenerator
12+
13+
14+
@app.function
15+
def get_latin3_font() -> Image.Image:
16+
fg = FontGenerator()
17+
fg.set_font(Path("./fonts/terminus_bold.ttf"), 14)
18+
fg.set_charset(encoding="latin3")
19+
20+
# clear all canvas mode
21+
fg.clear_canvas()
22+
fg.set_padding(0, -1)
23+
fg.draw_full_charset()
24+
25+
# Patch needed, cause some chars out of they boxes
26+
# Terminus 14 patch
27+
fg.set_padding(0, 0)
28+
fg.set_position(0, 15)
29+
fg.draw_char("≡")
30+
fg.set_position(5, 1)
31+
fg.draw_char("§")
32+
fg.set_position(5, 15)
33+
fg.draw_char("§")
34+
fg.set_position(14, 5)
35+
fg.draw_char("^")
36+
fg.set_position(14, 7)
37+
fg.draw_char("~")
38+
39+
fg.set_padding(0, 1)
40+
fg.set_position(0, 6)
41+
fg.draw_char("`")
42+
43+
fg.redraw_characters("°²³ĥÀÁÂÄĊĈÈÉÊËÌÍÎÏÑÒÓÔĠÖĜÙÚÛÜŬŜ")
44+
return fg.image
45+
46+
47+
@app.cell
48+
def _():
49+
image = get_latin3_font()
50+
return (image,)
51+
52+
53+
@app.cell
54+
def _(image):
55+
file = "latin3.png"
56+
image.save(file)
57+
print(f"File {file} written")
58+
return
59+
60+
61+
@app.cell
62+
def _(image):
63+
# Show resulting image (scaled x2 to see details)
64+
img = None
65+
if mo.running_in_notebook():
66+
scale = 2
67+
width = image.width * scale
68+
height = image.height * scale
69+
img = image.resize((width, height), Image.Resampling.NEAREST)
70+
71+
img
72+
return
73+
74+
75+
@app.cell
76+
def _():
77+
return
78+
79+
80+
if __name__ == "__main__":
81+
app.run()

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ readme = "README.md"
1111
dependencies = [
1212
"pillow>=11.3.0,<12",
1313
"alternative-encodings>=0.3.1,<0.4",
14+
"marimo>=0.18.0",
1415
]
1516

1617
[dependency-groups]

0 commit comments

Comments
 (0)