Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Custom mobile editor font #1797
I'm fine with this change, we can merge once it works with Android.
To detect Android from Setting.js you can do it like this:
Thanks for the pointers @laurent22! That's super helpful. I added the shim, which seems to handle the platform switching appropriately.
Do you know which fonts are allowed for Android? I'd love to support this feature for Android too, since @tessus seems excited about it. But if it's not immediately obvious how to do that, we could go down that rabbit hole in another PR so it's not blocking this one.
UPDATE: It looks like these are the fonts available out-of-the-box: https://github.com/react-native-training/react-native-fonts, though from what @tessus said it sounds like
Yes, I have all fonts installed locally, but that doesn't mean they are available to the iOS or Android emulators, or does it? I would have thought that they had to be installed properly to be referenced.
Hmm, so we either have to ship fonts, which might not be that easy due to licensing and it would increase the app size, or we find fonts that are available on iOS and Android that we can use....
Maybe the issue is that with this change we force a default font but if that default doesn't exist it will fail. Instead, the default should be like now to set no font at all and let the system pick one. So I think the options should be: "Default", followed by OS-specific fonts, "Menlo", etc.
Also I'm thinking, is it really do-able to list specific fonts? On iOS maybe, but on Android there are so many different variants that we can't know in advance if a font will exist or not.
So to keep it simple we could have two sets of options:
For Android, Monospace will just be a CSS string like "Monospace, Courier News", etc. Maybe later we can pick some nice fonts commonly available, but for now just generic monospace would do.