Skip to content

Commit

Permalink
[font_collection] Don't ignore the reload_system_font flags
Browse files Browse the repository at this point in the history
Since __system_fonts is a private attribute, hasattr(self, '__system_fonts') doesn't actually check if the fontcollection has the __system_fonts attribute.

It would work if it would be hasattr(self, '_FontCollection__system_fonts'), but that's a bit hacky, so let's declare self.__system_fonts in the __init__
  • Loading branch information
moi15moi committed Aug 15, 2024
1 parent 4bdba46 commit ba5db99
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion font_collector/font/font_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(
self.reload_system_font = reload_system_font
self.use_generated_fonts = use_generated_fonts
self.additional_fonts = additional_fonts
self.__system_fonts: Optional[List[FontFile]] = None


def __iter__(self) -> Generator[FontFile, None, None]:
Expand All @@ -56,7 +57,7 @@ def system_fonts(self) -> List[FontFile]:
if self.reload_system_font:
return FontLoader.load_system_fonts()

if not hasattr(self, '__system_fonts'):
if self.__system_fonts is None:
self.__system_fonts = FontLoader.load_system_fonts()
return self.__system_fonts
return []
Expand Down

0 comments on commit ba5db99

Please sign in to comment.