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

Added a local font for offline usage #55

Merged
merged 3 commits into from
Oct 3, 2024
Merged

Conversation

Alkebsi
Copy link
Contributor

@Alkebsi Alkebsi commented Sep 28, 2024

Closing #53

The Problem

Trying to run r3f-perf in an offline environment or an organization reserved internet connection (that blocks access to third-party URLs or CDNs) will bring errors to the console and completely hide the stats of r3f-perf, like the image below:

20240928_171907

The Solution

I downloaded and optimized the Roboto font from Google Fonts. I added it to the src directory and imported it directly in TextsHighHZ.tsx.

The result, while offline:
20240928_171850

It worked just fine in the dev environment and got built just fine.

Additional Size

The font initially weighted 164.69 KB. After using Font Squirrel, the size down to around ~26 KB

@Alkebsi
Copy link
Contributor Author

Alkebsi commented Sep 28, 2024

@RenaudRohlinger, I am open for editing this PR, if nessasery.

@RenaudRohlinger
Copy link
Member

If I remember correctly there is an online tool to cherry pick the characters we want to use. For example we could re-generate the Roboto font with only 0123456789 instead, it would go down to 1kb I guess.

@Alkebsi
Copy link
Contributor Author

Alkebsi commented Oct 2, 2024

If I remember correctly there is an online tool to cherry pick the characters we want to use. For example we could re-generate the Roboto font with only 0123456789 instead, it would go down to 1kb I guess.

I will see my options and update this PR.
Thanks for your comment ❤

This font only have the 1234567890 seubset of the Roboto-Medium font. Automaticly, the letters and special charecters are there, but they will follow the system default!
@Alkebsi
Copy link
Contributor Author

Alkebsi commented Oct 2, 2024

Hi @RenaudRohlinger,

I did my best to reduce it, and this was the best version at 11.66 KB. This has the subset of the numbers only and all others, like uppercase/lowercase/special/...etc characters, will be generated from the system's default font.

I couldn't make it lighter. Have you seen one before that I can test out? I used https://transfonter.org/

@RenaudRohlinger
Copy link
Member

Thanks!

@RenaudRohlinger RenaudRohlinger merged commit a217043 into utsuboco:main Oct 3, 2024
1 check failed
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.

2 participants