From 12082590898407f558d9540347778272ddb9d197 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Mon, 5 Sep 2022 00:02:20 +0200 Subject: [PATCH] Report variation axes that only use the default value as unused rather than underutilized --- lib/subsetFonts.js | 5 ++++- test/subsetFonts.js | 10 ++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/subsetFonts.js b/lib/subsetFonts.js index d133c332..4a325ec4 100644 --- a/lib/subsetFonts.js +++ b/lib/subsetFonts.js @@ -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); } diff --git a/test/subsetFonts.js b/test/subsetFonts.js index e7d6b3bc..c59c8003 100644 --- a/test/subsetFonts.js +++ b/test/subsetFonts.js @@ -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: { @@ -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)' ), }); }); @@ -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'), }); }); }); @@ -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)' ), }); });