Skip to content

Inject unicode-range into the original @font-face declaration when it's missing some of the glyphs that are used#100

Merged
Munter merged 3 commits intomasterfrom
fix/missingGlyphsInOriginalFont
Jun 30, 2020
Merged

Inject unicode-range into the original @font-face declaration when it's missing some of the glyphs that are used#100
Munter merged 3 commits intomasterfrom
fix/missingGlyphsInOriginalFont

Conversation

@papandreou
Copy link
Collaborator

See the discussion here: Munter/netlify-plugin-subfont#55

It fixes the double download when I run subfont on the test case we use for the missing glyph warning.

Fixes Munter/netlify-plugin-subfont#55

Before

before

After

after

@coveralls
Copy link

coveralls commented Jun 27, 2020

Pull Request Test Coverage Report for Build 349

  • 10 of 10 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.08%) to 89.486%

Totals Coverage Status
Change from base Build 347: 0.08%
Covered Lines: 999
Relevant Lines: 1069

💛 - Coveralls

@Munter
Copy link
Owner

Munter commented Jun 29, 2020

Looks great. I can't quite remember the details here. Do we know if this behaves well for google fonts?

@papandreou
Copy link
Collaborator Author

Do we know if this behaves well for google fonts?

Yeah, it should work great. Because of the User-Agent we use, we get CSS without unicode-range:

@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400;
  src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v20/KFOmCnqEu92Fr1Mu4mxP.ttf) format('truetype');
}

... So it should make a very positive difference :)

@Munter
Copy link
Owner

Munter commented Jun 30, 2020

It's just hat Google fonts fallbacks are still loaded from Google itself. But I guess that just means the addition adds a benefit to self-hosted fonts for now, and when we switch to self-hosted fallback fonts from Google fonts, they will get the benefit as well

@Munter
Copy link
Owner

Munter commented Jun 30, 2020

Just did a manual test with Google hosted fonts. Obviously there is nowhere we can add the unicode-range because google controls the stylesheet. So I was worried that the updated error message was incorrect. But of course, google serves unicode-range to capable browsers, so the error message is still correct even when Google supplies the CSS for the fallback font :D

@Munter Munter merged commit bb5f4db into master Jun 30, 2020
@Munter Munter deleted the fix/missingGlyphsInOriginalFont branch June 30, 2020 07:34
@papandreou
Copy link
Collaborator Author

Ah, right, yes 🤦

You’re right that the fallback CSS that gets async loaded from fonts.googleapis.com won’t benefit from this. We really should self-host that as well.

@daveredfern
Copy link

Thanks for your hard work fixing this @Munter @papandreou. It’s really appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Double font flicker when loading pages

4 participants