Skip to content

Commit

Permalink
Add allow_sfnt and allow_web_font filters to get_fonts_in_path method (
Browse files Browse the repository at this point in the history
  • Loading branch information
ftCLI authored Aug 10, 2023
1 parent ce030f6 commit a7a8e84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions foundryToolsCLI/Lib/Font.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ def is_woff2(self) -> bool:
"""
return self.flavor == "woff2"

@property
def is_web_font(self) -> bool:
"""
This function checks if the font is in WOFF/WOFF2 format.
:return: A boolean value indicating whether the "flavor" attribute of the object is None or not.
If it is None, the function will return False, otherwise it will return True.
"""
return self.flavor is not None

@property
def is_sfnt(self) -> bool:
"""
Expand Down
6 changes: 6 additions & 0 deletions foundryToolsCLI/Lib/utils/cli_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def get_fonts_in_path(
allow_cff=True,
allow_static=True,
allow_variable=True,
allow_web_font=True,
allow_sfnt=True,
) -> list[Font]:
files = []
if input_path.is_file():
Expand All @@ -55,6 +57,10 @@ def get_fonts_in_path(
continue
if not allow_variable and font.is_variable:
continue
if not allow_sfnt and font.is_sfnt:
continue
if not allow_web_font and font.is_web_font:
continue

fonts.append(font)

Expand Down

0 comments on commit a7a8e84

Please sign in to comment.