Closed dilincoln closed 2 years ago
I'm using Nunito font from the module @expo-google-fonts/nunito and for some reason on Android the name of regular font is 'Nunito_400Regular' but on iOS is 'Nunito-Regular'.
This error is because the value('Nunito_400Regular' ) of fontName property is passed to NativeModule of the react-native-image-marker but in iOS when the font is imported(By the @expo-google-fonts/nunito i think) as 'Nunito-Regular'.
To discover the right name of font in iOS i was added this code below on file /ios/YOURPROJECTNAME/AppDelegate.m
. So when the app starts you can see all fonts available on iOS/Android and they names in log.
...
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#if defined(FB_SONARKIT_ENABLED) && __has_include(<FlipperKit/FlipperClient.h>)
InitializeFlipper(application);
#endif
// THIS CODE v
for (NSString* family in [UIFont familyNames])
{
NSLog(@"%@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])
{
NSLog(@" %@", name);
}
}
// THIS CODE ˆ
...
On my app to solve this error i called ImageMarker function as describe below:
import { Platform } from 'react-native'
import ImageMarker from 'react-native-image-marker'
ImageMarker.markText({
src: 'YOURIMAGE',
text: 'Lorem ipsum',
X: 10,
Y: 10,
color: "#f2f2f2",
scale: 1,
quality: 100,
fontSize: 20,
fontName: Platform.OS === 'android' ? 'Nunito_400Regular' : 'Nunito-Regular', // This solved my problem
})
Describe the bug App crash when calling ImageMarker.markText. On Android works but on iOS the app close without any log or catch error but on Flipper has this appcrash:
To Reproduce Steps to reproduce the behavior:
Expected behavior Should log image path on success or log error on failed.
Devlopment environment(please complete the following information):
Smartphone (please complete the following information):
Additional context Add any other context about the problem here.