Skip to content

Commit

Permalink
Fix bug when falling back to default font
Browse files Browse the repository at this point in the history
  • Loading branch information
rrwick committed Oct 28, 2021
1 parent 5e9dce6 commit e935f66
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion trycycler/dotplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def get_font(draw, label, font_size, start_position, end_position):
# If we had to resort to the default font, then we can't size it.
if is_default_font:
text_width, text_height = draw.textsize(label, font=font)
return font, text_width, text_height
return font, text_width, text_height, font_size

# If we have a size-able font, then we adjust the size down until the text fits in the
# available space.
Expand All @@ -259,6 +259,13 @@ def get_font(draw, label, font_size, start_position, end_position):


def load_font(font_size):
"""
This function loads a font, but it has to try a few different ones because different platforms
have different fonts:
* DejaVuSans.ttf: is in Ubuntu 20.04 and CentOS 7
* OpenSans-Regular.ttf: is in CentOS 7
* Arial.ttf: is in MacOS 11
"""
try:
return ImageFont.truetype('DejaVuSans.ttf', font_size), False
except OSError:
Expand Down

0 comments on commit e935f66

Please sign in to comment.