Skip to content

Commit 611c90f

Browse files
committed
Update font for linux
1 parent 212667c commit 611c90f

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

colosseum/constants.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,10 @@ def available_font_families():
335335
"""List available font family names."""
336336
if sys.platform == 'darwin':
337337
return _available_font_families_mac()
338-
return ['Arial Black'] # TODO: for tests
338+
elif sys.platform.startswith('linux'):
339+
return _available_font_families_unix()
340+
341+
return [] # TODO: for tests
339342

340343

341344
def _available_font_families_mac():
@@ -351,6 +354,14 @@ def _available_font_families_mac():
351354
return list(sorted(str(item) for item in manager.availableFontFamilies))
352355

353356

357+
def _available_font_families_unix():
358+
"""List available font family names on unix."""
359+
import subprocess
360+
p = subprocess.check_output(['fc-list', ':', 'family'])
361+
fonts = p.decode().split('\n')
362+
return list(sorted(set(fonts)))
363+
364+
354365
AVAILABLE_FONT_FAMILIES = available_font_families()
355366
FONT_FAMILY_CHOICES = Choices(
356367
validators=[is_font_family(generic_family=GENERIC_FAMILY_FONTS, font_families=AVAILABLE_FONT_FAMILIES)],

0 commit comments

Comments
 (0)