feat(preset-web-fonts): use woff2 compatible user-agent #2114
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The most commonly used web font provider is Google Fonts and they are differentiating the CSS response based on the
User-Agent
header.If the user agent supports
woff2
format then the CSS response will containwoff2
font definitions.woff2
is using Brotli compression, which is far more efficient thanttf
, able to useunicode-range
(font chunks) and it's supported >96% of browsers.Currently the
@unocss/preset-web-fonts
is fetching web font CSS usingohmyfetch
library without setting any user agent, that's why Google Fonts will serve a CSS withttf
fonts.Example injected web font definitions by web-fonts preset:
With this PR the injected font definitions will be the following: