1- # text.tokenise() + text.draw () lay out word-wrapped rich text inside a rect.
2- # [tags] in the string call your glyph_renderers - here to change pen colour
1+ # screen. text() lays out word-wrapped rich text inside a rect. [tags] in the
2+ # string call glyph renderers registered with add_glyph() - here to change pen colour
33# mid-sentence and to blit an inline skull image.
44
55import math
66
77badge .mode (HIRES )
88
99skull = image .load ("/system/assets/skull.png" )
10- screen .font = rom_font .compass
10+ screen .font = font .compass
1111
1212
1313def pen_glyph_renderer (_image , parameters , measure ):
@@ -36,7 +36,7 @@ def circle_glyph_renderer(image, _parameters, measure):
3636 return None
3737
3838
39- nope = rom_font .nope
39+ nope = font .nope
4040
4141
4242glyph_renderers = {
@@ -45,6 +45,9 @@ def circle_glyph_renderer(image, _parameters, measure):
4545 "circle" : circle_glyph_renderer
4646}
4747
48+ for glyph_name , renderer in glyph_renderers .items ():
49+ add_glyph (glyph_name , renderer )
50+
4851
4952while True :
5053 i = round (badge .ticks / 200 )
@@ -59,9 +62,8 @@ def circle_glyph_renderer(image, _parameters, measure):
5962 y = 5
6063 width = math .sin (badge .ticks / 500 ) * 50 + 200
6164 height = 220
62- tokens = text .tokenise (screen , message , glyph_renderers )
6365 bounds = rect (x , y , width , height )
64- text . draw ( screen , tokens , bounds , line_spacing = 1 , word_spacing = 1.05 )
66+ screen . text ( message , bounds , line_height = 1 , word_spacing = 1.05 )
6567
6668 screen .pen = color .rgb (60 , 80 , 100 , 100 )
6769 screen .line (bounds .x , bounds .y , bounds .x + bounds .w , bounds .y )
0 commit comments