Skip to content

Commit

Permalink
Add more fonts to try
Browse files Browse the repository at this point in the history
  • Loading branch information
rrwick committed Oct 28, 2021
1 parent e935f66 commit f17018b
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions trycycler/dotplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,7 @@ 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
have different fonts.
"""
try:
return ImageFont.truetype('DejaVuSans.ttf', font_size), False
Expand All @@ -278,4 +275,24 @@ def load_font(font_size):
return ImageFont.truetype('Arial.ttf', font_size), False
except OSError:
pass
try:
return ImageFont.truetype('LiberationSans-Regular.ttf', font_size), False
except OSError:
pass
try:
return ImageFont.truetype('NimbusSans-Regular.otf', font_size), False
except OSError:
pass
try:
return ImageFont.truetype('Verdana.ttf', font_size), False
except OSError:
pass
try:
return ImageFont.truetype('Lato-Regular.ttf', font_size), False
except OSError:
pass
try:
return ImageFont.truetype('FreeSans.ttf', font_size), False
except OSError:
pass
return ImageFont.load_default(), True

0 comments on commit f17018b

Please sign in to comment.