Skip to content

Commit

Permalink
allow fonts which do not have a wght axis
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rc1e committed Jul 27, 2023
1 parent 86b034e commit 0405767
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/diffenator2/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def instances(self):
name.getBestSubFamilyName(),
)
)
return sorted(results, key=lambda k: k.coords["wght"])
return results

def masters(self):
assert self.is_variable(), "Needs to be a variable font"
Expand Down
3 changes: 2 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
mavenpro_regular = os.path.join(DATA_FP, "MavenPro-Regular.subset.ttf")
mavenpro_extra_bold = os.path.join(DATA_FP, "MavenPro-ExtraBold.subset.ttf")
mavenpro_black = os.path.join(DATA_FP, "MavenPro-Black.subset.ttf")
commissioner_vf = os.path.join(DATA_FP, "Commissioner[FLAR,VOLM,slnt,wght].ttf")
commissioner_vf = os.path.join(DATA_FP, "Commissioner[FLAR,VOLM,slnt,wght].ttf")
kablammo_vf = os.path.join(DATA_FP, "Kablammo[MORF].ttf")
23 changes: 23 additions & 0 deletions tests/test_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,34 @@ def test_match_coordinates(fp_before, fp_after, expected):
},
]
),
(
kablammo_vf,
[
{
"name": "Zoink",
"coords": {"MORF": 0.0},
},
{
"name": "Bloop",
"coords": {'MORF': 20.0},
},
{
"name": "Splat",
"coords": {'MORF': 40.0},
},
{
"name": "Eek",
"coords": {'MORF': 60.0},
},
]
)
]
)
def test_instances(fp, expected):
font = DFont(fp)
font_instances = font.instances()
assert len(font_instances) == len(expected)
for got, want in zip(font_instances, expected):
assert got.font == font
assert got.name == want["name"]
Expand Down

0 comments on commit 0405767

Please sign in to comment.