Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Textwrapping
  • Loading branch information
Klaus Thoden committed May 29, 2018
1 parent c0cf223 commit a71281a
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions mkimage.py
Expand Up @@ -170,19 +170,34 @@ def create_cover(metadata_dict, image_directory, cover_filename):
text_draw = ImageDraw.Draw(img)

# these will eventually also become candidates for multilines
text_draw.text((centered(title_text, big_bold_font), 200), title_text, font=big_bold_font, fill=fill_colour_top)
text_draw.text((centered(subtitle_text, medium_font), 350), subtitle_text, font=medium_font, fill=fill_colour_top)
text_draw.text((centered(authors_text, small_font), int(DIMENSIONS[1]/3)-200), authors_text, font=small_font, fill=fill_colour_top)

# text_draw.text((centered(title_text, big_bold_font), 200), title_text, font=big_bold_font, fill=fill_colour_top)
title_text_lines = textwrap.wrap(title_text, width=30)
title_text_joined = "\n".join(title_text_lines)
ttcenter = centered(title_text_joined, big_bold_font)
text_draw.multiline_text((ttcenter, 200), title_text_joined, font=big_bold_font, align="center")

if len(subtitle_text) > 0:
text_draw.text((centered(subtitle_text, medium_font), 350), subtitle_text, font=medium_font, fill=fill_colour_top)

authors_text_lines = textwrap.wrap(authors_text, width=50)
authors_text_joined = "\n".join(authors_text_lines)
ttcenter = centered(authors_text_joined, small_font)
text_draw.multiline_text((ttcenter, int(DIMENSIONS[1]/3)-200), authors_text_joined, font=small_font, align="center")

# text_draw.text((centered(authors_text, small_font), int(DIMENSIONS[1]/3)-200), authors_text, font=small_font, fill=fill_colour_top)

press_text_lines = textwrap.wrap(press_text, width=40)
press_text_lines.append(series_number_text)

press_text_joined = "\n".join(press_text_lines)
ptcenter = centered(press_text_joined, small_font)

text_draw.multiline_text((ptcenter,DIMENSIONS[1]-400), press_text_joined, font=small_font, align="center")

image_on_cover = Image.open(os.path.join(image_directory, get_cover_image(image_directory)))
if image_is_file == False:
image_on_cover = Image.open(os.path.join(image_directory, get_cover_image(image_directory)))
else:
image_on_cover = Image.open(image_directory)

MAXIMUM_HEIGHT = 1200

Expand Down

0 comments on commit a71281a

Please sign in to comment.