Implement line break support when using text with text module
This commit is contained in:
@@ -78,13 +78,17 @@ class TextToDisplay(inkycal_module):
|
|||||||
with open(self.filepath, 'r') as file:
|
with open(self.filepath, 'r') as file:
|
||||||
file_content = file.read()
|
file_content = file.read()
|
||||||
|
|
||||||
fitted_content = text_wrap(file_content, font=self.font, max_width=im_width)
|
# Split content by lines if not making a request
|
||||||
|
if not self.make_request:
|
||||||
|
lines = file_content.split('\n')
|
||||||
|
else:
|
||||||
|
lines = text_wrap(file_content, font=self.font, max_width=im_width)
|
||||||
|
|
||||||
# Trim down the list to the max number of lines
|
# Trim down the list to the max number of lines
|
||||||
del fitted_content[max_lines:]
|
del lines[max_lines:]
|
||||||
|
|
||||||
# Write feeds on image
|
# Write feeds on image
|
||||||
for index, line in enumerate(fitted_content):
|
for index, line in enumerate(lines):
|
||||||
write(
|
write(
|
||||||
im_black,
|
im_black,
|
||||||
line_positions[index],
|
line_positions[index],
|
||||||
|
|||||||
Reference in New Issue
Block a user