44class ShowFonts (Activity ):
55 def onCreate (self ):
66 screen = lv .obj ()
7- #cont.set_size(320, 240)
8- #cont.set_scrollbar_mode(lv.SCROLLBAR_MODE.AUTO)
9- #cont.set_scroll_dir(lv.DIR.VER)
107
118 # Make the screen focusable so it can be scrolled with the arrow keys
129 focusgroup = lv .group_get_default ()
1310 if focusgroup :
1411 focusgroup .add_obj (screen )
1512
13+ self .addAllFonts (screen )
14+ #self.addAllGlyphs(screen)
15+ self .setContentView (screen )
16+
17+ def addAllFonts (self , screen ):
18+ fonts = [
19+ (lv .font_montserrat_10 , "Montserrat 10" ),
20+ (lv .font_unscii_8 , "Unscii 8" ),
21+ (lv .font_montserrat_16 , "Montserrat 16" ), # +6
22+ (lv .font_montserrat_22 , "Montserrat 22" ), # +6
23+ (lv .font_unscii_16 , "Unscii 16" ),
24+ (lv .font_montserrat_30 , "Montserrat 30" ), # +8
25+ (lv .font_montserrat_38 , "Montserrat 38" ), # +8
26+ (lv .font_montserrat_48 , "Montserrat 48" ), # +10
27+ (lv .font_dejavu_16_persian_hebrew , "DejaVu 16 Persian/Hebrew" ),
28+ ]
29+
30+ dsc = lv .font_glyph_dsc_t ()
31+
32+ y = 0
33+ for font , name in fonts :
34+ x = 0
35+ title = lv .label (screen )
36+ title .set_text (name + ":" )
37+ title .set_style_text_font (lv .font_montserrat_16 , 0 )
38+ title .set_pos (x , y )
39+ y += title .get_height () + 20
40+
41+ line_height = font .get_line_height () + 4
42+
43+ for cp in range (0x20 , 0xFF ):
44+ if font .get_glyph_dsc (font , dsc , cp , cp + 1 ):
45+ lbl = lv .label (screen )
46+ lbl .set_style_text_font (font , 0 )
47+ lbl .set_text (chr (cp ))
48+ lbl .set_pos (x , y )
49+
50+ width = font .get_glyph_width (cp , cp + 1 )
51+ x += width
52+ if x + width * 2 > screen .get_width ():
53+ x = 0
54+ y += line_height
55+
56+ y += line_height * 2
57+
58+ screen .set_height (y + 20 )
59+
60+
61+
62+ def addAllGlyphs (self , screen ):
1663 fonts = [
1764 (lv .font_montserrat_16 , "Montserrat 16" ),
1865 (lv .font_unscii_16 , "Unscii 16" ),
@@ -21,7 +68,7 @@ def onCreate(self):
2168 ]
2269
2370 dsc = lv .font_glyph_dsc_t ()
24- y = 4
71+ y = 40
2572
2673 for font , name in fonts :
2774 title = lv .label (screen )
@@ -48,4 +95,3 @@ def onCreate(self):
4895 y += line_height
4996
5097 screen .set_height (y + 20 )
51- self .setContentView (screen )
0 commit comments