diff --git a/examples/SimpleExample/.bundle/config b/examples/SimpleExample/.bundle/config index 848943b..2369228 100644 --- a/examples/SimpleExample/.bundle/config +++ b/examples/SimpleExample/.bundle/config @@ -1,2 +1,2 @@ +--- BUNDLE_PATH: "vendor/bundle" -BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/examples/SimpleExample/App.tsx b/examples/SimpleExample/App.tsx index a226d23..b8aae3e 100644 --- a/examples/SimpleExample/App.tsx +++ b/examples/SimpleExample/App.tsx @@ -40,6 +40,14 @@ function AppContent() { safeArea: useSafeAreaInsets, storage: SecureStorage, markdown: Markdown, + buttonFont: { + filename: 'WorkSans-Regular.ttf', + postscriptName: 'WorkSans-Regular', + }, + surveyTextFont: { + filename: 'Merriweather-Regular.ttf', + postscriptName: 'Merriweather-Regular', + }, }); Iterate.onResponse((response, question, survey) => { diff --git a/examples/SimpleExample/android/app/src/main/assets/fonts/Merriweather-Regular.ttf b/examples/SimpleExample/android/app/src/main/assets/fonts/Merriweather-Regular.ttf new file mode 100644 index 0000000..3fecc77 Binary files /dev/null and b/examples/SimpleExample/android/app/src/main/assets/fonts/Merriweather-Regular.ttf differ diff --git a/examples/SimpleExample/android/app/src/main/assets/fonts/WorkSans-Regular.ttf b/examples/SimpleExample/android/app/src/main/assets/fonts/WorkSans-Regular.ttf new file mode 100644 index 0000000..20c7240 Binary files /dev/null and b/examples/SimpleExample/android/app/src/main/assets/fonts/WorkSans-Regular.ttf differ diff --git a/examples/SimpleExample/android/app/src/main/assets/fonts/WorkSans-VariableFont_wght.ttf b/examples/SimpleExample/android/app/src/main/assets/fonts/WorkSans-VariableFont_wght.ttf new file mode 100644 index 0000000..09829a5 Binary files /dev/null and b/examples/SimpleExample/android/app/src/main/assets/fonts/WorkSans-VariableFont_wght.ttf differ diff --git a/examples/SimpleExample/android/link-assets-manifest.json b/examples/SimpleExample/android/link-assets-manifest.json new file mode 100644 index 0000000..2c53cb5 --- /dev/null +++ b/examples/SimpleExample/android/link-assets-manifest.json @@ -0,0 +1,17 @@ +{ + "migIndex": 1, + "data": [ + { + "path": "assets/fonts/Merriweather-Regular.ttf", + "sha1": "f4e7810e4e20d1932d3d7994bb6f6456280ee6bd" + }, + { + "path": "assets/fonts/WorkSans-Regular.ttf", + "sha1": "89a5d38e1316b70da48e9475628023264af74783" + }, + { + "path": "assets/fonts/WorkSans-VariableFont_wght.ttf", + "sha1": "4337ebe379f077e10794f92c7e2358d567698eb4" + } + ] +} diff --git a/examples/SimpleExample/assets/fonts/Merriweather-Regular.ttf b/examples/SimpleExample/assets/fonts/Merriweather-Regular.ttf new file mode 100644 index 0000000..3fecc77 Binary files /dev/null and b/examples/SimpleExample/assets/fonts/Merriweather-Regular.ttf differ diff --git a/examples/SimpleExample/assets/fonts/WorkSans-Regular.ttf b/examples/SimpleExample/assets/fonts/WorkSans-Regular.ttf new file mode 100644 index 0000000..20c7240 Binary files /dev/null and b/examples/SimpleExample/assets/fonts/WorkSans-Regular.ttf differ diff --git a/examples/SimpleExample/assets/fonts/WorkSans-VariableFont_wght.ttf b/examples/SimpleExample/assets/fonts/WorkSans-VariableFont_wght.ttf new file mode 100644 index 0000000..09829a5 Binary files /dev/null and b/examples/SimpleExample/assets/fonts/WorkSans-VariableFont_wght.ttf differ diff --git a/examples/SimpleExample/ios/SimpleExample.xcodeproj/project.pbxproj b/examples/SimpleExample/ios/SimpleExample.xcodeproj/project.pbxproj index 7674f03..d82e924 100644 --- a/examples/SimpleExample/ios/SimpleExample.xcodeproj/project.pbxproj +++ b/examples/SimpleExample/ios/SimpleExample.xcodeproj/project.pbxproj @@ -12,6 +12,9 @@ 6C55674377BC0F74FD15DB1D /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */; }; 761780ED2CA45674006654EE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 761780EC2CA45674006654EE /* AppDelegate.swift */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; + 89991C9D5CA142698A361BFC /* WorkSans-VariableFont_wght.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3D87004600AA4F63A87843F9 /* WorkSans-VariableFont_wght.ttf */; }; + B209F12DD5234CC780CEF867 /* WorkSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6019927FEB784F9D9FF97A00 /* WorkSans-Regular.ttf */; }; + FDC5E126412D47D8B868282A /* Merriweather-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D43CB6966E0A4FEC98BC8633 /* Merriweather-Regular.ttf */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -20,10 +23,13 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = SimpleExample/Info.plist; sourceTree = ""; }; 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = SimpleExample/PrivacyInfo.xcprivacy; sourceTree = ""; }; 3B4392A12AC88292D35C810B /* Pods-SimpleExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SimpleExample.debug.xcconfig"; path = "Target Support Files/Pods-SimpleExample/Pods-SimpleExample.debug.xcconfig"; sourceTree = ""; }; + 3D87004600AA4F63A87843F9 /* WorkSans-VariableFont_wght.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = undefined; includeInIndex = 0; lastKnownFileType = unknown; name = "WorkSans-VariableFont_wght.ttf"; path = "../assets/fonts/WorkSans-VariableFont_wght.ttf"; sourceTree = ""; }; 5709B34CF0A7D63546082F79 /* Pods-SimpleExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SimpleExample.release.xcconfig"; path = "Target Support Files/Pods-SimpleExample/Pods-SimpleExample.release.xcconfig"; sourceTree = ""; }; 5DCACB8F33CDC322A6C60F78 /* libPods-SimpleExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SimpleExample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 6019927FEB784F9D9FF97A00 /* WorkSans-Regular.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = undefined; includeInIndex = 0; lastKnownFileType = unknown; name = "WorkSans-Regular.ttf"; path = "../assets/fonts/WorkSans-Regular.ttf"; sourceTree = ""; }; 761780EC2CA45674006654EE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = SimpleExample/AppDelegate.swift; sourceTree = ""; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = SimpleExample/LaunchScreen.storyboard; sourceTree = ""; }; + D43CB6966E0A4FEC98BC8633 /* Merriweather-Regular.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = undefined; includeInIndex = 0; lastKnownFileType = unknown; name = "Merriweather-Regular.ttf"; path = "../assets/fonts/Merriweather-Regular.ttf"; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -75,6 +81,7 @@ 83CBBA001A601CBA00E9B192 /* Products */, 2D16E6871FA4F8E400B85C8A /* Frameworks */, BBD78D7AC51CEA395F1C20DB /* Pods */, + FF48CEE1897A45F8A908495E /* Resources */, ); indentWidth = 2; sourceTree = ""; @@ -98,6 +105,17 @@ path = Pods; sourceTree = ""; }; + FF48CEE1897A45F8A908495E /* Resources */ = { + isa = PBXGroup; + children = ( + D43CB6966E0A4FEC98BC8633 /* Merriweather-Regular.ttf */, + 6019927FEB784F9D9FF97A00 /* WorkSans-Regular.ttf */, + 3D87004600AA4F63A87843F9 /* WorkSans-VariableFont_wght.ttf */, + ); + name = Resources; + path = ""; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -161,6 +179,9 @@ 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 6C55674377BC0F74FD15DB1D /* PrivacyInfo.xcprivacy in Resources */, + FDC5E126412D47D8B868282A /* Merriweather-Regular.ttf in Resources */, + B209F12DD5234CC780CEF867 /* WorkSans-Regular.ttf in Resources */, + 89991C9D5CA142698A361BFC /* WorkSans-VariableFont_wght.ttf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/examples/SimpleExample/ios/SimpleExample/Info.plist b/examples/SimpleExample/ios/SimpleExample/Info.plist index fcddfe6..9b645cb 100644 --- a/examples/SimpleExample/ios/SimpleExample/Info.plist +++ b/examples/SimpleExample/ios/SimpleExample/Info.plist @@ -32,7 +32,7 @@ NSLocationWhenInUseUsageDescription - + RCTNewArchEnabled UILaunchStoryboardName @@ -49,5 +49,11 @@ UIViewControllerBasedStatusBarAppearance + UIAppFonts + + Merriweather-Regular.ttf + WorkSans-Regular.ttf + WorkSans-VariableFont_wght.ttf + diff --git a/examples/SimpleExample/ios/link-assets-manifest.json b/examples/SimpleExample/ios/link-assets-manifest.json new file mode 100644 index 0000000..2c53cb5 --- /dev/null +++ b/examples/SimpleExample/ios/link-assets-manifest.json @@ -0,0 +1,17 @@ +{ + "migIndex": 1, + "data": [ + { + "path": "assets/fonts/Merriweather-Regular.ttf", + "sha1": "f4e7810e4e20d1932d3d7994bb6f6456280ee6bd" + }, + { + "path": "assets/fonts/WorkSans-Regular.ttf", + "sha1": "89a5d38e1316b70da48e9475628023264af74783" + }, + { + "path": "assets/fonts/WorkSans-VariableFont_wght.ttf", + "sha1": "4337ebe379f077e10794f92c7e2358d567698eb4" + } + ] +} diff --git a/examples/SimpleExample/react-native.config.js b/examples/SimpleExample/react-native.config.js new file mode 100644 index 0000000..2cfead9 --- /dev/null +++ b/examples/SimpleExample/react-native.config.js @@ -0,0 +1,8 @@ +module.exports = { + project: { + ios: {}, + android: {}, + }, + assets: ['./assets/fonts/'], +}; + diff --git a/src/language.tsx b/src/language.tsx index 33e7ec8..945ccf0 100644 --- a/src/language.tsx +++ b/src/language.tsx @@ -23,9 +23,10 @@ const getPreferredLanguage = ( ): Language => { const deviceLanguageWithRegion = Platform.OS === 'ios' - ? NativeModules.SettingsManager.settings.AppleLocale ?? - NativeModules.SettingsManager.settings.AppleLanguages[0] // iOS 13 - : NativeModules.I18nManager.localeIdentifier; + ? NativeModules.SettingsManager?.settings?.AppleLocale ?? + NativeModules.SettingsManager?.settings?.AppleLanguages?.[0] ?? // iOS 13 + 'en-US' + : NativeModules.I18nManager?.localeIdentifier ?? 'en-US'; const deviceLanguage = deviceLanguageWithRegion.substring(0, 2); const userTraitLanguage = userTraits?.language as Language;