Skip to content

Commit

Permalink
Merge pull request #104 from Munter/fix/alwaysIncludeSpaceInSubset
Browse files Browse the repository at this point in the history
Always include the space character U+20 in subsets
  • Loading branch information
Munter authored Jul 5, 2020
2 parents d61271e + 7c43ad1 commit 49d5625
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/subsetFonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,12 @@ async function subsetFonts(
const usedCodepoints = fontUsage.text
.split('')
.map((c) => c.codePointAt(0));
if (!usedCodepoints.includes(32)) {
// Make sure that space is always part of the subset fonts (and that it's announced in unicode-range).
// Prevents Chrome from going off and downloading the fallback:
// https://gitter.im/assetgraph/assetgraph?at=5f01f6e13a0d3931fad4021b
usedCodepoints.push(32);
}
const unusedCodepoints = originalCodepoints.filter(
(n) => !usedCodepoints.includes(n)
);
Expand Down
2 changes: 1 addition & 1 deletion test/subsetFonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ describe('subsetFonts', function () {
fontFamilies: expect.it('to be a', Set),
codepoints: {
original: expect.it('to be an array'),
used: [101, 108, 111, 72],
used: [101, 108, 111, 32, 72],
unused: expect.it('to be an array'),
},
},
Expand Down

0 comments on commit 49d5625

Please sign in to comment.