Skip to content

Commit

Permalink
fixed spacing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphGL committed Apr 21, 2022
1 parent 7706280 commit 2e208af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion neosent/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
metavar='<R G B>', help='set the foreground color') # Idem
@click.option('--set-font', 'font', default="data/OpenSansEmoji.ttf",
metavar='<font_path>', help='the font used')
@click.option('--set-font-size', 'font_size', default=240, show_default=True, type=int,
@click.option('--set-font-size', 'font_size', default=210, show_default=True, type=int,
metavar='<size>', help='set the font size')
@click.option('-o', 'output_file', default='', metavar='<output_file>', help='the name of the output file')
@click.option('-v', 'verbose', is_flag=True, help='get verbose output')
Expand Down
5 changes: 3 additions & 2 deletions neosent/sheetwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def _draw_text_page(self, name: str, text: str):
page = ImageDraw.Draw(img)
# centered text

spacing = round(self.dimension[1]/720)
def wrap_text(text: str, width: int):
"""
Limits text to a maximum character size per line
Expand All @@ -93,7 +94,7 @@ def wrap_text(text: str, width: int):
count = 0
for c in text:
if count > width and c == ' ':
final_text += c + '\n'
final_text += c * spacing + '\n'
count = 0
continue
if c == '\n':
Expand All @@ -104,7 +105,7 @@ def wrap_text(text: str, width: int):

text = wrap_text(text, 22)
page.text((self.dimension[0]/2, (self.dimension[1])/2.2), text,
font=self.font, fill=self.fg_color, anchor='mm', align='left', )
font=self.font, fill=self.fg_color, anchor='mm', align='left', spacing=spacing * 12)
img.save(name)

def _draw_image_page(self, name: str, img: str):
Expand Down

0 comments on commit 2e208af

Please sign in to comment.