aalh

font_scaling

Nov 12th, 2025
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.38 KB | None | 0 0
  1. # Load the fonts
  2. print(gc.mem_free()," free")
  3. print("loading fonts")
  4. time_font = bitmap_font.load_font('/fonts/Asimov-104.pcf')
  5. time_font.load_glyphs(b'0123456789:%')  # pre-load glyphs for fast printing  # type: ignore
  6.  
  7. speed_font = bitmap_font.load_font('/fonts/AsimovNar-45.pcf')
  8. speed_font.load_glyphs(b'0123456789mph.:%')  # type: ignore
  9.  
  10. title_font = bitmap_font.load_font('/fonts/Asimov-25.pcf')
  11. title_font.load_glyphs(b'123456789INSIDEOUTFft.%')  # type: ignore
  12.  
  13. # temperature_font = bitmap_font.load_font('/fonts/AsimovNar-40.pcf')
  14. # temperature_font.load_glyphs(b'0123456789INSIDEOUTFft.%')  # type: ignore
  15.  
  16. print("fonts loaded")
  17.  
  18. def create_text_areas(configs):
  19.     """Given a list of area specifications, create and return text areas."""
  20.     print("creating text areas")
  21.     text_areas = []
  22.     for cfg in configs:
  23.         textarea = Label(cfg['font'], text=' '*cfg['size'])
  24.         textarea.x = cfg['x']
  25.         textarea.y = cfg['y']
  26.         textarea.color = cfg['color']
  27.         text_areas.append(textarea)
  28.     return text_areas
  29.  
  30.  
  31.  
  32. class Time_State(State):
  33.     """This state manages the primary time display screen/mode"""
  34.  
  35.     def __init__(self):
  36.         super().__init__()
  37.         self.background_day = None
  38.         self.background_night = 'main_background_nightl.bmp'
  39.         self.refresh_time = None
  40.         self.update_time = None
  41.         self.weather_refresh = None
  42.         text_area_configs = [dict(x=160, y=235, size=5, color=0xFFFFFF, font=time_font),  # TIME
  43.                              dict(x=325, y=100, size=5, color=0xE09941, font=speed_font),  # SPEED
  44.                              dict(x=120, y=10, size=16, color=0xCFFC03, font=title_font),  # screen heading
  45.                              dict(x=125, y=48, size=4, color=0xFFFFFF, font=title_font),  # INSIDE temp
  46.                              dict(x=125, y=93, size=10, color=0x4F0066, font=title_font),  # INSIDE humid
  47.                              dict(x=215, y=48, size=4, color=0xFFFFFF, font=title_font),  # OUTSIDE temp
  48.                              dict(x=215, y=93, size=4, color=0x4F0066, font=title_font),  # OUTSIDE humid
  49.                              dict(x=145, y=170, size=1, color=0x32A89E, font=speed_font),  # Altitude
  50.                              dict(x=310, y=180, size=5, color=0xCFFC03, font=title_font)]  # Air Quality
  51.         self.text_areas = create_text_areas(text_area_configs)
  52.  
Advertisement
Add Comment
Please, Sign In to add comment