Skip to content

Commit

Permalink
Update font for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed Jan 3, 2020
1 parent 212667c commit 611c90f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion colosseum/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ def available_font_families():
"""List available font family names."""
if sys.platform == 'darwin':
return _available_font_families_mac()
return ['Arial Black'] # TODO: for tests
elif sys.platform.startswith('linux'):
return _available_font_families_unix()

return [] # TODO: for tests


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


def _available_font_families_unix():
"""List available font family names on unix."""
import subprocess
p = subprocess.check_output(['fc-list', ':', 'family'])
fonts = p.decode().split('\n')
return list(sorted(set(fonts)))


AVAILABLE_FONT_FAMILIES = available_font_families()
FONT_FAMILY_CHOICES = Choices(
validators=[is_font_family(generic_family=GENERIC_FAMILY_FONTS, font_families=AVAILABLE_FONT_FAMILIES)],
Expand Down

0 comments on commit 611c90f

Please sign in to comment.