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

Each font variant as a separate module #103

Open
RobertSasak opened this issue Sep 11, 2023 · 0 comments
Open

Each font variant as a separate module #103

RobertSasak opened this issue Sep 11, 2023 · 0 comments

Comments

@RobertSasak
Copy link

I really love how easy it is to use fonts in this package. It is much faster and less error-prone than manually downloading and loading fonts.

Problem

The final bundle size is too big and contains all the variants of the selected font, even if only a few variants are used in the app.

Proposal

Split the module into multiple submodules for each font variant individually. This approach ensures not all the fonts are imported.

This is how the fonts are currently included:

import { useFonts, RobotoMono_700Bold, RobotoMono_400Regular } from '@expo-google-fonts/roboto-mono'

I propose allowing the import of font variants from submodules as well, as follows:

import { useFonts } from '@expo-google-fonts/roboto-mono/hooks'
import RobotoMono_700Bold from '@expo-google-fonts/roboto-mono/700bold'
import RobotoMono_400Regular from '@expo-google-fonts/roboto-mono/400regular'

Benefits

Selective importing of font variants can significantly reduce the final app size. For instance, for the highly popular Inter font family, the app size can be reduced from 2.8MB to as little as 320kb for a single font variant.

I can look into the PR if you find this issue relevant.

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

No branches or pull requests

1 participant