mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
text formatting
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,7 @@ class OfTheDayManager:
|
||||
|
||||
# Load fonts using freetype
|
||||
font_dir = os.path.join(os.path.dirname(__file__), '..', 'assets', 'fonts')
|
||||
self.title_font = freetype.Face(os.path.join(font_dir, '5x7.bdf'))
|
||||
self.title_font = freetype.Face(os.path.join(font_dir, 'ic8x8u.bdf'))
|
||||
self.body_font = freetype.Face(os.path.join(font_dir, '5x7.bdf'))
|
||||
|
||||
# Load categories and their data
|
||||
@@ -229,13 +229,13 @@ class OfTheDayManager:
|
||||
wrapped = self._wrap_text(subtitle, available_width, body_font, max_lines=3, line_height=body_height, max_height=available_height)
|
||||
for i, line in enumerate(wrapped):
|
||||
if line.strip(): # Only draw non-empty lines
|
||||
self._draw_bdf_text(draw, body_font, line, 1, y_start + i * (body_height + 1), color=self.subtitle_color)
|
||||
self._draw_bdf_text(draw, body_font, line, 1, y_start + i * body_height, color=self.subtitle_color)
|
||||
elif self.rotation_state == 1 and description:
|
||||
# Show description
|
||||
wrapped = self._wrap_text(description, available_width, body_font, max_lines=3, line_height=body_height, max_height=available_height)
|
||||
for i, line in enumerate(wrapped):
|
||||
if line.strip(): # Only draw non-empty lines
|
||||
self._draw_bdf_text(draw, body_font, line, 1, y_start + i * (body_height + 1), color=self.subtitle_color)
|
||||
self._draw_bdf_text(draw, body_font, line, 1, y_start + i * body_height, color=self.subtitle_color)
|
||||
# else: nothing to show
|
||||
return True
|
||||
except Exception as e:
|
||||
@@ -276,9 +276,9 @@ class OfTheDayManager:
|
||||
if not truncated:
|
||||
lines.append(word[:10] + "...")
|
||||
# Check if we've filled all lines (accounting for line spacing)
|
||||
if len(lines) * (line_height + 1) >= max_height or len(lines) >= max_lines:
|
||||
if len(lines) * line_height >= max_height or len(lines) >= max_lines:
|
||||
break
|
||||
if current_line and (len(lines) * (line_height + 1) < max_height and len(lines) < max_lines):
|
||||
if current_line and (len(lines) * line_height < max_height and len(lines) < max_lines):
|
||||
lines.append(' '.join(current_line))
|
||||
while len(lines) < max_lines:
|
||||
lines.append("")
|
||||
|
||||
Reference in New Issue
Block a user