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
Add Support for custom fonts in composition of React Native component. #4816
Comments
I agree |
@toticuervo-tandem - I just upgraded Webpack and others in #4842. It seems to be working now, can you check? |
OP is @KutnerUri |
sorry. @yarahemant - can you check? |
@KutnerUri the fonts do not seem to match with that of Figma. current (used) bvm version: 0.0.26 Replying on behalf of @yarahemant |
@kapildeyyara2 did you find a solution? We're following the same approach with a custom Text component that uses a custom font. But on Bit it always defaults back to some standard font. |
would love to find a solution to this problem! |
How are you trying to apply the fonts? Webpack is supposed to pick up fonts from Maybe, for compositions, you can create a regular css font component (and add it to your env providers), and then add the fonts to the |
The config file is only being used for the ‘react-native link’ command which copies the assets into the native ios/android folders. when developing a react native app we still have to build a unique android app as well as a unique ios app. During this building process our React files are getting transformed into native android/ios code so the apps work native on devices. During this process iOS and Android take the fonts that are placed in the native directories and bundle them into the app. After bundling the files into the app the transformed React Project has access to those fonts. I think when using react-native-web there has to be an index.html file, the question is if you link the fonts in that html file do they actually end up being reachable by the react-native components |
necolas/react-native-web#2176 (comment) It seems possible to load fonts like we need with expo. But expo needs native changes which you can see here: When installing expo in a bit workspace and trying to use it bit throws following error in component docs / composition: |
If I understand correctly you have a font in the app globally and you want to see it on your component compositions. |
Update, currently the react-native env doesn’t support |
@JoshK2 Thanks for working out the example! What do you think is the timeline on this ? probably after new years ? |
@JoshK2 - Now that I think about it, it might be possible to just import the css/fonts from the // your-env.preview.runtime.ts
import './global-fonts.css' /* global-fonts.css */
@font-face {
font-family: "FontName";
src: url("./assets/lineto-circular-bookitalic.woff2") format("woff2"); /* etc */
} We still need to support providers in React Native, but this should tell Webpack to bundle the font and make it available. |
@h3nk42 the example is working and I'll publish it soon to a public repo. |
The PR is almost ready! The demo is working too, I'll send it after the PR above will be merged because you need the changes to do the same as I did. |
The PR was merged, so after the next release, I'll publish the demo workspace. |
I'm happy to share that a version including my changes is now available. And here is a demo project that demonstrates the support for custom fonts in React Native compositions. |
Thanks @JoshK2 for the amazing work to make custom fonts work with Bit! @JoshK2 just in case someone else needs a guide for how to set this up, this approach is correct right?
Thanks a lot again, this is awesome! |
@smn-snkl perfect! |
Description
I build my own Text Component in React Native and exported over bit.dev harmony and I added composition as well but I am using Noto Sans font in my own Text Component and I want the same font should be visible in composition of Text component as well but it is showing some default font over composition over bit.dev
So could you guys suggest something how can i add my own font in my own React Native components over composition.
Specifications
The text was updated successfully, but these errors were encountered: