Skip to content
Snippets Groups Projects
Verified Commit f5b8244d authored by dos's avatar dos
Browse files

fil3s: Draw each line of text in Reader separately

parent 47d92085
No related branches found
No related tags found
No related merge requests found
...@@ -174,8 +174,16 @@ class Reader(ActionView): ...@@ -174,8 +174,16 @@ class Reader(ActionView):
ctx.font_size = 32 ctx.font_size = 32
else: else:
ctx.font_size = 16 ctx.font_size = 16
ctx.move_to(self.viewport_offset[0], self.viewport_offset[1])
ctx.text(f"{self.content}") line_height = ctx.font_size
for i, line in enumerate(self.content):
x, y = self.viewport_offset[0], self.viewport_offset[1] + i * line_height
if y > 120 + line_height or y < -120 - line_height:
continue
ctx.move_to(x, y)
ctx.text(line)
ctx.restore() ctx.restore()
def _draw_media(self, ctx: Context) -> None: def _draw_media(self, ctx: Context) -> None:
...@@ -195,7 +203,7 @@ class Reader(ActionView): ...@@ -195,7 +203,7 @@ class Reader(ActionView):
def _read_file(self) -> None: def _read_file(self) -> None:
try: try:
with open(self.path, "r", encoding="utf-8") as f: with open(self.path, "r", encoding="utf-8") as f:
self.content = f.read() self.content = f.readlines()
except: except:
self.has_error = True self.has_error = True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment