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

Implement zGoogleFont zod type #4284

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

erayerdin
Copy link

Closes #2692.

This PR is a draft.

Copy link

vercel bot commented Sep 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bugs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 9, 2024 8:55am
remotion ❌ Failed (Inspect) Sep 9, 2024 8:55am
remotion-convert ❌ Failed (Inspect) Sep 9, 2024 8:55am

@@ -0,0 +1,7 @@
import {getAvailableFonts} from '@remotion/google-fonts';
Copy link
Member

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.

Copy link
Author

@erayerdin erayerdin Sep 6, 2024

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',
  // ...
];

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement zod type for google fonts
2 participants