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

Use Google Fonts' "text" parameter to limit the font characters to fetch #135

Closed
asger-finding opened this issue Sep 13, 2022 · 3 comments · Fixed by #136
Closed

Use Google Fonts' "text" parameter to limit the font characters to fetch #135

asger-finding opened this issue Sep 13, 2022 · 3 comments · Fixed by #136
Labels
enhancement New feature or request

Comments

@asger-finding
Copy link

asger-finding commented Sep 13, 2022

The text images are excessively large since all characters in the font are loaded. By including a text url parameter, detailing what characters are used, the google font can be scaled down in size significantly.

For example, https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&text=fo will only deliver the f and o characters, which can spell out foo, but not bar nor Foo.
It'd be neat if this was automated on the back-end of course.

It should be noted that I managed to reduce the file size of my readme-typing from 150kb to 5kb.

@asger-finding asger-finding added the enhancement New feature or request label Sep 13, 2022
@DenverCoder1 DenverCoder1 added this to To do in Readme Typing SVG Projects via automation Sep 13, 2022
@DenverCoder1
Copy link
Owner

This is a very neat idea! I didn't know about this, but this can definitely increase the performance in many ways.

It seems like with this method, fetching the Google Fonts from the API takes 2-4 times less time than the database in many cases since it doesn't need to fetch all the different scripts.

I think I may even remove the font database connection entirely and just use the API with the text parameter.

@DenverCoder1
Copy link
Owner

Thanks @asger-finding! Let me know what you think of the proposed solution.

@asger-finding
Copy link
Author

Super neat!

Readme Typing SVG Projects automation moved this from To do to Done Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

2 participants