diff --git a/src/font_test_manager.py b/src/font_test_manager.py index 7ebfa344..d105ab39 100644 --- a/src/font_test_manager.py +++ b/src/font_test_manager.py @@ -10,13 +10,12 @@ logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) class FontTestManager: - """Manager for testing different font sizes of tom-thumb font.""" + """Manager for testing tom-thumb font.""" def __init__(self, config: Dict[str, Any], display_manager: DisplayManager): self.display_manager = display_manager self.config = config self.font_path = "assets/fonts/tom-thumb.bdf" - self.font_sizes = [4, 5, 6, 7, 8, 9] # Adjusted sizes for BDF font self.logger = logging.getLogger('FontTest') # Verify font exists @@ -24,14 +23,14 @@ class FontTestManager: self.logger.error(f"Font file not found: {self.font_path}") raise FileNotFoundError(f"Font file not found: {self.font_path}") - self.logger.info(f"Initialized FontTestManager with {len(self.font_sizes)} font sizes to test using tom-thumb font") + self.logger.info("Initialized FontTestManager with tom-thumb font") def update(self): """No update needed for static display.""" pass def display(self, force_clear: bool = False): - """Display all font sizes at once across the screen.""" + """Display the font with sample text.""" try: # Clear the display self.display_manager.clear() @@ -40,41 +39,33 @@ class FontTestManager: width = self.display_manager.matrix.width height = self.display_manager.matrix.height - # Calculate spacing between font sizes - total_sizes = len(self.font_sizes) - spacing = width // (total_sizes + 1) # Add 1 to account for edges + # Load the BDF font + font = ImageFont.load(self.font_path) # Draw font name at the top self.display_manager.draw_text("tom-thumb", y=2, color=(255, 255, 255)) - # Draw each font size + # Draw sample text draw = ImageDraw.Draw(self.display_manager.image) + sample_text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - for i, size in enumerate(self.font_sizes): - # Load the BDF font - font = ImageFont.load(self.font_path) - - # Create text to display (the size number) - text = str(size) - - # Get text dimensions - bbox = draw.textbbox((0, 0), text, font=font) - text_width = bbox[2] - bbox[0] - text_height = bbox[3] - bbox[1] - - # Calculate position to center the text horizontally - x = spacing * (i + 1) - (text_width // 2) - # Position vertically in the middle of the screen - y = (height - text_height) // 2 - - # Draw the text - draw.text((x, y), text, font=font, fill=(255, 255, 255)) + # Get text dimensions + bbox = draw.textbbox((0, 0), sample_text, font=font) + text_width = bbox[2] - bbox[0] + text_height = bbox[3] - bbox[1] + + # Calculate position to center the text + x = (width - text_width) // 2 + y = (height - text_height) // 2 + + # Draw the text + draw.text((x, y), sample_text, font=font, fill=(255, 255, 255)) # Update the display once self.display_manager.update_display() # Log that display is complete - self.logger.info("Font size test display complete. All sizes shown at once.") + self.logger.info("Font test display complete.") except Exception as e: self.logger.error(f"Error displaying font test: {e}", exc_info=True) \ No newline at end of file