From f17018b35603cf0ed766357552e9c49accd687c7 Mon Sep 17 00:00:00 2001 From: Ryan Wick Date: Fri, 29 Oct 2021 10:31:38 +1100 Subject: [PATCH] Add more fonts to try --- trycycler/dotplot.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/trycycler/dotplot.py b/trycycler/dotplot.py index 804584c..7390bf7 100644 --- a/trycycler/dotplot.py +++ b/trycycler/dotplot.py @@ -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 @@ -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