Skip to content

Commit

Permalink
Report variation axes that only use the default value as unused rathe…
Browse files Browse the repository at this point in the history
…r than underutilized
  • Loading branch information
papandreou committed Sep 4, 2022
1 parent d7758eb commit 1208259
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 4 additions & 1 deletion lib/subsetFonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,11 @@ function warnAboutUnusedVariationAxes(
if (ignoredVariationAxes.has(name)) {
continue;
}
let usedValues = [];
if (seenAxisValuesByAxisName.has(name) && !outOfBoundsAxes.has(name)) {
const usedValues = [...seenAxisValuesByAxisName.get(name)];
usedValues = [...seenAxisValuesByAxisName.get(name)];
}
if (!usedValues.every((value) => value === defaultValue)) {
if (!standardVariationAxes.has(name)) {
usedValues.push(defaultValue);
}
Expand Down
10 changes: 4 additions & 6 deletions test/subsetFonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ describe('subsetFonts', function () {
fontFamilies: expect.it('to be a', Set),
fontStyles: expect.it('to be a', Set),
fontWeights: expect.it('to be a', Set),
fontStretches: expect.it('to be a', Set),
fontVariationSettings: expect.it('to be a', Set),
hasOutOfBoundsAnimationTimingFunction: false,
codepoints: {
Expand Down Expand Up @@ -2895,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: GRAD, XOPQ, YOPQ, YTLC, YTUC, YTDE, YTFI\n Underutilized axes:\n wght: 400 used (100-1000 available)\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, XOPQ, YOPQ, YTLC, YTUC, YTDE, YTFI\n Underutilized axes:\n YTAS: 400-750 used (649-854 available)'
),
});
});
Expand Down Expand Up @@ -2971,10 +2972,7 @@ describe('subsetFonts', function () {

expect(infoSpy, 'to have calls satisfying', function () {
infoSpy({
message: expect.it(
'to contain',
'Underutilized axes:\n ital: 0 used (0-1 available)'
),
message: expect.it('to contain', 'Unused axes: ital'),
});
});
});
Expand Down Expand Up @@ -3046,7 +3044,7 @@ describe('subsetFonts', function () {
infoSpy({
message: expect.it(
'to contain',
'Underutilized axes:\n wght: 400 used (100-1000 available)\n YTAS: 400-750 used (649-854 available)'
'Underutilized axes:\n YTAS: 400-750 used (649-854 available)'
),
});
});
Expand Down

0 comments on commit 1208259

Please sign in to comment.