diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 0e218d7..007fc42 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.1.17 +current_version = 1.1.18 commit = True tag = True diff --git a/foundryToolsCLI/Lib/Font.py b/foundryToolsCLI/Lib/Font.py index acb8f3f..b4f3e03 100644 --- a/foundryToolsCLI/Lib/Font.py +++ b/foundryToolsCLI/Lib/Font.py @@ -9,6 +9,7 @@ from fontTools.misc.psCharStrings import T2CharString from fontTools.misc.timeTools import timestampToString from fontTools.pens.statisticsPen import StatisticsPen +from fontTools.ttLib.tables._f_v_a_r import Axis from fontTools.ttLib.ttFont import TTFont from foundryToolsCLI.Lib.tables.OS_2 import TableOS2 @@ -623,6 +624,13 @@ def get_file_name(self, source) -> str: name. :return: A string representing the file name of the font. """ + if self.is_variable: + family_name = self.guess_family_name().replace(" ", "").strip() + if self.is_italic: + family_name += "-Italic" + axes = self.get_axes() + file_name = f"{family_name}[{','.join([axis.axisTag for axis in axes])}]" + return file_name if self.is_ttf: if source in (4, 5): @@ -644,6 +652,14 @@ def get_file_name(self, source) -> str: else: return Path(self.reader.file.name).stem + def get_axes(self) -> list[Axis]: + """ + This function returns a list of axes in a variable font. + """ + if not self.is_variable: + return [] + return [axis for axis in self["fvar"].axes if axis.flags == 0] + def fix_cff_top_dict_version(self) -> None: if not self.is_otf: return diff --git a/foundryToolsCLI/Lib/VFont.py b/foundryToolsCLI/Lib/VFont.py index d9890c0..e53db25 100644 --- a/foundryToolsCLI/Lib/VFont.py +++ b/foundryToolsCLI/Lib/VFont.py @@ -1,6 +1,6 @@ from pathlib import Path -from fontTools.ttLib.tables._f_v_a_r import NamedInstance, Axis +from fontTools.ttLib.tables._f_v_a_r import NamedInstance from foundryToolsCLI.Lib.Font import Font @@ -10,9 +10,6 @@ def __init__(self, file=None, recalcTimestamp=False): super().__init__(file=file, recalcTimestamp=recalcTimestamp) assert "fvar" in self - def get_axes(self) -> list[Axis]: - return [axis for axis in self["fvar"].axes if axis.flags == 0] - def get_instances(self) -> list[NamedInstance]: return [instance for instance in self["fvar"].instances] diff --git a/foundryToolsCLI/__init__.py b/foundryToolsCLI/__init__.py index 65950ce..ca101a5 100644 --- a/foundryToolsCLI/__init__.py +++ b/foundryToolsCLI/__init__.py @@ -1,3 +1,3 @@ -VERSION = __version__ = "1.1.17" +VERSION = __version__ = "1.1.18" __all__ = ["VERSION"] diff --git a/setup.py b/setup.py index 09746af..233228a 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def _get_requirements(): setuptools.setup( name="foundrytools-cli", - version="1.1.17", + version="1.1.18", description="A set of command line tools to inspect, manipulate and convert font files", long_description=long_description, long_description_content_type="text/markdown",