-
-
Notifications
You must be signed in to change notification settings - Fork 41
feat(fontless): support selecting preloaded fonts by subsets #655
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
base: main
Are you sure you want to change the base?
feat(fontless): support selecting preloaded fonts by subsets #655
Conversation
❌ Deploy Preview for fontless failed.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #655 +/- ##
==========================================
- Coverage 53.40% 52.79% -0.62%
==========================================
Files 11 11
Lines 734 752 +18
Branches 93 94 +1
==========================================
+ Hits 392 397 +5
- Misses 342 355 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
commit: |
packages/fontless/src/types.ts
Outdated
* @default false | ||
* @example { subsets: ['latin'] } | ||
*/ | ||
type PreloadOption = boolean | { subsets: string[] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might also want to choose preload based on font file extensions (defaulting to only .woff2
). maybe we could support just passing a function directly? e.g. preload?: boolean | ((fontFamily: string, data: FontFaceData) => boolean)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, making it more flexible sounds good to me, but my intention was that subsets based preload selection should provide optional most of the case, so simple option preload.subset
might be good enough to start with. Btw, woff
(meta.priority = 1) returned by google provider is not a subsetted font, which is why it's large and thus they don't get included in current preload.subsets
.
That said, I was also thinking that maybe we can later expand option to { subsets: string[], weights: string[], etc. }
, which may become tricky, so I agree with exposing boolean function. However, I think we should also keep simple preload.subsets
option.
This PR updated
preload
option to support selecting preloaded fonts bypreload.subsets: [...]
.It also updated a public API
transformCss
to have more flexible preload selection. I addedFontFamilyInjectionPluginOptions.filterFontsToPreload
and deprecatedFontFamilyInjectionPluginOptions.shouldPreload
.