mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-21 08:29:59 +00:00
Control Board: Use Pillow 10 API for getting text size
This commit is contained in:
parent
cd5666ae14
commit
256650908b
@ -30,7 +30,7 @@ class MenuRenderer(ABC):
|
|||||||
self.draw = ImageDraw.Draw(self.image)
|
self.draw = ImageDraw.Draw(self.image)
|
||||||
self.font = ImageFont.truetype(config.font_path, size=config.font_size)
|
self.font = ImageFont.truetype(config.font_path, size=config.font_size)
|
||||||
# just a sample text to work with the font height
|
# just a sample text to work with the font height
|
||||||
_, self.font_height = self.font.getsize("ABCabc")
|
self.font_height = self.font.getbbox("ABCabc")[3]
|
||||||
self.cursor_position = 0
|
self.cursor_position = 0
|
||||||
self.frame_start_row = 0
|
self.frame_start_row = 0
|
||||||
self.render_timestamp = None
|
self.render_timestamp = None
|
||||||
@ -153,7 +153,8 @@ class MenuRenderer(ABC):
|
|||||||
|
|
||||||
def draw_fullsceen_message(self, text: str):
|
def draw_fullsceen_message(self, text: str):
|
||||||
"""Draws a fullscreen message, i.e., a full-screen message."""
|
"""Draws a fullscreen message, i.e., a full-screen message."""
|
||||||
font_width, font_height = self.font.getsize(text)
|
font_width = self.font.getlength(text)
|
||||||
|
font_height = self.font.getbbox(text)[3]
|
||||||
centered_width = (self.disp.width - font_width) / 2
|
centered_width = (self.disp.width - font_width) / 2
|
||||||
centered_height = (self.disp.height - font_height) / 2
|
centered_height = (self.disp.height - font_height) / 2
|
||||||
|
|
||||||
@ -171,7 +172,7 @@ class MenuRenderer(ABC):
|
|||||||
def draw_mini_message(self, text: str):
|
def draw_mini_message(self, text: str):
|
||||||
"""Draws a fullscreen message, i.e., a message covering only the center portion of
|
"""Draws a fullscreen message, i.e., a message covering only the center portion of
|
||||||
the screen. The remaining areas stay visible."""
|
the screen. The remaining areas stay visible."""
|
||||||
font_width, _ = self.font.getsize(text)
|
font_width = self.font.getlength(text)
|
||||||
centered_width = (self.disp.width - font_width) / 2
|
centered_width = (self.disp.width - font_width) / 2
|
||||||
centered_height = (self.disp.height - self.font_height) / 2
|
centered_height = (self.disp.height - self.font_height) / 2
|
||||||
|
|
||||||
@ -270,7 +271,7 @@ class MenuRenderer(ABC):
|
|||||||
|
|
||||||
def setup_horizontal_scrolling(self, text):
|
def setup_horizontal_scrolling(self, text):
|
||||||
"""Configure horizontal scrolling based on the configured screen dimensions."""
|
"""Configure horizontal scrolling based on the configured screen dimensions."""
|
||||||
font_width, _ = self.font.getsize(text)
|
font_width = self.font.getlength(text)
|
||||||
self._current_line_horizontal_overlap = font_width - self.disp.width
|
self._current_line_horizontal_overlap = font_width - self.disp.width
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user