diff --git a/src/calendar_manager.py b/src/calendar_manager.py index cf13db00..838c0161 100644 --- a/src/calendar_manager.py +++ b/src/calendar_manager.py @@ -139,11 +139,8 @@ class CalendarManager: # Draw summary lines y_pos = 12 # Start position for summary (below date/time) for line in title_lines: - # Use direct drawing with calendar font for summary - bbox = self.display_manager.draw.textbbox((0, 0), line, font=summary_font) - text_width = bbox[2] - bbox[0] - x = (self.display_manager.matrix.width - text_width) // 2 - self.display_manager.draw.text((x, y_pos), line, font=summary_font, fill=self.text_color) + # Use draw_text with custom font for summary + self.display_manager.draw_text(line, y=y_pos, color=self.text_color, font=summary_font) y_pos += 8 # Move down for next line return True diff --git a/src/display_manager.py b/src/display_manager.py index e9491bec..610e59fd 100644 --- a/src/display_manager.py +++ b/src/display_manager.py @@ -185,9 +185,10 @@ class DisplayManager: if not hasattr(self, 'extra_small_font'): self.extra_small_font = self.regular_font - def draw_text(self, text: str, x: int = None, y: int = None, color: Tuple[int, int, int] = (255, 255, 255), small_font: bool = False) -> None: + def draw_text(self, text: str, x: int = None, y: int = None, color: Tuple[int, int, int] = (255, 255, 255), small_font: bool = False, font: ImageFont = None) -> None: """Draw text on the display with improved clarity.""" - font = self.small_font if small_font else self.regular_font + # Use provided font if specified, otherwise use small_font or regular_font + font = font if font else (self.small_font if small_font else self.regular_font) # Get text dimensions including ascenders and descenders bbox = self.draw.textbbox((0, 0), text, font=font) @@ -210,7 +211,7 @@ class DisplayManager: y = min(y, max_y) y = max(y, padding) # Ensure text doesn't get cut off at top - # Press Start 2P is pixel-perfect, so we can draw directly without any adjustments + # Draw the text self.draw.text((x, y), text, font=font, fill=color) def draw_sun(self, x: int, y: int, size: int = 16):