mirror of
https://github.com/esphome/esphome.git
synced 2024-12-18 19:44:53 +01:00
[font] cleanly handle font file format exception (Bugfix) (#7970)
This commit is contained in:
parent
6dcbd1a8ae
commit
e890486043
1 changed files with 5 additions and 2 deletions
|
@ -51,8 +51,11 @@ CONF_IGNORE_MISSING_GLYPHS = "ignore_missing_glyphs"
|
||||||
# Cache loaded freetype fonts
|
# Cache loaded freetype fonts
|
||||||
class FontCache(dict):
|
class FontCache(dict):
|
||||||
def __missing__(self, key):
|
def __missing__(self, key):
|
||||||
|
try:
|
||||||
res = self[key] = freetype.Face(key)
|
res = self[key] = freetype.Face(key)
|
||||||
return res
|
return res
|
||||||
|
except freetype.FT_Exception as e:
|
||||||
|
raise cv.Invalid(f"Could not load Font file {key}: {e}") from e
|
||||||
|
|
||||||
|
|
||||||
FONT_CACHE = FontCache()
|
FONT_CACHE = FontCache()
|
||||||
|
|
Loading…
Reference in a new issue