File tree Expand file tree Collapse file tree 3 files changed +620
-0
lines changed
Expand file tree Collapse file tree 3 files changed +620
-0
lines changed Original file line number Diff line number Diff line change 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 ()
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ readme = "README.md"
1111dependencies = [
1212 " pillow>=11.3.0,<12" ,
1313 " alternative-encodings>=0.3.1,<0.4" ,
14+ " marimo>=0.18.0" ,
1415]
1516
1617[dependency-groups ]
You can’t perform that action at this time.
0 commit comments