feat(fontless): support selecting preloaded fonts by subsets#655
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: |
| * @default false | ||
| * @example { subsets: ['latin'] } | ||
| */ | ||
| type PreloadOption = boolean | { subsets: string[] } |
There was a problem hiding this comment.
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.
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
preloadoption to support selecting preloaded fonts bypreload.subsets: [...].It also updated a public API
transformCssto have more flexible preload selection. I addedFontFamilyInjectionPluginOptions.filterFontsToPreloadand deprecatedFontFamilyInjectionPluginOptions.shouldPreload.