-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Implement zGoogleFont zod type #4284
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -0,0 +1,7 @@ | |||
import {getAvailableFonts} from '@remotion/google-fonts'; |
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.
Thanks a lot for starting this initiative!
Unfortunately I think it's not a good idea to use @remotion/google-fonts
as a dependency.
@remotion/zod-types
is a lightweight package and many people use it to for example show a color picker.
Due to it's massive database, @remotion/google-fonts
is a 50MB package that most people will not even need in this case.
For a zGoogleFont
type, we should use the Google Fonts package and write a script to generate a list of available fonts, then use that instead of depending on the whole package.
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.
Just out of curiosity and to clarify: Why do we even have to write a generator script here? I have checked packages/google-fonts/scripts
and it does not seem like it fetches fonts from Google Fonts API. And, in this case, all we need (I presume) is to get the names of the fonts and that's all.
So, doesn't that mean I can just copy all FontName.ts
files under packages/google-fonts/src
into packages/zod-types/src/z-google-fonts
? Or maybe a create a big packages/zod-types/src/z-google-fonts/fonts.ts
and create something like:
const fonts: string[] = [
// ...
'Roboto',
'Ubuntu',
// ...
];
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.
The generator script does only retrieve metadata: List of available fonts, weights, styles, unicode ranges and most importantly the URLs at which it should fetch the actual fonts. The metadata powers also the TypeScript type completion and the getInfo()
APIs. Yes even this data is massive.
I would say yes, you can just copy all font names into an array. Then the developer can itself retrieve the metadata from that and load fonts.
Closes #2692.
This PR is a draft.