Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google provider downloads variable fonts even when not required #108

Open
florian-lefebvre opened this issue Jan 21, 2025 · 3 comments
Open
Labels
bug Something isn't working

Comments

@florian-lefebvre
Copy link
Collaborator

🐛 The bug

When downloading a family that has an available variable font with the default settings, the whole variable font is downloaded (https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900)

🛠️ To reproduce

https://stackblitz.com/edit/github-anxb2im8?file=index.js

🌈 Expected behaviour

When downloading a family that has an available variable font with the default settings, only the 400 weight should be downloaded (https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;1,400)

ℹ️ Additional context

I think the faulty logic lives here https://github.com/unjs/unifont/blob/main/src/providers/google.ts#L42, it should check the provided weights for .. first. I'd be happy to submit a PR

@florian-lefebvre florian-lefebvre added the bug Something isn't working label Jan 21, 2025
@qwerzl
Copy link
Collaborator

qwerzl commented Jan 21, 2025

Yes, this has been the expected behavior, but we might need to re-think about the way to handle google's variable fonts instead of simply defaulting to the full-axis one. @danielroe what's your opinion on this?

@florian-lefebvre
Copy link
Collaborator Author

For context, I'm working on adding 1st party fonts support to Astro and we want the default to be as lightweight as possible

@ematipico
Copy link

Is there anything we can do to resolve this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants