We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8f33b80 commit ef6c6eaCopy full SHA for ef6c6ea
1 file changed
ev3dev/fonts/__init__.py
@@ -19,6 +19,10 @@ def load(name):
19
`PIL.ImageFont <http://pillow.readthedocs.io/en/latest/reference/ImageFont.html>`_
20
class.
21
"""
22
- pil_file = pkg_resources.resource_filename('ev3dev.fonts', '{}.pil'.format(name))
23
- pbm_file = pkg_resources.resource_filename('ev3dev.fonts', '{}.pbm'.format(name))
24
- return ImageFont.load(pil_file)
+ try:
+ pil_file = pkg_resources.resource_filename('ev3dev.fonts', '{}.pil'.format(name))
+ pbm_file = pkg_resources.resource_filename('ev3dev.fonts', '{}.pbm'.format(name))
25
+ return ImageFont.load(pil_file)
26
+ except FileNotFoundError:
27
+ raise Exception('Failed to load font "{}". '.format(name) +
28
+ 'Check ev3dev.fonts.available() for the list of available fonts')
0 commit comments