From b1783cfa4ab1353c2d77a3e1432629ae92d018b9 Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Thu, 30 Jan 2020 14:19:21 +0100 Subject: [PATCH] [buf fix] Skip fonts that are not properly reported by fc-list Thanks @jmcwhirter and @ukmattbrock for reporting the issue fixes #24, closes #24, closes #18 --- font_helpers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/font_helpers.py b/font_helpers.py index 9c29c94..beb4567 100755 --- a/font_helpers.py +++ b/font_helpers.py @@ -20,6 +20,10 @@ def get_fonts(folder=None): if not line: continue if 'otf' not in line and 'ttf' not in line: continue parts = line.split(':') + if 'style=' not in line or len(parts) < 3: + # fc-list didn't output all desired properties + logger.warn('skipping invalid font %s', line) + continue path = parts[0] families = parts[1].strip().split(',') styles = parts[2].split('=')[1].split(',')