[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
This commit is contained in:
Philipp Klaus 2020-01-30 14:19:21 +01:00
parent 8ddbe95505
commit b1783cfa4a

View File

@ -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(',')