From 9407f562f6d74daf557a58554573bdf455dda667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 16 Oct 2018 12:17:15 +0200 Subject: [PATCH] [iOS] Simplify dynamically loading fonts --- ios/sdk/sdk.xcodeproj/project.pbxproj | 2 -- ios/sdk/src/Info.plist | 4 ---- ios/sdk/src/JitsiMeetView.m | 33 -------------------------- react/features/base/font-icons/Icon.js | 7 ++++++ 4 files changed, 7 insertions(+), 39 deletions(-) diff --git a/ios/sdk/sdk.xcodeproj/project.pbxproj b/ios/sdk/sdk.xcodeproj/project.pbxproj index 1aa5def58..765954327 100644 --- a/ios/sdk/sdk.xcodeproj/project.pbxproj +++ b/ios/sdk/sdk.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ 0B49424520AD8DBD00BD2DE0 /* outgoingStart.wav in Resources */ = {isa = PBXBuildFile; fileRef = 0B49424320AD8DBD00BD2DE0 /* outgoingStart.wav */; }; 0B49424620AD8DBD00BD2DE0 /* outgoingRinging.wav in Resources */ = {isa = PBXBuildFile; fileRef = 0B49424420AD8DBD00BD2DE0 /* outgoingRinging.wav */; }; 0B7C2CFD200F51D60060D076 /* LaunchOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B7C2CFC200F51D60060D076 /* LaunchOptions.m */; }; - 0B93EF7B1EC608550030D24D /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B93EF7A1EC608550030D24D /* CoreText.framework */; }; 0B93EF7E1EC9DDCD0030D24D /* RCTBridgeWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B93EF7C1EC9DDCD0030D24D /* RCTBridgeWrapper.h */; }; 0B93EF7F1EC9DDCD0030D24D /* RCTBridgeWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B93EF7D1EC9DDCD0030D24D /* RCTBridgeWrapper.m */; }; 0BA13D311EE83FF8007BEF7F /* ExternalAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BA13D301EE83FF8007BEF7F /* ExternalAPI.m */; }; @@ -114,7 +113,6 @@ files = ( 0BB9AD791F5EC6D7001C08DB /* Intents.framework in Frameworks */, 0BB9AD771F5EC6CE001C08DB /* CallKit.framework in Frameworks */, - 0B93EF7B1EC608550030D24D /* CoreText.framework in Frameworks */, 0F65EECE1D95DA94561BB47E /* libPods-JitsiMeet.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ios/sdk/src/Info.plist b/ios/sdk/src/Info.plist index 0b9c0fb0f..b534be789 100644 --- a/ios/sdk/src/Info.plist +++ b/ios/sdk/src/Info.plist @@ -18,10 +18,6 @@ 1.9.0 CFBundleVersion $(CURRENT_PROJECT_VERSION) - JitsiMeetFonts - - jitsi.ttf - LSApplicationQueriesSchemes dbapi-2 diff --git a/ios/sdk/src/JitsiMeetView.m b/ios/sdk/src/JitsiMeetView.m index 75f05932d..0799ef0cb 100644 --- a/ios/sdk/src/JitsiMeetView.m +++ b/ios/sdk/src/JitsiMeetView.m @@ -14,7 +14,6 @@ * limitations under the License. */ -#import #import #include @@ -53,35 +52,6 @@ RCTFatalHandler _RCTFatal = ^(NSError *error) { } }; -/** - * Helper function to dynamically load custom fonts. The `UIAppFonts` key in the - * plist file doesn't work for frameworks, so fonts have to be manually loaded. - */ -void loadCustomFonts(Class clazz) { - NSBundle *bundle = [NSBundle bundleForClass:clazz]; - NSArray *fonts = [bundle objectForInfoDictionaryKey:@"JitsiMeetFonts"]; - - for (NSString *item in fonts) { - NSString *fontName = [item stringByDeletingPathExtension]; - NSString *fontExt = [item pathExtension]; - NSString *fontPath = [bundle pathForResource:fontName ofType:fontExt]; - NSData *inData = [NSData dataWithContentsOfFile:fontPath]; - CFErrorRef error; - CGDataProviderRef provider - = CGDataProviderCreateWithCFData((__bridge CFDataRef)inData); - CGFontRef font = CGFontCreateWithDataProvider(provider); - - if (!CTFontManagerRegisterGraphicsFont(font, &error)) { - CFStringRef errorDescription = CFErrorCopyDescription(error); - - NSLog(@"Failed to load font: %@", errorDescription); - CFRelease(errorDescription); - } - CFRelease(font); - CFRelease(provider); - } -} - /** * Helper function to register a fatal error handler for React. Our handler * won't kill the process, it will swallow JS errors and print stack traces @@ -410,9 +380,6 @@ static NSMapTable *views; = [[RCTBridgeWrapper alloc] initWithLaunchOptions:_launchOptions]; views = [NSMapTable strongToWeakObjectsMapTable]; - // Dynamically load custom bundled fonts. - loadCustomFonts(self.class); - // Register a fatal error handler for React. registerFatalErrorHandler(); }); diff --git a/react/features/base/font-icons/Icon.js b/react/features/base/font-icons/Icon.js index 622b4a433..85a561fac 100644 --- a/react/features/base/font-icons/Icon.js +++ b/react/features/base/font-icons/Icon.js @@ -1,3 +1,5 @@ +import { Platform } from 'react-native'; + // FIXME The import of react-native-vector-icons makes the file native-specific // but the file's name and/or location (within the directory structure) don't // reflect that, it suggests the file is platform-independent. @@ -10,3 +12,8 @@ import icoMoonConfig from './jitsi.json'; * Creates the Jitsi icon set from the ico moon project config file. */ export const Icon = createIconSetFromIcoMoon(icoMoonConfig); + +// Dynamically load font on iOS +if (Platform.OS === 'ios') { + Icon.loadFont('jitsi.ttf'); +}