Skip to content

fix(fontless): avoid loading woff over woff2 with google provider#657

Merged
danielroe merged 3 commits intounjs:mainfrom
hi-ogawa:09-28-fix_fontless_avoid_loading_woff_over_woff2
Sep 28, 2025
Merged

fix(fontless): avoid loading woff over woff2 with google provider#657
danielroe merged 3 commits intounjs:mainfrom
hi-ogawa:09-28-fix_fontless_avoid_loading_woff_over_woff2

Conversation

@hi-ogawa
Copy link
Collaborator

@hi-ogawa hi-ogawa commented Sep 28, 2025

problem

CSS spec says the when there are multiple @font-face with overlapping unicode-range, browser picks the last one. Note that when it's not specified, it's considered as a full range.

Reference https://www.w3.org/TR/css-fonts-4/#composite-fonts

If the unicode ranges overlap for a set of @font-face rules with the same family and style descriptor values, the rules are ordered in the reverse order they were defined; the last rule defined is the first to be checked for a given character.

solution

This PR moves priority: 1 before priority: 0 in rendered css, so browser prioritizes priority: 0 for overlapping unicode-range.

alternative

Removing priority: 1 might be also an option since woff2 only is normally considered fine. For example, next/font only generates woff2 https://nextjs.org/docs/app/api-reference/components/font and fontsource`'s default setup suggests woff2 https://fontsource.org/docs/getting-started/install

@netlify
Copy link

netlify bot commented Sep 28, 2025

Deploy Preview for fontless failed.

Name Link
🔨 Latest commit 269d83c
🔍 Latest deploy log https://app.netlify.com/projects/fontless/deploys/68d8d621cd11590008e39a08

@hi-ogawa hi-ogawa changed the title fix(fontless): avoid loading woff over woff2 fix(fontless): avoid loading woff over woff2 with google provider Sep 28, 2025
@codecov
Copy link

codecov bot commented Sep 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.47%. Comparing base (75ef138) to head (269d83c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #657      +/-   ##
==========================================
+ Coverage   53.41%   53.47%   +0.06%     
==========================================
  Files          11       11              
  Lines         732      733       +1     
  Branches       93       93              
==========================================
+ Hits          391      392       +1     
  Misses        341      341              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this great change ☺️

@hi-ogawa hi-ogawa force-pushed the 09-28-fix_fontless_avoid_loading_woff_over_woff2 branch from afdb647 to 269d83c Compare September 28, 2025 06:30
@hi-ogawa hi-ogawa marked this pull request as ready for review September 28, 2025 06:33
@hi-ogawa hi-ogawa requested a review from danielroe as a code owner September 28, 2025 06:33
@danielroe danielroe merged commit 6e5db91 into unjs:main Sep 28, 2025
5 of 9 checks passed
@hi-ogawa hi-ogawa deleted the 09-28-fix_fontless_avoid_loading_woff_over_woff2 branch September 28, 2025 07:52
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.

[fontless] google provider includes both woff2 and woff in css and browser downloads larger woff

3 participants