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

Consider a new way to load dynamic fonts #367

Closed
shuding opened this issue Jan 9, 2023 · 3 comments · Fixed by #442
Closed

Consider a new way to load dynamic fonts #367

shuding opened this issue Jan 9, 2023 · 3 comments · Fixed by #442
Assignees
Labels
enhancement New feature or request released

Comments

@shuding
Copy link
Member

shuding commented Jan 9, 2023

Currently the process of loading dynamic fonts for missing graphemes is, we use a list of RegExps to match that character, and use the first match as the final locale. Then, we go to Google Fonts and load that corresponding Noto Sans with that locale.

The problem is that these RegExps are not accurate. It might be not possible at all to generate RegExps for languages (or too large). For example we have Han in both zh-CN, ja-JP, and zh-TW and zh-HK, but this is not always correct. In this example is only available in zh-CN but is matched by Han.

We can step back and try to load the actual font instead, and check if that character (unicode) is included in that font. For example to render , we matched ["ja-JP", "zh-CN", "zh-TW", "zh-HK"]. And then, we fetch corresponding Google Fonts CSS such as https://fonts.googleapis.com/css2?family=Noto+Sans+JP&display=swap and check their unicode-range to see if is included.

I think this can be a more reliable approach.

Bug reproduction

@shuding shuding added the enhancement New feature or request label Jan 9, 2023
@LuciNyan
Copy link
Contributor

I'm interested in it! Can you assign it to me? <3

@shuding
Copy link
Member Author

shuding commented Feb 7, 2023

Sure, @LuciNyan thank you and feel free to explore this!

@github-actions
Copy link

🎉 This issue has been resolved in version 0.4.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

sahithyandev pushed a commit to sahithyandev/satori that referenced this issue Apr 26, 2024
Hi! @shuding I have encountered a minor issue. After successfully
retrieving the necessary font files on the backend server, I am simply
uncertain about the optimal method for transmitting them back to the
front end in a single response while also specifying the language for
each file. Would you be able to provide me with some guidance on this
matter? 🤔️

Closes: vercel#367

---------

Co-authored-by: Shu Ding <g@shud.in>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants