From 8fb38ee0fd63b190148ce526575e02bc12666066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Rudowicz?= Date: Tue, 10 Sep 2024 18:27:31 +0200 Subject: [PATCH] Add ability to configure font settings --- example_config.json | 6 +++++- menu.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/example_config.json b/example_config.json index 4b11bd3..46a3e21 100644 --- a/example_config.json +++ b/example_config.json @@ -41,6 +41,10 @@ "message_text_color": "#2e3440", "btn_bg_color": "#d8dee9", "btn_hover_color": "#eceff4", - "btn_text_color": "#2e3440" + "btn_text_color": "#2e3440", + "btn_font_face": "Sans", + "btn_font_size": "20", + "message_font_face": "Sans", + "message_font_size": "40" } } diff --git a/menu.py b/menu.py index 4e853aa..4277150 100644 --- a/menu.py +++ b/menu.py @@ -45,7 +45,7 @@ class Button: self.text = text self.theme = theme self.cbk = cbk - self.font = pygame.freetype.SysFont(name="Sans", size=20) + self.font = pygame.freetype.SysFont(name=theme["btn_font_face"], size=int(theme["btn_font_size"])) text_rect = self.font.get_rect(self.text) self.text_pos = pygame.Rect((self.position.left + (self.position.width - text_rect.width)/2), (self.position.top + (self.position.height - text_rect.height)/2), @@ -104,7 +104,7 @@ class Button: class MessageBoard(IBoard): def __init__(self, screen_rect: pygame.Rect, text: str, theme: Dict): self.text = text - self.font = pygame.freetype.SysFont(name="Sans", size=30) + self.font = pygame.freetype.SysFont(name=theme["message_font_face"], size=int(theme["message_font_size"])) text_rect = self.font.get_rect(self.text) self.text_pos = pygame.Rect((screen_rect.left + (screen_rect.width - text_rect.width)/2), (screen_rect.top + (screen_rect.height - text_rect.height)/2),