Skip to content

Commit

Permalink
Clamp the used variation axis values to the available interval
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Sep 7, 2022
1 parent dc4be15 commit 1429c0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/subsetFonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,9 @@ function warnAboutUnusedVariationAxes(
}
let usedValues = [];
if (seenAxisValuesByAxisName.has(name) && !outOfBoundsAxes.has(name)) {
usedValues = [...seenAxisValuesByAxisName.get(name)];
usedValues = [...seenAxisValuesByAxisName.get(name)].map((usedValue) =>
_.clamp(usedValue, min, max)
);
}
if (!usedValues.every((value) => value === defaultValue)) {
if (!standardVariationAxes.has(name)) {
Expand Down
12 changes: 8 additions & 4 deletions test/subsetFonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2896,7 +2896,7 @@ describe('subsetFonts', function () {
infoSpy({
message: expect.it(
'to contain',
'RobotoFlex-VariableFont_GRAD,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght.ttf:\n Unused axes: wght, wdth, GRAD, slnt, XOPQ, YOPQ, YTLC, YTUC, YTDE, YTFI\n Underutilized axes:\n YTAS: 400-750 used (649-854 available)'
'RobotoFlex-VariableFont_GRAD,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght.ttf:\n Unused axes: wght, wdth, GRAD, slnt, XOPQ, YOPQ, YTLC, YTUC, YTDE, YTFI\n Underutilized axes:\n YTAS: 649-750 used (649-854 available)'
),
});
});
Expand Down Expand Up @@ -3070,7 +3070,9 @@ describe('subsetFonts', function () {
infoSpy({
message: expect.it(
'to contain',
'Underutilized axes:\n slnt: 14 used (-10-0 available)'
'Unused axes: wght, wdth, GRAD, slnt,'
// FIXME: Find a liberally licensed variable font that actually includes a slnt value of 14 so we can test that the output is:
// 'Underutilized axes:\n slnt: 14 used (-100-100 available)'
),
});
});
Expand All @@ -3096,7 +3098,9 @@ describe('subsetFonts', function () {
infoSpy({
message: expect.it(
'to contain',
'Underutilized axes:\n slnt: 0-14 used (-10-0 available)'
'Unused axes: wght, wdth, GRAD, slnt,'
// FIXME: Find a liberally licensed variable font that actually includes a slnt value of 14 so we can test that the output is:
// 'Underutilized axes:\n slnt: 0-14 used (-100-100 available)'
),
});
});
Expand Down Expand Up @@ -3124,7 +3128,7 @@ describe('subsetFonts', function () {
infoSpy({
message: expect.it(
'to contain',
'Underutilized axes:\n YTAS: 400-750 used (649-854 available)'
'Underutilized axes:\n YTAS: 649-750 used (649-854 available)'
),
});
});
Expand Down

0 comments on commit 1429c0f

Please sign in to comment.